Skip to content

Commit

Permalink
Complete Linux-PAM compliance for forked child in su and login.
Browse files Browse the repository at this point in the history
As documented here:

http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end

The child that is about to exec*() the user shell is supposed to pam_end()
with PAM_DATA_SILENT. This gives the modules a last chance to do a minor
cleanup of the module state before the user's shell is launched.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2037212
Upstream: http://github.com/util-linux/util-linux/commit/4660286e9cdff6d95b49295674b96f83af10ea36
Signed-off-by: Andrew G. Morgan <[email protected]>
  • Loading branch information
AndrewGMorgan authored and karelzak committed Jan 6, 2022
1 parent d39f86f commit 962d377
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions login-utils/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,9 @@ int main(int argc, char **argv)

child_argv[child_argc++] = NULL;

/* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
(void) pam_end(cxt.pamh, PAM_SUCCESS|PAM_DATA_SILENT);

execvp(child_argv[0], child_argv + 1);

if (!strcmp(child_argv[0], "/bin/sh"))
Expand Down
3 changes: 3 additions & 0 deletions login-utils/su-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,9 @@ int su_main(int argc, char **argv, int mode)
if (su->simulate_login && chdir(su->pwd->pw_dir) != 0)
warn(_("warning: cannot change directory to %s"), su->pwd->pw_dir);

/* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
(void) pam_end(su->pamh, PAM_SUCCESS|PAM_DATA_SILENT);

if (shell)
run_shell(su, shell, command, argv + optind, max(0, argc - optind));

Expand Down

0 comments on commit 962d377

Please sign in to comment.