diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/passdb/passdb.c | 29 | ||||
-rw-r--r-- | source3/passdb/pdb_ldap.c | 49 | ||||
-rw-r--r-- | source3/passdb/pdb_nisplus.c | 40 | ||||
-rw-r--r-- | source3/passdb/pdb_smbpasswd.c | 42 | ||||
-rw-r--r-- | source3/passdb/pdb_tdb.c | 25 |
5 files changed, 29 insertions, 156 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index ca7c508dc5..eeecc0abe5 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -1793,4 +1793,33 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext) return True; } +/*************************************************************************** + Search by uid. Wrapper around pdb_getsampwnam() + **************************************************************************/ + +BOOL pdb_getsampwuid (SAM_ACCOUNT* user, uid_t uid) +{ + struct passwd *pw; + fstring name; + + if (user==NULL) { + DEBUG(0,("pdb_getsampwuid: SAM_ACCOUNT is NULL.\n")); + return False; + } + + /* + * Never trust the uid in the passdb. Lookup the username first + * and then lokup the user by name in the sam. + */ + + if ((pw=sys_getpwuid(uid)) == NULL) { + DEBUG(0,("pdb_getsampwuid: getpwuid(%d) return NULL. User does not exist in Unix accounts!\n", uid)); + return False; + } + + fstrcpy (name, pw->pw_name); + + return pdb_getsampwnam (user, name); + +} diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index a6593491d0..215292be48 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -782,55 +782,6 @@ BOOL pdb_getsampwrid(SAM_ACCOUNT * user, uint32 rid) } /********************************************************************** - Get SAM_ACCOUNT entry from LDAP by uid -*********************************************************************/ -BOOL pdb_getsampwuid(SAM_ACCOUNT * user, uid_t uid) -{ - LDAP *ldap_struct; - LDAPMessage *result; - LDAPMessage *entry; - - if (!ldap_open_connection(&ldap_struct)) - return False; - - if (!ldap_connect_system(ldap_struct)) - { - ldap_unbind(ldap_struct); - return False; - } - if (ldap_search_one_user_by_uid(ldap_struct, uid, &result) != - LDAP_SUCCESS) - { - ldap_unbind(ldap_struct); - return False; - } - - if (ldap_count_entries(ldap_struct, result) < 1) - { - DEBUG(0, - ("We don't find this uid [%i] count=%d\n", uid, - ldap_count_entries(ldap_struct, result))); - ldap_unbind(ldap_struct); - return False; - } - entry = ldap_first_entry(ldap_struct, result); - if (entry) - { - init_sam_from_ldap(user, ldap_struct, entry); - ldap_msgfree(result); - ldap_unbind(ldap_struct); - return True; - } - else - { - ldap_msgfree(result); - ldap_unbind(ldap_struct); - return False; - } -} - - -/********************************************************************** Delete entry from LDAP for username *********************************************************************/ BOOL pdb_delete_sam_account(const char *sname) diff --git a/source3/passdb/pdb_nisplus.c b/source3/passdb/pdb_nisplus.c index 27dd420f3f..c2505b99f5 100644 --- a/source3/passdb/pdb_nisplus.c +++ b/source3/passdb/pdb_nisplus.c @@ -1019,46 +1019,6 @@ BOOL pdb_getsampwrid(SAM_ACCOUNT * user, uint32 rid) } /************************************************************************* - Routine to search the nisplus passwd file for an entry matching the username - *************************************************************************/ -BOOL pdb_getsampwuid(SAM_ACCOUNT * user, uid_t uid) -{ - nis_result *result; - char *nisname; - BOOL ret; - char *sp, *p = lp_smb_passwd_file(); - pstring pfiletmp; - - if (!*p) - { - DEBUG(0, ("no SMB password file set\n")); - return False; - } - - if( (sp = strrchr( p, '/' )) ) - safe_strcpy(pfiletmp, sp+1, sizeof(pfiletmp)-1); - else - safe_strcpy(pfiletmp, p, sizeof(pfiletmp)-1); - safe_strcat(pfiletmp, ".org_dir", sizeof(pfiletmp)-strlen(pfiletmp)-1); - - nisname = make_nisname_from_uid(uid, pfiletmp); - - DEBUG(10, ("search by uid: %s\n", nisname)); - - /* Search the table. */ - - if(!(result = nisp_get_nis_list(nisname, 0))) - { - return False; - } - - ret = make_sam_from_nisresult(user, result); - nis_freeresult(result); - - return ret; -} - -/************************************************************************* Routine to remove entry from the nisplus smbpasswd table *************************************************************************/ BOOL pdb_delete_sam_account(const char *sname) diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index 8e942a60fb..e82e94dae5 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1418,48 +1418,6 @@ BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username) } -BOOL pdb_getsampwuid (SAM_ACCOUNT *sam_acct, uid_t uid) -{ - struct smb_passwd *smb_pw; - void *fp = NULL; - - DEBUG(10, ("pdb_getsampwuid: search by uid: %d\n", (int)uid)); - - /* Open the sam password file - not for update. */ - fp = startsmbfilepwent(lp_smb_passwd_file(), PWF_READ, &pw_file_lock_depth); - - if (fp == NULL) { - DEBUG(0, ("unable to open passdb database.\n")); - return False; - } - - while ( ((smb_pw=getsmbfilepwent(fp)) != NULL) && (smb_pw->smb_userid != uid) ) - /* do nothing */ ; - - endsmbfilepwent(fp, &pw_file_lock_depth); - - /* did we locate the username in smbpasswd */ - if (smb_pw == NULL) - return False; - - DEBUG(10, ("pdb_getsampwuid: found by name: %s\n", smb_pw->smb_name)); - - if (!sam_acct) { - DEBUG(10,("pdb_getsampwuid:SAM_ACCOUNT is NULL\n")); -#if 0 - smb_panic("NULL pointer passed to pdb_getsampwuid\n"); -#endif - return False; - } - - /* now build the SAM_ACCOUNT */ - if (!build_sam_account(sam_acct, smb_pw)) - return False; - - /* success */ - return True; -} - BOOL pdb_getsampwrid(SAM_ACCOUNT *sam_acct,uint32 rid) { struct smb_passwd *smb_pw; diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 08439a9d20..fbfdd1aace 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -542,31 +542,6 @@ BOOL pdb_getsampwnam (SAM_ACCOUNT *user, const char *sname) } /*************************************************************************** - Search by uid - **************************************************************************/ - -BOOL pdb_getsampwuid (SAM_ACCOUNT* user, uid_t uid) -{ - struct passwd *pw; - fstring name; - - if (user==NULL) { - DEBUG(0,("pdb_getsampwuid: SAM_ACCOUNT is NULL.\n")); - return False; - } - - pw = sys_getpwuid(uid); - if (pw == NULL) { - DEBUG(0,("pdb_getsampwuid: getpwuid(%d) return NULL. User does not exist!\n", uid)); - return False; - } - fstrcpy (name, pw->pw_name); - - return pdb_getsampwnam (user, name); - -} - -/*************************************************************************** Search by rid **************************************************************************/ |