[hackers] [ubase] Some stylistic changes to su(1) || sin

From: <git_AT_suckless.org>
Date: Fri, 18 Oct 2013 11:26:44 +0200

commit 56ce9e8bffe8eba7f6b1f09309f1a1250bb04da6
Author: sin <sin_AT_2f30.org>
Date: Fri Oct 18 10:20:13 2013 +0100

    Some stylistic changes to su(1)
    
    Also set errno to zero before calling getspnam().

diff --git a/su.c b/su.c
index 273728a..5531e63 100644
--- a/su.c
+++ b/su.c
_AT_@ -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?
");
 
         switch (spw->sp_pwdp[0]) {
         case '!':
_AT_@ -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
", usr);
+ enprintf(EXIT_FAILURE, "who are you?
");
 
         if (initgroups(usr, pw->pw_gid) < 0)
                 eprintf("initgroups:");
Received on Fri Oct 18 2013 - 11:26:44 CEST

This archive was generated by hypermail 2.3.0 : Fri Oct 18 2013 - 11:36:23 CEST