Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/usr.bin/chpass Revert pullup of 1.18 [releng].
details: https://anonhg.NetBSD.org/src/rev/f491ecfb17db
branches: netbsd-1-5
changeset: 490239:f491ecfb17db
user: tv <tv%NetBSD.org@localhost>
date: Wed Nov 15 18:53:39 2000 +0000
description:
Revert pullup of 1.18 [releng].
This causes other issues that need to be addressed as part of a more complete
change in 1.5.1.
diffstat:
usr.bin/chpass/pw_yp.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 117 insertions(+), 2 deletions(-)
diffs (147 lines):
diff -r 7f1c03ad4d4f -r f491ecfb17db usr.bin/chpass/pw_yp.c
--- a/usr.bin/chpass/pw_yp.c Wed Nov 15 18:41:53 2000 +0000
+++ b/usr.bin/chpass/pw_yp.c Wed Nov 15 18:53:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pw_yp.c,v 1.15.8.2 2000/10/30 22:45:22 tv Exp $ */
+/* $NetBSD: pw_yp.c,v 1.15.8.3 2000/11/15 18:53:39 tv 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.15.8.2 2000/10/30 22:45:22 tv Exp $");
+__RCSID("$NetBSD: pw_yp.c,v 1.15.8.3 2000/11/15 18:53:39 tv Exp $");
#endif
#endif /* not lint */
@@ -65,6 +65,9 @@
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.
* XXX this duplicates some code, but is much less complex
@@ -196,6 +199,118 @@
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