utmp

simple login manager
git clone git://git.suckless.org/utmp
Log | Files | Refs | README | LICENSE

commit 9631182347109af70cc725aabd6d567c83e989ec
parent 5ac5ede22b55ec5820dbacf1c5e5e9d9c2b2d9ad
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 28 Aug 2014 11:41:54 +0200

Copy test of getpwuid from st

This part of the code is identicall to the code of st, and st does
better tests that utmp was doing, so we take the code of st.

Diffstat:
utmp.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/utmp.c b/utmp.c @@ -46,9 +46,13 @@ main(int argc, char *argv[]) gid = getgid(); setgid(gid); - pw = getpwuid(uid = getuid()); - if (!pw || !pw->pw_name) - die("Process is running with an incorrect uid %d", uid); + errno = 0; + if ((pw = getpwuid(uid = getuid())) == NULL) { + if(errno) + die("getpwuid:%s", strerror(errno)); + else + die("who are you?"); + } setenv("LOGNAME", pw->pw_name, 1); setenv("USER", pw->pw_name, 1);