Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/passwd Fix yppasswd part of passwd. This has never w...



details:   https://anonhg.NetBSD.org/src/rev/498d040b4af4
branches:  trunk
changeset: 479835:498d040b4af4
user:      mjl <mjl%NetBSD.org@localhost>
date:      Thu Dec 23 01:02:52 1999 +0000

description:
Fix yppasswd part of passwd. This has never worked since the
password map was split and master.passwd.byname was introduced.

XXX This is a temporary fix until luke finds some time to add
the necessary support glue to libc for TRT.

diffstat:

 usr.bin/passwd/Makefile    |  11 ++---
 usr.bin/passwd/yp_passwd.c |  81 ++++++---------------------------------------
 2 files changed, 16 insertions(+), 76 deletions(-)

diffs (165 lines):

diff -r 16888506874e -r 498d040b4af4 usr.bin/passwd/Makefile
--- a/usr.bin/passwd/Makefile   Thu Dec 23 00:15:12 1999 +0000
+++ b/usr.bin/passwd/Makefile   Thu Dec 23 01:02:52 1999 +0000
@@ -1,15 +1,14 @@
-#      $NetBSD: Makefile,v 1.22 1999/07/20 09:35:21 mrg Exp $
+#      $NetBSD: Makefile,v 1.23 1999/12/23 01:02:52 mjl Exp $
 #      from: @(#)Makefile    8.3 (Berkeley) 4/2/94
 
 SRCTOP=        ../..
 .include <bsd.crypto.mk>
 
 PROG=  passwd
-SRCS=  local_passwd.c yp_passwd.c passwd.c getpwent.c
-.PATH:  ${.CURDIR}/../../lib/libc/gen
+SRCS=  local_passwd.c yp_passwd.c passwd.c
 DPADD+= ${LIBRPCSVC} ${LIBCRYPT} ${LIBUTIL}
 LDADD+= -lrpcsvc -lcrypt -lutil
-CPPFLAGS+=-I${.CURDIR} -I${.CURDIR}/../../lib/libc/include -DYP
+CPPFLAGS+=-I${.CURDIR} -DYP
 
 LINKS= ${BINDIR}/passwd ${BINDIR}/yppasswd
 MLINKS=        passwd.1 yppasswd.1
@@ -26,5 +25,5 @@
 
 .include <bsd.prog.mk>
 
-getpwent.o: getpwent.c
-       ${COMPILE.c} -UYP ${.IMPSRC}
+# getpwent.o: getpwent.c
+#      ${COMPILE.c} -UYP ${.IMPSRC}
diff -r 16888506874e -r 498d040b4af4 usr.bin/passwd/yp_passwd.c
--- a/usr.bin/passwd/yp_passwd.c        Thu Dec 23 00:15:12 1999 +0000
+++ b/usr.bin/passwd/yp_passwd.c        Thu Dec 23 01:02:52 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: yp_passwd.c,v 1.20 1999/08/16 03:02:46 simonb Exp $    */
+/*     $NetBSD: yp_passwd.c,v 1.21 1999/12/23 01:02:52 mjl Exp $       */
 
 /*
  * Copyright (c) 1988, 1990, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "from:  @(#)local_passwd.c    8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: yp_passwd.c,v 1.20 1999/08/16 03:02:46 simonb Exp $");
+__RCSID("$NetBSD: yp_passwd.c,v 1.21 1999/12/23 01:02:52 mjl Exp $");
 #endif
 #endif /* not lint */
 
@@ -74,8 +74,7 @@
 extern int yflag, yppwd;
 
 static char            *getnewpasswd __P((struct passwd *, char **));
-static struct passwd   *interpret __P((struct passwd *, char *));
-static struct passwd   *ypgetpwnam __P((char *));
+static int              ypgetpwnam __P((char *));
 static void             pw_error __P((char *, int, int));
 static void             test_local __P((char *));
 
@@ -119,7 +118,7 @@
        struct passwd *pw;
        struct timeval tv;
        CLIENT *client;
-       
+
        uid = getuid();
 
        /*
@@ -155,8 +154,10 @@
        if (rpcport >= IPPORT_RESERVED)
                errx(1, "yppasswd daemon is on an invalid port.");
 
-       /* Get user's login identity */
-       if (!(pw = ypgetpwnam(username))) {
+       /* Bail out if this is a local (non-yp) user, */
+       /* then get user's login identity */
+       if (!ypgetpwnam(username) ||
+           !(pw = getpwnam(username))) {
                test_local(username);
                errx(1, "unknown user %s", username);
        }
@@ -260,66 +261,10 @@
        return(strdup(crypt(buf, salt)));
 }
 
-static char *pwskip __P((char *));
-
-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);
-}
-
-static struct passwd *
+static int
 ypgetpwnam(nam)
        char *nam;
 {
-       static struct passwd pwent;
-       static char line[1024];
        char *val;
        int reason, vallen;
        
@@ -329,14 +274,10 @@
        if (reason != 0) {
                if (val != NULL)
                        free(val);
-               return (NULL);
+               return 0;
        }
-       val[vallen] = '\0';
-       (void)strncpy(line, val, sizeof(line) - 1);
-       line[sizeof(line) - 1] = '\0';
        free(val);
-
-       return (interpret(&pwent, line));
+       return 1;
 }
 
 #endif /* YP */



Home | Main Index | Thread Index | Old Index