ubase

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

commit 6af24e35f954e21bdafd3d0e0f7fb76e92ac93bd
parent e4677f290b9fbc6feceda0fbe406d19a8881faae
Author: sin <sin@2f30.org>
Date:   Mon, 18 Aug 2014 21:49:22 +0100

Only check errno if getpwnam() fails

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

diff --git a/login.c b/login.c @@ -74,13 +74,15 @@ main(int argc, char *argv[]) if (isatty(STDIN_FILENO) == 0) eprintf("stdin is not a tty\n"); - errno = 0; user = argv[0]; + errno = 0; pw = getpwnam(user); - if (errno) - eprintf("getpwnam: %s:", user); - else if (!pw) - eprintf("who are you?\n"); + if (!pw) { + if (errno) + eprintf("getpwnam: %s:", user); + else + eprintf("who are you?\n"); + } uid = pw->pw_uid; gid = pw->pw_gid;