logger: use xgetlogin from pwdutils.
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
019b97024f
, 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>
This commit is contained in:
parent
5cc21d91fc
commit
8ab700b933
|
@ -28,7 +28,7 @@ usrbin_exec_PROGRAMS += logger
|
|||
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)
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "xalloc.h"
|
||||
#include "strv.h"
|
||||
#include "list.h"
|
||||
#include "pwdutils.h"
|
||||
|
||||
#define SYSLOG_NAMES
|
||||
#include <syslog.h>
|
||||
|
@ -393,16 +394,6 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
|
|||
}
|
||||
#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
|
||||
|
@ -927,6 +918,8 @@ static void logger_open(struct logger_ctl *ctl)
|
|||
syslog_local_header;
|
||||
if (!ctl->tag)
|
||||
ctl->tag = xgetlogin();
|
||||
if (!ctl->tag)
|
||||
ctl->tag = "<someone>";
|
||||
|
||||
generate_syslog_header(ctl);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue