summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-07-09 00:20:43 +0000
committerJeremy Allison <jra@samba.org>2003-07-09 00:20:43 +0000
commit2f0c3cd8174ba7c1cdf65281d50b922e5069bfa7 (patch)
tree41c889060e5ed0780167a8a07fc5250e619448a8 /source3/passdb
parent4f0b771af0b1d0ccbe8a4a6009c382a27661ad7e (diff)
downloadsamba-2f0c3cd8174ba7c1cdf65281d50b922e5069bfa7.tar.gz
samba-2f0c3cd8174ba7c1cdf65281d50b922e5069bfa7.tar.bz2
samba-2f0c3cd8174ba7c1cdf65281d50b922e5069bfa7.zip
Fix up become_root/unbecome_root pairs needed around local passdb
lookups. Jeremy. (This used to be commit 6bd47884030c9c124c4bba1f0d57cb8dd916530d)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/passdb.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index ff8b1b412b..a2623ff3d7 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -734,7 +734,10 @@ BOOL local_lookup_sid(DOM_SID *sid, char *name, enum SID_NAME_USE *psid_name_use
}
/* see if the passdb can help us with the name of the user */
+
+ become_root();
if (pdb_getsampwsid(sam_account, sid)) {
+ unbecome_root();
fstrcpy(name, pdb_get_username(sam_account));
*psid_name_use = SID_NAME_USER;
@@ -742,7 +745,7 @@ BOOL local_lookup_sid(DOM_SID *sid, char *name, enum SID_NAME_USE *psid_name_use
return True;
}
-
+ unbecome_root();
pdb_free_sam(&sam_account);
if (pdb_getgrsid(&map, *sid)) {
@@ -840,13 +843,16 @@ BOOL local_lookup_name(const char *c_user, DOM_SID *psid, enum SID_NAME_USE *psi
return False;
}
+ become_root();
if (pdb_getsampwnam(sam_account, user)) {
+ unbecome_root();
sid_copy(psid, pdb_get_user_sid(sam_account));
*psid_name_use = SID_NAME_USER;
pdb_free_sam(&sam_account);
return True;
}
+ unbecome_root();
pdb_free_sam(&sam_account);
@@ -907,7 +913,10 @@ BOOL local_password_change(const char *user_name, int local_flags,
/* Get the smb passwd entry for this user */
pdb_init_sam(&sam_pass);
+
+ become_root();
if(!pdb_getsampwnam(sam_pass, user_name)) {
+ unbecome_root();
pdb_free_sam(&sam_pass);
if ((local_flags & LOCAL_ADD_USER) || (local_flags & LOCAL_DELETE_USER)) {
@@ -921,6 +930,7 @@ BOOL local_password_change(const char *user_name, int local_flags,
return False;
}
} else {
+ unbecome_root();
/* the entry already existed */
local_flags &= ~LOCAL_ADD_USER;
}
@@ -1046,8 +1056,6 @@ DOM_SID *local_uid_to_sid(DOM_SID *psid, uid_t uid)
SAM_ACCOUNT *sampw = NULL;
struct passwd *unix_pw;
-
-
winbind_off();
unix_pw = sys_getpwuid( uid );
winbind_on();
@@ -1062,11 +1070,14 @@ DOM_SID *local_uid_to_sid(DOM_SID *psid, uid_t uid)
return NULL;
}
+ become_root();
if ( !pdb_getsampwnam( sampw, unix_pw->pw_name ) ) {
+ unbecome_root();
DEBUG(4,("local_uid_to_sid: User %s [uid == %d] has no samba account\n",
unix_pw->pw_name, uid));
return NULL;
}
+ unbecome_root();
sid_copy( psid, pdb_get_user_sid(sampw) );
@@ -1108,11 +1119,14 @@ BOOL local_sid_to_uid(uid_t *puid, const DOM_SID *psid, enum SID_NAME_USE *name_
return False;
}
+ become_root();
if ( !pdb_getsampwsid(sampw, psid) ) {
+ unbecome_root();
DEBUG(8,("local_sid_to_uid: Could not find SID %s in passdb\n",
sid_string_static(psid)));
return False;
}
+ unbecome_root();
user_name = pdb_get_username(sampw);