]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
authorJacques Vidrine <nectar@FreeBSD.org>
Wed, 6 Sep 2000 18:16:48 +0000 (18:16 +0000)
committerJacques Vidrine <nectar@FreeBSD.org>
Wed, 6 Sep 2000 18:16:48 +0000 (18:16 +0000)
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

chpass/Makefile
chpass/chpass.c
chpass/edit.c
libc/gen/pw_scan.c
libc/gen/pw_scan.h

index 7966608938ceec2d2f96b9916e5bd30df93c879f..8b2db0b19407ea4fc3477f1d7cb3e81ab3eb8b23 100644 (file)
@@ -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
index 77f9f7832f84e1f83072e2b288143dddd874c876..69e700f04e8cba27641fea2573836f545a0bd8e6 100644 (file)
@@ -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;
index 6311d5751508d55d816544b43f2da6b51ee214cb..a5d3d5d8d911ca4b82ae68887a2cd2827986ceb5 100644 (file)
@@ -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));
 }
index d0fb5f17d03516c29cadf9dc8ad09cbfb4379fbd..3ecb9e0ac07a834bca82da7d09abde7c2b929fb7 100644 (file)
@@ -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);
index 2519bd45db019742c8fb40785c7a05612ca99d20..3bc62010a871adafda4da52e9c84f70d224cdba2 100644 (file)
@@ -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));