cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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