Blame SOURCES/sudo-1.8.6p7-logsudouser.patch

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