commit 6af24e35f954e21bdafd3d0e0f7fb76e92ac93bd
Author: sin <[email protected]>
Date: Mon Aug 18 21:49:22 2014 +0100
Only check errno if getpwnam() fails
diff --git a/login.c b/login.c
index 51b1f77..fde7ad3 100644
--- a/login.c
+++ b/login.c
@@ -74,13 +74,15 @@ main(int argc, char *argv[])
if (isatty(STDIN_FILENO) == 0)
eprintf("stdin is not a tty
");
- errno = 0;
user = argv[0];
+ errno = 0;
pw = getpwnam(user);
- if (errno)
- eprintf("getpwnam: %s:", user);
- else if (!pw)
- eprintf("who are you?
");
+ if (!pw) {
+ if (errno)
+ eprintf("getpwnam: %s:", user);
+ else
+ eprintf("who are you?
");
+ }
uid = pw->pw_uid;
gid = pw->pw_gid;