Blame SOURCES/sudo-1.8.6p7-logsudouser.patch

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