Refine error messages

I forgot that they can fail with errno = 0, which indicates that the
given entry was not found.
This commit is contained in:
Laslo Hunhold 2018-02-04 21:40:51 +01:00
parent 2c74631df9
commit 33d3d85f4f

10
main.c
View file

@ -198,11 +198,13 @@ main(int argc, char *argv[])
/* validate user and group */ /* validate user and group */
errno = 0; errno = 0;
if (user && !(pwd = getpwnam(user))) { if (user && !(pwd = getpwnam(user))) {
die("getpwnam '%s':", user); die("getpwnam '%s': %s", user, errno ? strerror(errno) :
"Entry not found");
} }
errno = 0; errno = 0;
if (group && !(grp = getgrnam(group))) { if (group && !(grp = getgrnam(group))) {
die("getgrnam '%s':", group); die("getgrnam '%s': %s", group, errno ? strerror(errno) :
"Entry not found");
} }
handlesignals(sigcleanup); handlesignals(sigcleanup);
@ -243,10 +245,10 @@ main(int argc, char *argv[])
die("setuid:"); die("setuid:");
} }
if (getuid() == 0) { if (getuid() == 0) {
die("won't run as root user", argv0); die("Won't run as root user", argv0);
} }
if (getgid() == 0) { if (getgid() == 0) {
die("won't run as root group", argv0); die("Won't run as root group", argv0);
} }
serve(insock); serve(insock);