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/passwd Apply patch (requested by phil):
details: https://anonhg.NetBSD.org/src/rev/3c280ea9d2e7
branches: netbsd-1-4
changeset: 470958:3c280ea9d2e7
user: he <he%NetBSD.org@localhost>
date: Sun Oct 08 18:45:38 2000 +0000
description:
Apply patch (requested by phil):
Make this program actually able to change the YP password.
diffstat:
usr.bin/passwd/yp_passwd.c | 77 ++++-----------------------------------------
1 files changed, 8 insertions(+), 69 deletions(-)
diffs (124 lines):
diff -r 9a8811dd9bf3 -r 3c280ea9d2e7 usr.bin/passwd/yp_passwd.c
--- a/usr.bin/passwd/yp_passwd.c Sun Oct 08 16:18:44 2000 +0000
+++ b/usr.bin/passwd/yp_passwd.c Sun Oct 08 18:45:38 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: yp_passwd.c,v 1.19 1998/07/26 22:15:38 mycroft Exp $ */
+/* $NetBSD: yp_passwd.c,v 1.19.2.1 2000/10/08 18:45:38 he 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.19 1998/07/26 22:15:38 mycroft Exp $");
+__RCSID("$NetBSD: yp_passwd.c,v 1.19.2.1 2000/10/08 18:45:38 he 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 *));
@@ -156,8 +155,8 @@
errx(1, "yppasswd daemon is on an invalid port.");
/* Get user's login identity */
- if (!(pw = ypgetpwnam(username))) {
- test_local(username);
+ if (!ypgetpwnam(username) ||
+ !(pw = getpwnam(username))) {
errx(1, "unknown user %s", username);
}
@@ -260,66 +259,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 +272,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