Only check errno if getpwnam() fails
This commit is contained in:
parent
e4677f290b
commit
6af24e35f9
12
login.c
12
login.c
@ -74,13 +74,15 @@ main(int argc, char *argv[])
|
|||||||
if (isatty(STDIN_FILENO) == 0)
|
if (isatty(STDIN_FILENO) == 0)
|
||||||
eprintf("stdin is not a tty\n");
|
eprintf("stdin is not a tty\n");
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
user = argv[0];
|
user = argv[0];
|
||||||
|
errno = 0;
|
||||||
pw = getpwnam(user);
|
pw = getpwnam(user);
|
||||||
if (errno)
|
if (!pw) {
|
||||||
eprintf("getpwnam: %s:", user);
|
if (errno)
|
||||||
else if (!pw)
|
eprintf("getpwnam: %s:", user);
|
||||||
eprintf("who are you?\n");
|
else
|
||||||
|
eprintf("who are you?\n");
|
||||||
|
}
|
||||||
|
|
||||||
uid = pw->pw_uid;
|
uid = pw->pw_uid;
|
||||||
gid = pw->pw_gid;
|
gid = pw->pw_gid;
|
||||||
|
Loading…
Reference in New Issue
Block a user