diff options
author | Simo Sorce <idra@samba.org> | 2002-01-12 23:11:35 +0000 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2002-01-12 23:11:35 +0000 |
commit | 92445af3dd88dd3102217ecf945d58c810d1a564 (patch) | |
tree | fc3df62404020d1d9e7e26acecfd773e42b37c10 | |
parent | f364aaa52cebb92b4ed6fa0a589f268ac05ddeaa (diff) | |
download | samba-92445af3dd88dd3102217ecf945d58c810d1a564.tar.gz samba-92445af3dd88dd3102217ecf945d58c810d1a564.tar.xz samba-92445af3dd88dd3102217ecf945d58c810d1a564.zip |
fix a wrong check on sampass beeing null.
it can never be null, the bug got in when the interface was changed from
the previous smb_passwd structure.
thanks to Kyle VanderBeek <kylev@yaga.com> for pointing out the bug.
-rw-r--r-- | source/pam_smbpass/pam_smb_auth.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/pam_smbpass/pam_smb_auth.c b/source/pam_smbpass/pam_smb_auth.c index e9502165aaa..a4f784701c3 100644 --- a/source/pam_smbpass/pam_smb_auth.c +++ b/source/pam_smbpass/pam_smb_auth.c @@ -45,7 +45,7 @@ do { \ } while (0) static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl, - const char *name, SAM_ACCOUNT *sampass); + const char *name, SAM_ACCOUNT *sampass, BOOL exist); /* * pam_sm_authenticate() authenticates users against the samba password file. @@ -64,6 +64,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, SAM_ACCOUNT *sampass = NULL; extern BOOL in_client; const char *name; + BOOL found; /* Points to memory managed by the PAM library. Do not free. */ char *p = NULL; @@ -101,15 +102,15 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, pdb_init_sam(&sampass); - pdb_getsampwnam( sampass, name ); + found = pdb_getsampwnam( sampass, name ); if (on( SMB_MIGRATE, ctrl )) { - retval = _smb_add_user(pamh, ctrl, name, sampass); + retval = _smb_add_user(pamh, ctrl, name, sampass, found); pdb_free_sam(sampass); AUTH_RETURN; } - if (sampass == NULL) { + if (!found) { _log_err(LOG_ALERT, "Failed to find entry for user %s.", name); retval = PAM_USER_UNKNOWN; pdb_free_sam(sampass); @@ -168,7 +169,7 @@ int pam_sm_setcred(pam_handle_t *pamh, int flags, /* Helper function for adding a user to the db. */ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl, - const char *name, SAM_ACCOUNT *sampass) + const char *name, SAM_ACCOUNT *sampass, BOOL exist) { pstring err_str; pstring msg_str; @@ -190,7 +191,7 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl, } /* Add the user to the db if they aren't already there. */ - if (sampass == NULL) { + if (!exist) { retval = local_password_change( name, LOCAL_ADD_USER, pass, err_str, sizeof(err_str), @@ -208,8 +209,8 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl, pass = NULL; return PAM_IGNORE; - } - + } + else { /* Change the user's password IFF it's null. */ if ((pdb_get_lanman_passwd(sampass) == NULL) && (pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ)) { @@ -226,6 +227,8 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl, make_remark( pamh, ctrl, PAM_TEXT_INFO, msg_str ); } } + } + pass = NULL; return PAM_IGNORE; |