* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c,
src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c, src/chsh.c: Simplify the PAM error handling. Do not keep the pamh handle, but terminate the PAM transaction as soon as possible if there are no PAM session opened.
This commit is contained in:
@@ -440,7 +440,7 @@ static void check_perms (void)
|
||||
if (!list) {
|
||||
#ifdef USE_PAM
|
||||
pam_handle_t *pamh = NULL;
|
||||
int retval = PAM_SUCCESS;
|
||||
int retval;
|
||||
struct passwd *pampw;
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
@@ -459,7 +459,9 @@ static void check_perms (void)
|
||||
retval = pam_acct_mgmt (pamh, 0);
|
||||
}
|
||||
|
||||
(void) pam_end (pamh, retval);
|
||||
if (NULL != pamh) {
|
||||
(void) pam_end (pamh, retval);
|
||||
}
|
||||
if (PAM_SUCCESS != retval) {
|
||||
fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
|
||||
fail_exit (1);
|
||||
|
||||
Reference in New Issue
Block a user