Source-Changes-HG archive

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

[src/netbsd-1-4]: src/usr.bin/chpass Apply patch (requested by phil):



details:   https://anonhg.NetBSD.org/src/rev/fc98e672d81b
branches:  netbsd-1-4
changeset: 471160:fc98e672d81b
user:      he <he%NetBSD.org@localhost>
date:      Fri Oct 20 15:36:14 2000 +0000

description:
Apply patch (requested by phil):
  Change password database information without turning off the user
  when using secure YP maps.

diffstat:

 usr.bin/chpass/chpass.c |   18 +-----
 usr.bin/chpass/pw_yp.c  |  118 +-----------------------------------------------
 2 files changed, 6 insertions(+), 130 deletions(-)

diffs (190 lines):

diff -r b32c8eceac80 -r fc98e672d81b usr.bin/chpass/chpass.c
--- a/usr.bin/chpass/chpass.c   Thu Oct 19 21:14:18 2000 +0000
+++ b/usr.bin/chpass/chpass.c   Fri Oct 20 15:36:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chpass.c,v 1.18 1999/02/08 22:21:44 mjl Exp $  */
+/*     $NetBSD: chpass.c,v 1.18.2.1 2000/10/20 15:36:14 he Exp $       */
 
 /*-
  * Copyright (c) 1988, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)chpass.c   8.4 (Berkeley) 4/2/94";
 #else 
-__RCSID("$NetBSD: chpass.c,v 1.18 1999/02/08 22:21:44 mjl Exp $");
+__RCSID("$NetBSD: chpass.c,v 1.18.2.1 2000/10/20 15:36:14 he Exp $");
 #endif
 #endif /* not lint */
 
@@ -187,23 +187,13 @@
 
        if (op == EDITENTRY || op == NEWSH) {
                if (username != NULL) {
-#ifdef YP
-                       if (use_yp)
-                               pw = ypgetpwnam(username);
-                       else
-#endif /* YP */
-                               pw = getpwnam(username);
+                       pw = getpwnam(username);
                        if (pw == NULL)
                                errx(1, "unknown user: %s", username);
                        if (uid && uid != pw->pw_uid)
                                baduser();
                } else {
-#ifdef YP
-                       if (use_yp)
-                               pw = ypgetpwuid(uid);
-                       else
-#endif /* YP */
-                               pw = getpwuid(uid);
+                       pw = getpwuid(uid);
                        if (pw == NULL)
                                errx(1, "unknown user: uid %u\n", uid);
                }
diff -r b32c8eceac80 -r fc98e672d81b usr.bin/chpass/pw_yp.c
--- a/usr.bin/chpass/pw_yp.c    Thu Oct 19 21:14:18 2000 +0000
+++ b/usr.bin/chpass/pw_yp.c    Fri Oct 20 15:36:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pw_yp.c,v 1.14.2.1 2000/10/19 14:33:12 he Exp $        */
+/*     $NetBSD: pw_yp.c,v 1.14.2.2 2000/10/20 15:36:14 he Exp $        */
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)pw_yp.c    1.0 2/2/93";
 #else
-__RCSID("$NetBSD: pw_yp.c,v 1.14.2.1 2000/10/19 14:33:12 he Exp $");
+__RCSID("$NetBSD: pw_yp.c,v 1.14.2.2 2000/10/20 15:36:14 he Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,8 +65,6 @@
 
 static char *domain;
 
-static struct passwd *interpret __P((struct passwd *, char *));
-static char *pwskip __P((char *));
 
 /*
  * Check if rpc.yppasswdd is running on the master YP server.
@@ -199,118 +197,6 @@
        return (0);
 }
 
-static char *
-pwskip(p)
-       char *p;
-{
-       while (*p && *p != ':' && *p != '\n')
-               ++p;
-       if (*p)
-               *p++ = 0;
-       return (p);
-}
-
-static struct passwd *
-interpret(pwent, line)
-       struct passwd *pwent;
-       char *line;
-{
-       char    *p = line;
-
-       pwent->pw_passwd = "*";
-       pwent->pw_uid = 0;
-       pwent->pw_gid = 0;
-       pwent->pw_gecos = "";
-       pwent->pw_dir = "";
-       pwent->pw_shell = "";
-       pwent->pw_change = 0;
-       pwent->pw_expire = 0;
-       pwent->pw_class = "";
-       
-       /* line without colon separators is no good, so ignore it */
-       if(!strchr(p,':'))
-               return(NULL);
-
-       pwent->pw_name = p;
-       p = pwskip(p);
-       pwent->pw_passwd = p;
-       p = pwskip(p);
-       pwent->pw_uid = (uid_t)strtoul(p, NULL, 10);
-       p = pwskip(p);
-       pwent->pw_gid = (gid_t)strtoul(p, NULL, 10);
-       p = pwskip(p);
-       pwent->pw_gecos = p;
-       p = pwskip(p);
-       pwent->pw_dir = p;
-       p = pwskip(p);
-       pwent->pw_shell = p;
-       while (*p && *p != '\n')
-               p++;
-       *p = '\0';
-       return (pwent);
-}
-
-struct passwd *
-ypgetpwnam(nam)
-       const char *nam;
-{
-       static struct passwd pwent;
-       static char line[1024];
-       char *val;
-       int reason, vallen;
-       
-       /*
-        * Get local domain
-        */
-       if (!domain && (reason = yp_get_default_domain(&domain)))
-               errx(1, "can't get local YP domain. Reason: %s",
-                   yperr_string(reason));
-
-       val = NULL;
-       reason = yp_match(domain, "passwd.byname", nam, strlen(nam),
-           &val, &vallen);
-       if (reason != 0) {
-               if (val)
-                       free (val);
-               return (NULL);
-       }
-       val[vallen] = '\0';
-       (void)strncpy(line, val, sizeof(line) - 1);
-       free(val);
-
-       return(interpret(&pwent, line));
-}
-
-struct passwd *
-ypgetpwuid(uid)
-       uid_t uid;
-{
-       static struct passwd pwent;
-       static char line[1024];
-       char *val;
-       int reason, vallen;
-       char namebuf[16];
-       
-       if (!domain && (reason = yp_get_default_domain(&domain)))
-               errx(1, "can't get local YP domain. Reason: %s\n",
-                   yperr_string(reason));
-
-       (void)snprintf(namebuf, sizeof namebuf, "%d", uid);
-       val = NULL;
-       reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf),
-           &val, &vallen);
-       if (reason != 0) {
-               if (val)
-                       free (val);
-               return (NULL);
-       }
-       val[vallen] = '\0';
-       (void)strncpy(line, val, sizeof(line) - 1);
-       free(val);
-
-       return(interpret(&pwent, line));
-}
-
 void
 yppw_error(name, err, eval)
        const char *name;



Home | Main Index | Thread Index | Old Index