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 "<someone>" when pw look up fails. Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
This commit is contained in:
parent
bca77acb03
commit
5cc21d91fc
|
@ -72,6 +72,7 @@
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
#include "closestream.h"
|
#include "closestream.h"
|
||||||
#include "timeutils.h"
|
#include "timeutils.h"
|
||||||
|
#include "pwdutils.h"
|
||||||
|
|
||||||
#define TERM_WIDTH 79
|
#define TERM_WIDTH 79
|
||||||
#define WRITE_TIME_OUT 300 /* in seconds */
|
#define WRITE_TIME_OUT 300 /* in seconds */
|
||||||
|
@ -352,13 +353,11 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
|
||||||
if (print_banner == TRUE) {
|
if (print_banner == TRUE) {
|
||||||
char *hostname = xgethostname();
|
char *hostname = xgethostname();
|
||||||
char *whom, *where, date[CTIME_BUFSIZ];
|
char *whom, *where, date[CTIME_BUFSIZ];
|
||||||
struct passwd *pw;
|
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
if (!(whom = getlogin()) || !*whom)
|
whom = xgetlogin();
|
||||||
whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
|
|
||||||
if (!whom) {
|
if (!whom) {
|
||||||
whom = "someone";
|
whom = "<someone>";
|
||||||
warn(_("cannot get passwd uid"));
|
warn(_("cannot get passwd uid"));
|
||||||
}
|
}
|
||||||
where = ttyname(STDOUT_FILENO);
|
where = ttyname(STDOUT_FILENO);
|
||||||
|
|
Loading…
Reference in New Issue