cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/2.24-su-suppress-PAM-info-messages.patch

6717ab
diff -up util-linux-2.23.2/login-utils/su-common.c.kzak util-linux-2.23.2/login-utils/su-common.c
6717ab
--- util-linux-2.23.2/login-utils/su-common.c.kzak	2013-07-30 10:39:26.223738407 +0200
6717ab
+++ util-linux-2.23.2/login-utils/su-common.c	2013-09-09 09:32:05.497238691 +0200
6717ab
@@ -111,6 +111,9 @@ static int same_session = 0;
6717ab
 /* SU_MODE_{RUNUSER,SU} */
6717ab
 static int su_mode;
6717ab
6717ab
+/* Don't print PAM info messages (Last login, etc.). */
6717ab
+static int suppress_pam_info;
6717ab
+
6717ab
 static bool _pam_session_opened;
6717ab
 static bool _pam_cred_established;
6717ab
 static sig_atomic_t volatile caught_signal = false;
6717ab
@@ -208,10 +211,23 @@ static void log_btmp(struct passwd const
6717ab
	updwtmp(_PATH_BTMP, &ut);
6717ab
 }
6717ab
6717ab
+
6717ab
+static int su_pam_conv(int num_msg, const struct pam_message **msg,
6717ab
+                       struct pam_response **resp, void *appdata_ptr)
6717ab
+{
6717ab
+	if (suppress_pam_info
6717ab
+	    && num_msg == 1
6717ab
+	    && msg
6717ab
+	    && msg[0]->msg_style == PAM_TEXT_INFO)
6717ab
+		return PAM_SUCCESS;
6717ab
+
6717ab
+	return misc_conv(num_msg, msg, resp, appdata_ptr);
6717ab
+}
6717ab
+
6717ab
 static struct pam_conv conv =
6717ab
 {
6717ab
-  misc_conv,
6717ab
-  NULL
6717ab
+	su_pam_conv,
6717ab
+	NULL
6717ab
 };
6717ab
6717ab
 static void
6717ab
@@ -902,6 +918,9 @@ su_main (int argc, char **argv, int mode
6717ab
6717ab
   init_groups (pw, groups, num_supp_groups);
6717ab
6717ab
+  if (!simulate_login || command)
6717ab
+    suppress_pam_info = 1;		/* don't print PAM info messages */
6717ab
+
6717ab
   create_watching_parent ();
6717ab
   /* Now we're in the child.  */