Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/skeyinfo Tidy up error messages. Prompted by PR 4199...



details:   https://anonhg.NetBSD.org/src/rev/c4eebe4c6b81
branches:  trunk
changeset: 747181:c4eebe4c6b81
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Sep 05 06:13:34 2009 +0000

description:
Tidy up error messages. Prompted by PR 41993 from Bug Hunting, but more
comprehensive.

diffstat:

 usr.bin/skeyinfo/skeyinfo.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (53 lines):

diff -r 028d5f667922 -r c4eebe4c6b81 usr.bin/skeyinfo/skeyinfo.c
--- a/usr.bin/skeyinfo/skeyinfo.c       Sat Sep 05 03:50:49 2009 +0000
+++ b/usr.bin/skeyinfo/skeyinfo.c       Sat Sep 05 06:13:34 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: skeyinfo.c,v 1.5 2008/04/28 20:24:15 martin Exp $      */
+/*     $NetBSD: skeyinfo.c,v 1.6 2009/09/05 06:13:34 dholland Exp $    */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,12 +31,13 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: skeyinfo.c,v 1.5 2008/04/28 20:24:15 martin Exp $");
+__RCSID("$NetBSD: skeyinfo.c,v 1.6 2009/09/05 06:13:34 dholland Exp $");
 #endif
 
 #include <stdio.h>
 #include <pwd.h>
 #include <err.h>
+#include <errno.h>
 #include <skey.h>
 #include <string.h>
 #include <unistd.h>
@@ -57,7 +58,7 @@
        argv++;
 
        if (geteuid())
-               errx(1, "must be root to read /etc/skeykeys");
+               errx(1, "Must be root to read /etc/skeykeys");
 
        uid = getuid();
 
@@ -65,14 +66,16 @@
                pw = getpwuid(uid);
        else if (!uid)
                pw = getpwnam(argv[0]);
-       else
-               errx(1, "permission denied to look other users skeys");
+       else {
+               errno = EPERM;
+               err(1, "%s", argv[0]);
+       }
 
        if (!pw) {
                if (argc)
                        errx(1, "%s: no such user", argv[0]);
                else
-                       errx(1, "who are you?");
+                       errx(1, "Who are you?");
        }
 
        (void) strlcpy(name, pw->pw_name, sizeof(name));



Home | Main Index | Thread Index | Old Index