svn commit: samba r18483 - in branches: SAMBA_3_0/source/passdb SAMBA_3_0_23/source/passdb

jra at samba.org jra at samba.org
Wed Sep 13 16:30:42 GMT 2006


Author: jra
Date: 2006-09-13 16:30:40 +0000 (Wed, 13 Sep 2006)
New Revision: 18483

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18483

Log:
Ensure all pdb_XXX calls are wrapped in become_root()/unbecome_root()
pairs. Should fix bug #4097.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/passdb/lookup_sid.c
   branches/SAMBA_3_0_23/source/passdb/lookup_sid.c


Changeset:
Modified: branches/SAMBA_3_0/source/passdb/lookup_sid.c
===================================================================
--- branches/SAMBA_3_0/source/passdb/lookup_sid.c	2006-09-13 16:29:14 UTC (rev 18482)
+++ branches/SAMBA_3_0/source/passdb/lookup_sid.c	2006-09-13 16:30:40 UTC (rev 18483)
@@ -1117,6 +1117,7 @@
 {
 	uid_t low, high;
 	uint32 rid;
+	BOOL ret;
 
 	ZERO_STRUCTP(psid);
 
@@ -1131,7 +1132,11 @@
 		goto done;
 	}
 
-	if (pdb_uid_to_rid(uid, &rid)) {
+	become_root();
+	ret = pdb_uid_to_rid(uid, &rid);
+	unbecome_root();
+
+	if (ret) {
 		/* This is a mapped user */
 		sid_copy(psid, get_global_sam_sid());
 		sid_append_rid(psid, rid);
@@ -1156,6 +1161,7 @@
 
 void gid_to_sid(DOM_SID *psid, gid_t gid)
 {
+	BOOL ret;
 	gid_t low, high;
 
 	ZERO_STRUCTP(psid);
@@ -1171,7 +1177,11 @@
 		goto done;
 	}
 
-	if (pdb_gid_to_sid(gid, psid)) {
+	become_root();
+	ret = pdb_gid_to_sid(gid, psid);
+	unbecome_root();
+
+	if (ret) {
 		/* This is a mapped group */
 		goto done;
 	}
@@ -1213,8 +1223,13 @@
 
 	if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
 		union unid_t id;
+		BOOL ret;
 
-		if (pdb_sid_to_id(psid, &id, &type)) {
+		become_root();
+		ret = pdb_sid_to_id(psid, &id, &type);
+		unbecome_root();
+
+		if (ret) {
 			if (type != SID_NAME_USER) {
 				DEBUG(5, ("sid %s is a %s, expected a user\n",
 					  sid_string_static(psid),
@@ -1288,7 +1303,13 @@
 
 	if ((sid_check_is_in_builtin(psid) ||
 	     sid_check_is_in_wellknown_domain(psid))) {
-		if (pdb_getgrsid(&map, *psid)) {
+		BOOL ret;
+
+		become_root();
+		ret = pdb_getgrsid(&map, *psid);
+		unbecome_root();
+
+		if (ret) {
 			*pgid = map.gid;
 			goto done;
 		}
@@ -1296,7 +1317,13 @@
 	}
 
 	if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
-		if (pdb_sid_to_id(psid, &id, &type)) {
+		BOOL ret;
+
+		become_root();
+		ret = pdb_sid_to_id(psid, &id, &type);
+		unbecome_root();
+
+		if (ret) {
 			if ((type != SID_NAME_DOM_GRP) &&
 			    (type != SID_NAME_ALIAS)) {
 				DEBUG(5, ("sid %s is a %s, expected a group\n",

Modified: branches/SAMBA_3_0_23/source/passdb/lookup_sid.c
===================================================================
--- branches/SAMBA_3_0_23/source/passdb/lookup_sid.c	2006-09-13 16:29:14 UTC (rev 18482)
+++ branches/SAMBA_3_0_23/source/passdb/lookup_sid.c	2006-09-13 16:30:40 UTC (rev 18483)
@@ -1069,6 +1069,7 @@
 {
 	uid_t low, high;
 	uint32 rid;
+	BOOL ret;
 
 	ZERO_STRUCTP(psid);
 
@@ -1083,7 +1084,11 @@
 		goto done;
 	}
 
-	if (pdb_uid_to_rid(uid, &rid)) {
+	become_root();
+	ret = pdb_uid_to_rid(uid, &rid);
+	unbecome_root();
+
+	if (ret) {
 		/* This is a mapped user */
 		sid_copy(psid, get_global_sam_sid());
 		sid_append_rid(psid, rid);
@@ -1108,6 +1113,7 @@
 
 void gid_to_sid(DOM_SID *psid, gid_t gid)
 {
+	BOOL ret;
 	gid_t low, high;
 
 	ZERO_STRUCTP(psid);
@@ -1123,7 +1129,11 @@
 		goto done;
 	}
 
-	if (pdb_gid_to_sid(gid, psid)) {
+	become_root();
+	ret = pdb_gid_to_sid(gid, psid);
+	unbecome_root();
+
+	if (ret) {
 		/* This is a mapped group */
 		goto done;
 	}
@@ -1165,8 +1175,13 @@
 
 	if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
 		union unid_t id;
+		BOOL ret;
 
-		if (pdb_sid_to_id(psid, &id, &type)) {
+		become_root();
+		ret = pdb_sid_to_id(psid, &id, &type);
+		unbecome_root();
+
+		if (ret) {
 			if (type != SID_NAME_USER) {
 				DEBUG(5, ("sid %s is a %s, expected a user\n",
 					  sid_string_static(psid),
@@ -1240,7 +1255,13 @@
 
 	if ((sid_check_is_in_builtin(psid) ||
 	     sid_check_is_in_wellknown_domain(psid))) {
-		if (pdb_getgrsid(&map, *psid)) {
+		BOOL ret;
+
+		become_root();
+		ret = pdb_getgrsid(&map, *psid);
+		unbecome_root();
+
+		if (ret) {
 			*pgid = map.gid;
 			goto done;
 		}
@@ -1248,7 +1269,13 @@
 	}
 
 	if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
-		if (pdb_sid_to_id(psid, &id, &type)) {
+		BOOL ret;
+
+		become_root();
+		ret = pdb_sid_to_id(psid, &id, &type);
+		unbecome_root();
+
+		if (ret) {
 			if ((type != SID_NAME_DOM_GRP) &&
 			    (type != SID_NAME_ALIAS)) {
 				DEBUG(5, ("sid %s is a %s, expected a group\n",



More information about the samba-cvs mailing list