summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chpass/Makefile5
-rw-r--r--chpass/chpass.c2
-rw-r--r--chpass/edit.c2
-rw-r--r--libc/gen/pw_scan.c56
-rw-r--r--libc/gen/pw_scan.h5
5 files changed, 39 insertions, 31 deletions
diff --git a/chpass/Makefile b/chpass/Makefile
index 7966608..8b2db0b 100644
--- a/chpass/Makefile
+++ b/chpass/Makefile
@@ -10,8 +10,9 @@ GENSRCS=yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c yppasswd_private.h \
BINMODE=4555
.PATH: ${.CURDIR}/../../usr.sbin/pwd_mkdb ${.CURDIR}/../../usr.sbin/vipw \
${.CURDIR}/../../libexec/ypxfr \
- ${.CURDIR}/../../usr.sbin/rpc.yppasswdd
-CFLAGS+=-I${.CURDIR}/../../usr.sbin/pwd_mkdb -I${.CURDIR}/../../usr.sbin/vipw
+ ${.CURDIR}/../../usr.sbin/rpc.yppasswdd \
+ ${.CURDIR}/../../lib/libc/gen
+CFLAGS+=-I${.CURDIR}/../../usr.sbin/pwd_mkdb -I${.CURDIR}/../../usr.sbin/vipw -I${.CURDIR}/../../lib/libc/gen
LINKS= ${BINDIR}/chpass ${BINDIR}/chfn
LINKS+= ${BINDIR}/chpass ${BINDIR}/chsh
LINKS+= ${BINDIR}/chpass ${BINDIR}/ypchpass
diff --git a/chpass/chpass.c b/chpass/chpass.c
index 77f9f78..69e700f 100644
--- a/chpass/chpass.c
+++ b/chpass/chpass.c
@@ -204,7 +204,7 @@ main(argc, argv)
if (uid)
baduser();
pw = &lpw;
- if (!pw_scan(arg, pw))
+ if (!__pw_scan(arg, pw, _PWSCAN_WARN|_PWSCAN_MASTER))
exit(1);
}
username = pw->pw_name;
diff --git a/chpass/edit.c b/chpass/edit.c
index 6311d57..a5d3d5d 100644
--- a/chpass/edit.c
+++ b/chpass/edit.c
@@ -264,5 +264,5 @@ bad: (void)fclose(fp);
return (0);
}
free(p);
- return (pw_scan(buf, pw));
+ return (__pw_scan(buf, pw, _PWSCAN_WARN|_PWSCAN_MASTER));
}
diff --git a/libc/gen/pw_scan.c b/libc/gen/pw_scan.c
index d0fb5f1..3ecb9e0 100644
--- a/libc/gen/pw_scan.c
+++ b/libc/gen/pw_scan.c
@@ -66,12 +66,10 @@ static const char rcsid[] =
* it will be set based on the existance of PW_SCAN_BIG_IDS in the
* environment.
*/
-int pw_big_ids_warning = -1;
+static int pw_big_ids_warning = -1;
int
-pw_scan(bp, pw)
- char *bp;
- struct passwd *pw;
+__pw_scan(char *bp, struct passwd *pw, int flags)
{
uid_t id;
int root;
@@ -97,20 +95,23 @@ pw_scan(bp, pw)
pw->pw_fields |= _PWF_UID;
else {
if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
- warnx("no uid for user %s", pw->pw_name);
+ if (flags & _PWSCAN_WARN)
+ warnx("no uid for user %s", pw->pw_name);
return (0);
}
}
id = strtoul(p, (char **)NULL, 10);
if (errno == ERANGE) {
- warnx("%s > max uid value (%u)", p, ULONG_MAX);
+ if (flags & _PWSCAN_WARN)
+ warnx("%s > max uid value (%u)", p, ULONG_MAX);
return (0);
}
if (root && id) {
- warnx("root uid should be 0");
+ if (flags & _PWSCAN_WARN)
+ warnx("root uid should be 0");
return (0);
}
- if (pw_big_ids_warning && id > USHRT_MAX) {
+ if (flags & _PWSCAN_WARN && pw_big_ids_warning && id > USHRT_MAX) {
warnx("%s > recommended max uid value (%u)", p, USHRT_MAX);
/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
}
@@ -121,28 +122,30 @@ pw_scan(bp, pw)
if(p[0]) pw->pw_fields |= _PWF_GID;
id = strtoul(p, (char **)NULL, 10);
if (errno == ERANGE) {
- warnx("%s > max gid value (%u)", p, ULONG_MAX);
+ if (flags & _PWSCAN_WARN)
+ warnx("%s > max gid value (%u)", p, ULONG_MAX);
return (0);
}
- if (pw_big_ids_warning && id > USHRT_MAX) {
+ if (flags & _PWSCAN_WARN && pw_big_ids_warning && id > USHRT_MAX) {
warnx("%s > recommended max gid value (%u)", p, USHRT_MAX);
/* return (0); This should not be fatal! */
}
pw->pw_gid = id;
- pw->pw_class = strsep(&bp, ":"); /* class */
- if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;
-
- if (!(p = strsep(&bp, ":"))) /* change */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_CHANGE;
- pw->pw_change = atol(p);
-
- if (!(p = strsep(&bp, ":"))) /* expire */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_EXPIRE;
- pw->pw_expire = atol(p);
-
+ if (flags & _PWSCAN_MASTER ) {
+ pw->pw_class = strsep(&bp, ":"); /* class */
+ if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;
+
+ if (!(p = strsep(&bp, ":"))) /* change */
+ goto fmt;
+ if(p[0]) pw->pw_fields |= _PWF_CHANGE;
+ pw->pw_change = atol(p);
+
+ if (!(p = strsep(&bp, ":"))) /* expire */
+ goto fmt;
+ if(p[0]) pw->pw_fields |= _PWF_EXPIRE;
+ pw->pw_expire = atol(p);
+ }
if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */
goto fmt;
if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS;
@@ -158,7 +161,8 @@ pw_scan(bp, pw)
if (root && *p) /* empty == /bin/sh */
for (setusershell();;) {
if (!(sh = getusershell())) {
- warnx("warning, unknown root shell");
+ if (flags & _PWSCAN_WARN)
+ warnx("warning, unknown root shell");
break;
}
if (!strcmp(p, sh))
@@ -167,7 +171,9 @@ pw_scan(bp, pw)
if(p[0]) pw->pw_fields |= _PWF_SHELL;
if ((p = strsep(&bp, ":"))) { /* too many */
-fmt: warnx("corrupted entry");
+fmt:
+ if (flags & _PWSCAN_WARN)
+ warnx("corrupted entry");
return (0);
}
return (1);
diff --git a/libc/gen/pw_scan.h b/libc/gen/pw_scan.h
index 2519bd4..3bc6201 100644
--- a/libc/gen/pw_scan.h
+++ b/libc/gen/pw_scan.h
@@ -35,6 +35,7 @@
* $FreeBSD$
*/
-extern int pw_big_ids_warning;
+#define _PWSCAN_MASTER 0x01
+#define _PWSCAN_WARN 0x02
-extern int pw_scan __P((char *, struct passwd *));
+extern int __pw_scan __P((char *, struct passwd *, int));