Blame SOURCES/sudo-1.8.6p7-logsudouser.patch

22f5af
From 06b46ae226fecd4188af372ac0ccd7aa582e21c8 Mon Sep 17 00:00:00 2001
22f5af
From: Tomas Sykora <tosykora@redhat.com>
22f5af
Date: Wed, 17 Aug 2016 10:12:11 +0200
22f5af
Subject: [PATCH] Sudo logs username root instead of realuser
22f5af
22f5af
RHEL7 sudo logs username root instead of realuser in /var/log/secure
22f5af
22f5af
Rebased from:
22f5af
Patch50: sudo-1.8.6p7-logsudouser.patch
22f5af
22f5af
Resolves:
22f5af
rhbz#1312486
22f5af
---
22f5af
 plugins/sudoers/logging.c | 14 +++++++-------
22f5af
 plugins/sudoers/sudoers.h |  1 +
22f5af
 2 files changed, 8 insertions(+), 7 deletions(-)
22f5af
22f5af
diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c
22f5af
index 45cae67..74b2220 100644
22f5af
--- a/plugins/sudoers/logging.c
22f5af
+++ b/plugins/sudoers/logging.c
22f5af
@@ -104,7 +104,7 @@ do_syslog(int pri, char *msg)
22f5af
      * Log the full line, breaking into multiple syslog(3) calls if necessary
22f5af
      */
22f5af
     fmt = _("%8s : %s");
22f5af
-    maxlen = def_syslog_maxlen - (strlen(fmt) - 5 + strlen(user_name));
22f5af
+    maxlen = def_syslog_maxlen - (strlen(fmt) - 5 + strlen(sudo_user_name));
22f5af
     for (p = msg; *p != '\0'; ) {
22f5af
 	len = strlen(p);
22f5af
 	if (len > maxlen) {
22f5af
@@ -120,7 +120,7 @@ do_syslog(int pri, char *msg)
22f5af
 	    save = *tmp;
22f5af
 	    *tmp = '\0';
22f5af
 
22f5af
-	    mysyslog(pri, fmt, user_name, p);
22f5af
+	    mysyslog(pri, fmt, sudo_user_name, p);
22f5af
 
22f5af
 	    *tmp = save;			/* restore saved character */
22f5af
 
22f5af
@@ -128,11 +128,11 @@ do_syslog(int pri, char *msg)
22f5af
 	    for (p = tmp; *p == ' '; p++)
22f5af
 		continue;
22f5af
 	} else {
22f5af
-	    mysyslog(pri, fmt, user_name, p);
22f5af
+	    mysyslog(pri, fmt, sudo_user_name, p);
22f5af
 	    p += len;
22f5af
 	}
22f5af
 	fmt = _("%8s : (command continued) %s");
22f5af
-	maxlen = def_syslog_maxlen - (strlen(fmt) - 5 + strlen(user_name));
22f5af
+	maxlen = def_syslog_maxlen - (strlen(fmt) - 5 + strlen(sudo_user_name));
22f5af
     }
22f5af
 
22f5af
     sudoers_setlocale(oldlocale, NULL);
22f5af
@@ -179,10 +179,10 @@ do_logfile(const char *msg)
22f5af
 	timestr = "invalid date";
22f5af
     if (def_log_host) {
22f5af
 	len = asprintf(&full_line, "%s : %s : HOST=%s : %s",
22f5af
-	    timestr, user_name, user_srunhost, msg);
22f5af
+	    timestr, sudo_user_name, user_srunhost, msg);
22f5af
     } else {
22f5af
 	len = asprintf(&full_line, "%s : %s : %s",
22f5af
-	    timestr, user_name, msg);
22f5af
+	    timestr, sudo_user_name, msg);
22f5af
     }
22f5af
     if (len == -1) {
22f5af
 	sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
22f5af
@@ -746,7 +746,7 @@ send_mail(const char *fmt, ...)
22f5af
 
22f5af
     if ((timestr = get_timestr(time(NULL), def_log_year)) == NULL)
22f5af
 	timestr = "invalid date";
22f5af
-    (void) fprintf(mail, "\n\n%s : %s : %s : ", user_host, timestr, user_name);
22f5af
+    (void) fprintf(mail, "\n\n%s : %s : %s : ", user_host, timestr, sudo_user_name);
22f5af
     va_start(ap, fmt);
22f5af
     (void) vfprintf(mail, fmt, ap);
22f5af
     va_end(ap);
22f5af
diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h
22f5af
index cfd5abb..c69a043 100644
22f5af
--- a/plugins/sudoers/sudoers.h
22f5af
+++ b/plugins/sudoers/sudoers.h
22f5af
@@ -180,6 +180,7 @@ struct sudo_user {
22f5af
 /*
22f5af
  * Shortcuts for sudo_user contents.
22f5af
  */
22f5af
+#define sudo_user_name		(sudo_user.pw->pw_name)
22f5af
 #define user_name		(sudo_user.name)
22f5af
 #define user_uid		(sudo_user.uid)
22f5af
 #define user_gid		(sudo_user.gid)
22f5af
-- 
22f5af
2.7.4
22f5af