diff options
author | truckman <truckman@FreeBSD.org> | 2016-05-23 05:11:08 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-05-23 05:11:08 +0000 |
commit | b92c1d64bb76696e6668913a140f5ec64a0e24d8 (patch) | |
tree | 0c1328513a13cda101db1654c588e47f3fc1478b | |
parent | 91fbd99e629388c273182ddea4f1037d73d168d2 (diff) | |
download | FreeBSD-src-b92c1d64bb76696e6668913a140f5ec64a0e24d8.zip FreeBSD-src-b92c1d64bb76696e6668913a140f5ec64a0e24d8.tar.gz |
MFC r299926
Hoist the getpwnam() call outside the first if/else block in
pam_sm_chauthtok(). Set user = getlogin() inside the true
branch so that it is initialized for the following PAM_LOG()
call. This is how it is done in pam_sm_authenticate().
Reported by: Coverity
CID: 272498
-rw-r--r-- | lib/libpam/modules/pam_unix/pam_unix.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libpam/modules/pam_unix/pam_unix.c b/lib/libpam/modules/pam_unix/pam_unix.c index 9a213e2..8c6b822 100644 --- a/lib/libpam/modules/pam_unix/pam_unix.c +++ b/lib/libpam/modules/pam_unix/pam_unix.c @@ -278,13 +278,13 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, int pfd, tfd, retval; if (openpam_get_option(pamh, PAM_OPT_AUTH_AS_SELF)) - pwd = getpwnam(getlogin()); + user = getlogin(); else { retval = pam_get_user(pamh, &user, NULL); if (retval != PAM_SUCCESS) return (retval); - pwd = getpwnam(user); } + pwd = getpwnam(user); if (pwd == NULL) return (PAM_AUTHTOK_RECOVERY_ERR); |