Source-Changes-HG archive

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

[src/netbsd-1-4]: src/usr.sbin/chown Pull up revision 1.25 (via patch, reques...



details:   https://anonhg.NetBSD.org/src/rev/f2af0e41534c
branches:  netbsd-1-4
changeset: 471236:f2af0e41534c
user:      he <he%NetBSD.org@localhost>
date:      Sun Jan 21 17:22:02 2001 +0000

description:
Pull up revision 1.25 (via patch, requested by mike):
  Correct display of invalid username error and cache duplicate
  password lookup.  Fixes PR#11695.

diffstat:

 usr.sbin/chown/chown.c |  34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)

diffs (81 lines):

diff -r 9566060d04c0 -r f2af0e41534c usr.sbin/chown/chown.c
--- a/usr.sbin/chown/chown.c    Sun Jan 21 17:07:58 2001 +0000
+++ b/usr.sbin/chown/chown.c    Sun Jan 21 17:22:02 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chown.c,v 1.19.2.1 2000/05/11 10:28:20 he Exp $        */
+/*     $NetBSD: chown.c,v 1.19.2.2 2001/01/21 17:22:02 he Exp $        */
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)chown.c    8.8 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: chown.c,v 1.19.2.1 2000/05/11 10:28:20 he Exp $");
+__RCSID("$NetBSD: chown.c,v 1.19.2.2 2001/01/21 17:22:02 he Exp $");
 #endif
 #endif /* not lint */
 
@@ -64,7 +64,7 @@
 #include <unistd.h>
 
 static void    a_gid __P((const char *));
-static int     a_uid __P((const char *));
+static void    a_uid __P((const char *));
 static id_t    id __P((const char *, const char *));
        int     main __P((int, char **));
 static void    usage __P((void));
@@ -155,13 +155,13 @@
                } 
 #ifdef SUPPORT_DOT
                else if ((cp = strrchr(*argv, '.')) != NULL) {
-                       if (a_uid(*argv) == -1) {
+                       if (uid_from_user(*argv, &uid) == -1) {
                                *cp++ = '\0';
                                a_gid(cp);
                        }
                }
 #endif
-               (void) a_uid(*argv);
+               a_uid(*argv);
        } else 
                a_gid(*argv);
 
@@ -217,26 +217,24 @@
 
        if (*s == '\0')                 /* Argument was "uid[:.]". */
                return;
-       gid = ((gr = getgrnam(s)) == NULL) ? id(s, "group") : gr->gr_gid;
+       gr = getgrnam(s);
+       if (gr == NULL)
+               gid = id(s, "group");
+       else
+               gid = gr->gr_gid;
+       return;
 }
 
-static int
+static void
 a_uid(s)
        const char *s;
 {
-       struct passwd *pw;
-
        if (*s == '\0')                 /* Argument was "[:.]gid". */
-               return 0;
-       pw = getpwnam(s);
-       if (pw != NULL) {
-               uid = pw->pw_uid;
-               return 0;
+               return;
+       if (uid_from_user(s, &uid) == -1) {
+               uid = id(s, "user");
        }
-       if (isalpha(*s))
-               return -1;
-       uid = id(s, "user");
-       return 0;
+       return;
 }
 
 static id_t



Home | Main Index | Thread Index | Old Index