From 7a12f22e9e599c96fd1905ec606609f489704fba Mon Sep 17 00:00:00 2001 From: basebuilder_pel7ppc64bebuilder0 Date: Thu, 17 May 2018 19:13:32 +0200 Subject: [PATCH] util linux patches Signed-off-by: basebuilder_pel7ppc64bebuilder0 --- ...ly-only-getlogin-3-telling-who-ran-t.patch | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 SOURCES/0134-logger-do-not-rely-only-getlogin-3-telling-who-ran-t.patch diff --git a/SOURCES/0134-logger-do-not-rely-only-getlogin-3-telling-who-ran-t.patch b/SOURCES/0134-logger-do-not-rely-only-getlogin-3-telling-who-ran-t.patch new file mode 100644 index 00000000..f1f06eb6 --- /dev/null +++ b/SOURCES/0134-logger-do-not-rely-only-getlogin-3-telling-who-ran-t.patch @@ -0,0 +1,78 @@ +From 70ed51ccc2e8e6c4976d422af960e4232210fb99 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 16 Oct 2017 13:31:47 +0200 +Subject: [PATCH 134/135] logger: do not rely only getlogin(3) telling who ran + the command + +The getlogin(3) is known not to always work, and when that happens it +is reasonable to try determine user of name by looking process owner +and passwd information. + +Upstream: http://github.com/karelzak/util-linux/commit/019b97024fde3f07eaf541eef990762483369a11 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1336432 +Signed-off-by: Karel Zak +--- + misc-utils/logger.c | 25 ++++++++++++++++--------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +diff --git a/misc-utils/logger.c b/misc-utils/logger.c +index dfda01866..c1cec45e8 100644 +--- a/misc-utils/logger.c ++++ b/misc-utils/logger.c +@@ -49,6 +49,8 @@ + #include + #include + #include ++#include ++#include + + #include "c.h" + #include "closestream.h" +@@ -183,9 +185,20 @@ inet_socket(const char *servername, const char *port, const int socket_type) + return fd; + } + ++static char const *xgetlogin(void) ++{ ++ char const *cp; ++ struct passwd *pw; ++ ++ if (!(cp = getlogin()) || !*cp) ++ cp = (pw = getpwuid(geteuid()))? pw->pw_name : ""; ++ return cp; ++} ++ + static void + mysyslog(int fd, int logflags, int pri, char *tag, char *msg) { +- char *buf, pid[30], *cp, *tp; ++ char *buf, pid[30], *tp; ++ const char *cp; + time_t now; + + if (fd > -1) { +@@ -193,13 +206,7 @@ mysyslog(int fd, int logflags, int pri, char *tag, char *msg) { + snprintf (pid, sizeof(pid), "[%d]", getpid()); + else + pid[0] = 0; +- if (tag) +- cp = tag; +- else { +- cp = getlogin(); +- if (!cp) +- cp = ""; +- } ++ cp = tag ? tag : xgetlogin(); + (void)time(&now); + tp = ctime(&now)+4; + +@@ -334,7 +341,7 @@ main(int argc, char **argv) { + else if (usock) + LogSock = unix_socket(usock, socket_type); + else +- openlog(tag ? tag : getlogin(), logflags, 0); ++ openlog(tag ? tag : xgetlogin(), logflags, 0); + + buf = xcalloc(1, max_message_size); + +-- +2.13.6