Blame SOURCES/sudo-1.8.6p7-logsudouser.patch

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