From: Érico Nogueira Date: Wed, 28 Jul 2021 02:51:34 +0000 (-0300) Subject: wall: use xgetlogin. X-Git-Tag: v2.38-rc1~333^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11109352d4a3fb34ecfdb120cca65640bcecf5b2;p=thirdparty%2Futil-linux.git wall: use xgetlogin. getlogin(3) shouldn't be used for identification here. This also removes the bug where a missing entry for getuid() in passwd database wouldn't print a warning, because whom would be set to "???". For consistency, switch to "" when pw look up fails. Signed-off-by: Érico Nogueira --- diff --git a/term-utils/wall.c b/term-utils/wall.c index fb283d3bfd..c601d3e5b7 100644 --- a/term-utils/wall.c +++ b/term-utils/wall.c @@ -72,6 +72,7 @@ #include "fileutils.h" #include "closestream.h" #include "timeutils.h" +#include "pwdutils.h" #define TERM_WIDTH 79 #define WRITE_TIME_OUT 300 /* in seconds */ @@ -352,13 +353,11 @@ static char *makemsg(char *fname, char **mvec, int mvecsz, if (print_banner == TRUE) { char *hostname = xgethostname(); char *whom, *where, date[CTIME_BUFSIZ]; - struct passwd *pw; time_t now; - if (!(whom = getlogin()) || !*whom) - whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???"; + whom = xgetlogin(); if (!whom) { - whom = "someone"; + whom = ""; warn(_("cannot get passwd uid")); } where = ttyname(STDOUT_FILENO);