[hackers] [quark] Refine error messages || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Sun, 4 Feb 2018 21:41:02 +0100 (CET)

commit 33d3d85f4f54f7c6e7aadec4f8f1b0f7b89b01d8
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Sun Feb 4 21:40:51 2018 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Sun Feb 4 21:40:51 2018 +0100

    Refine error messages
    
    I forgot that they can fail with errno = 0, which indicates that the
    given entry was not found.

diff --git a/main.c b/main.c
index 5dc9034..28b78c9 100644
--- a/main.c
+++ b/main.c
_AT_@ -198,11 +198,13 @@ main(int argc, char *argv[])
         /* validate user and group */
         errno = 0;
         if (user && !(pwd = getpwnam(user))) {
- die("getpwnam '%s':", user);
+ die("getpwnam '%s': %s", user, errno ? strerror(errno) :
+ "Entry not found");
         }
         errno = 0;
         if (group && !(grp = getgrnam(group))) {
- die("getgrnam '%s':", group);
+ die("getgrnam '%s': %s", group, errno ? strerror(errno) :
+ "Entry not found");
         }
 
         handlesignals(sigcleanup);
_AT_@ -243,10 +245,10 @@ main(int argc, char *argv[])
                         die("setuid:");
                 }
                 if (getuid() == 0) {
- die("won't run as root user", argv0);
+ die("Won't run as root user", argv0);
                 }
                 if (getgid() == 0) {
- die("won't run as root group", argv0);
+ die("Won't run as root group", argv0);
                 }
 
                 serve(insock);
Received on Sun Feb 04 2018 - 21:41:02 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 04 2018 - 21:48:24 CET