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>
#include "fileutils.h"
#include "closestream.h"
#include "timeutils.h"
+#include "pwdutils.h"
#define TERM_WIDTH 79
#define WRITE_TIME_OUT 300 /* in seconds */
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 = "<someone>";
warn(_("cannot get passwd uid"));
}
where = ttyname(STDOUT_FILENO);