From 56ce9e8bffe8eba7f6b1f09309f1a1250bb04da6 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 18 Oct 2013 10:20:13 +0100 Subject: [PATCH] Some stylistic changes to su(1) Also set errno to zero before calling getspnam(). --- su.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/su.c b/su.c index 273728a..5531e63 100644 --- 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:");