diff options
author | nectar <nectar@FreeBSD.org> | 2000-09-06 18:16:48 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2000-09-06 18:16:48 +0000 |
commit | 748554442d0ac4467fdac2ce9d42006588fd4481 (patch) | |
tree | aed2ddbcac97f46f60ee9c2063a3345553f6a1ee /lib/libc/gen/pw_scan.c | |
parent | 59ffb36b778f8e629622726f6bd32dfa4fda7e35 (diff) | |
download | FreeBSD-src-748554442d0ac4467fdac2ce9d42006588fd4481.zip FreeBSD-src-748554442d0ac4467fdac2ce9d42006588fd4481.tar.gz |
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 'lib/libc/gen/pw_scan.c')
-rw-r--r-- | lib/libc/gen/pw_scan.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c index d0fb5f1..3ecb9e0 100644 --- a/lib/libc/gen/pw_scan.c +++ b/lib/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); |