[hackers] [ubase] Only check errno if getpwnam() fails || sin
commit 6af24e35f954e21bdafd3d0e0f7fb76e92ac93bd
Author: sin <sin_AT_2f30.org>
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
_AT_@ -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;
Received on Mon Aug 18 2014 - 22:49:55 CEST
This archive was generated by hypermail 2.3.0
: Mon Aug 18 2014 - 23:00:12 CEST