dcavalca / rpms / util-linux

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