ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 56ce9e8bffe8eba7f6b1f09309f1a1250bb04da6
parent f7fdd5897296a7b9389b6c292e278d842a7a1baf
Author: sin <sin@2f30.org>
Date:   Fri, 18 Oct 2013 10:20:13 +0100

Some stylistic changes to su(1)

Also set errno to zero before calling getspnam().

Diffstat:
Msu.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/su.c b/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:");