summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
commit64f057143b18b4110b24c745b8aefcc8da518d76 (patch)
treedc98efa4cf55258bc53bec373b43fb6a2721d1f2 /libc
parent399d39681121c06e014dc7527c0932259fa55d13 (diff)
downloadpw-darwin-64f057143b18b4110b24c745b8aefcc8da518d76.tar.gz
pw-darwin-64f057143b18b4110b24c745b8aefcc8da518d76.tar.zst
pw-darwin-64f057143b18b4110b24c745b8aefcc8da518d76.zip
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be looked up using flat files, NIS, or Hesiod. = Hesiod has been added to libc (see hesiod(3)). = A library routine for parsing nsswitch.conf and invoking callback functions as specified has been added to libc (see nsdispatch(3)). = The following C library functions have been modified to use nsdispatch: . getgrent, getgrnam, getgrgid . getpwent, getpwnam, getpwuid . getusershell . getaddrinfo . gethostbyname, gethostbyname2, gethostbyaddr . getnetbyname, getnetbyaddr . getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr = host.conf has been removed from src/etc. rc.network has been modified to warn that host.conf is no longer used at boot time. In addition, if there is a host.conf but no nsswitch.conf, the latter is created at boot time from the former. Obtained from: NetBSD
Diffstat (limited to 'libc')
-rw-r--r--libc/gen/pw_scan.c56
-rw-r--r--libc/gen/pw_scan.h5
2 files changed, 34 insertions, 27 deletions
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));