mirror of git://git.suckless.org/sbase
Some stylistic changes to su(1)
Also set errno to zero before calling getspnam().
This commit is contained in:
parent
f7fdd58972
commit
56ce9e8bff
7
su.c
7
su.c
|
@ -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:");
|
||||
|
|
Loading…
Reference in New Issue