Some stylistic changes to su(1)

Also set errno to zero before calling getspnam().
This commit is contained in:
sin 2013-10-18 10:20:13 +01:00
parent f7fdd58972
commit 56ce9e8bff

7
su.c
View File

@ -40,9 +40,12 @@ main(int argc, char **argv)
uid = getuid();
errno = 0;
spw = getspnam(usr);
if (!spw)
if (errno)
eprintf("getspnam: %s:", usr);
else if (!spw)
enprintf(EXIT_FAILURE, "who are you?\n");
switch (spw->sp_pwdp[0]) {
case '!':
@ -74,7 +77,7 @@ main(int argc, char **argv)
if (errno)
eprintf("getpwnam: %s", usr);
else if (!pw)
enprintf(EXIT_FAILURE, "getpwnam: %s: no such user\n", usr);
enprintf(EXIT_FAILURE, "who are you?\n");
if (initgroups(usr, pw->pw_gid) < 0)
eprintf("initgroups:");