It defined its own xgetlogin, which queried geteuid() instead of getuid(),
with a fallback to "<someone>" when lookup fails. This has been the case
since the function was introduced in
019b97024fde3f07eaf541eef990762483369a11, so geteuid() has always been
used. Since using geteuid for identification isn't consistent with the
rest of util-linux, switching to xgetlogin(), which uses getuid(),
should be correct.
Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
MANPAGES += misc-utils/logger.1
dist_noinst_DATA += misc-utils/logger.1.adoc
logger_SOURCES = misc-utils/logger.c lib/strutils.c lib/strv.c
-logger_LDADD = $(LDADD)
+logger_LDADD = $(LDADD) libcommon.la
logger_CFLAGS = $(AM_CFLAGS)
if HAVE_SYSTEMD
logger_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS) $(SYSTEMD_JOURNAL_LIBS)
#include "xalloc.h"
#include "strv.h"
#include "list.h"
+#include "pwdutils.h"
#define SYSLOG_NAMES
#include <syslog.h>
}
#endif
-static char const *xgetlogin(void)
-{
- char const *cp;
- struct passwd *pw;
-
- if (!(cp = getlogin()) || !*cp)
- cp = (pw = getpwuid(geteuid()))? pw->pw_name : "<someone>";
- return cp;
-}
-
/* this creates a timestamp based on current time according to the
* fine rules of RFC3164, most importantly it ensures in a portable
* way that the month day is correctly written (with a SP instead
syslog_local_header;
if (!ctl->tag)
ctl->tag = xgetlogin();
+ if (!ctl->tag)
+ ctl->tag = "<someone>";
generate_syslog_header(ctl);
}