dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
25f9c8
From 9e7cedda86e5356d1723e6bd0bab5e38c4fe4a34 Mon Sep 17 00:00:00 2001
25f9c8
From: "Andrew G. Morgan" <morgan@kernel.org>
25f9c8
Date: Sat, 27 Nov 2021 21:00:22 -0800
25f9c8
Subject: [PATCH 74/74] Complete Linux-PAM compliance for forked child in su
25f9c8
 and login.
25f9c8
25f9c8
As documented here:
25f9c8
25f9c8
http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end
25f9c8
25f9c8
The child that is about to exec*() the user shell is supposed to pam_end()
25f9c8
with PAM_DATA_SILENT. This gives the modules a last chance to do a minor
25f9c8
cleanup of the module state before the user's shell is launched.
25f9c8
25f9c8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1950187
25f9c8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2033566
25f9c8
Upstream: http://github.com/util-linux/util-linux/commit/4660286e9cdff6d95b49295674b96f83af10ea36
25f9c8
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
25f9c8
---
25f9c8
 login-utils/login.c     | 3 +++
25f9c8
 login-utils/su-common.c | 3 +++
25f9c8
 2 files changed, 6 insertions(+)
25f9c8
25f9c8
diff --git a/login-utils/login.c b/login-utils/login.c
25f9c8
index 8c9e43292..9f50fe03b 100644
25f9c8
--- a/login-utils/login.c
25f9c8
+++ b/login-utils/login.c
25f9c8
@@ -1370,6 +1370,9 @@ int main(int argc, char **argv)
25f9c8
 
25f9c8
 	childArgv[childArgc++] = NULL;
25f9c8
 
25f9c8
+	/* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
25f9c8
+	(void) pam_end(cxt.pamh, PAM_SUCCESS|PAM_DATA_SILENT);
25f9c8
+
25f9c8
 	execvp(childArgv[0], childArgv + 1);
25f9c8
 
25f9c8
 	if (!strcmp(childArgv[0], "/bin/sh"))
25f9c8
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
25f9c8
index c1b1a04e4..825ff1d5a 100644
25f9c8
--- a/login-utils/su-common.c
25f9c8
+++ b/login-utils/su-common.c
25f9c8
@@ -1428,6 +1428,9 @@ int su_main(int argc, char **argv, int mode)
25f9c8
 	if (su->simulate_login && chdir(su->pwd->pw_dir) != 0)
25f9c8
 		warn(_("warning: cannot change directory to %s"), su->pwd->pw_dir);
25f9c8
 
25f9c8
+	/* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
25f9c8
+	(void) pam_end(su->pamh, PAM_SUCCESS|PAM_DATA_SILENT);
25f9c8
+
25f9c8
 	if (shell)
25f9c8
 		run_shell(su, shell, command, argv + optind, max(0, argc - optind));
25f9c8
 
25f9c8
-- 
25f9c8
2.31.1
25f9c8