diff options
author | Jeremy Allison <jra@samba.org> | 2003-07-09 00:20:43 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-07-09 00:20:43 +0000 |
commit | 6bd47884030c9c124c4bba1f0d57cb8dd916530d (patch) | |
tree | 74496c232974e2d5a2707bee04c1b13318d90e4e /source | |
parent | f3c2e73a8c1c592d407542c12c0a445103415bc0 (diff) | |
download | samba-6bd47884030c9c124c4bba1f0d57cb8dd916530d.tar.gz samba-6bd47884030c9c124c4bba1f0d57cb8dd916530d.tar.xz samba-6bd47884030c9c124c4bba1f0d57cb8dd916530d.zip |
Fix up become_root/unbecome_root pairs needed around local passdb
lookups.
Jeremy.
Diffstat (limited to 'source')
-rw-r--r-- | source/passdb/passdb.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/source/passdb/passdb.c b/source/passdb/passdb.c index ff8b1b412b8..a2623ff3d70 100644 --- a/source/passdb/passdb.c +++ b/source/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); |