mtree -c: Fix username logic when getlogin(3) fails.

Obtained from:	NetBSD (Credit to Sascha Wildner with DragonFlyBSD)
MFC after:	2 weeks
This commit is contained in:
Bryan Drewery 2019-09-12 18:51:59 +00:00
parent 4f4b548b1d
commit 09c9ed3b05
1 changed files with 1 additions and 1 deletions

View File

@ -117,7 +117,7 @@ cwalk(FILE *fp)
host[sizeof(host) - 1] = '\0';
if ((user = getlogin()) == NULL) {
struct passwd *pw;
user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
"<unknown>";
}