]> git.ipfire.org Git - people/ms/dma.git/commitdiff
Be explicit about missing user.
authorEd Maste <emaste@freebsd.org>
Tue, 20 Nov 2012 16:29:09 +0000 (11:29 -0500)
committerEd Maste <emaste@freebsd.org>
Tue, 20 Nov 2012 16:29:09 +0000 (11:29 -0500)
Previously the error message for a missing 'mail' user was
dma: cannot drop root privileges: No error: 0

dma.c

diff --git a/dma.c b/dma.c
index bb5fa198f18adc6c039a80097aa9ebcdd35369c5..0a2f93580347e4db52446668aed98c4f79d7a90a 100644 (file)
--- a/dma.c
+++ b/dma.c
@@ -423,9 +423,14 @@ main(int argc, char **argv)
        if (geteuid() == 0 || getuid() == 0) {
                struct passwd *pw;
 
+               errno = 0;
                pw = getpwnam(DMA_ROOT_USER);
-               if (pw == NULL)
-                       err(1, "cannot drop root privileges");
+               if (pw == NULL) {
+                       if (errno == 0)
+                               errx(1, "user '%s' not found", DMA_ROOT_USER);
+                       else
+                               err(1, "cannot drop root privileges");
+               }
 
                if (setuid(pw->pw_uid) != 0)
                        err(1, "cannot drop root privileges");