]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Add a flag to allow the 'use NIS or local?' logic to tell when NIS is
authorBill Paul <wpaul@FreeBSD.org>
Wed, 23 Oct 1996 14:43:39 +0000 (14:43 +0000)
committerBill Paul <wpaul@FreeBSD.org>
Wed, 23 Oct 1996 14:43:39 +0000 (14:43 +0000)
enabled in /etc/master.passwd & friends. This allows the 'USER_YP_AND_LOCAL'
case to make a more sensible guess (if NIS is enabled, default to NIS,
otherwise default to local -- this is better than defaulting to NIS
all the time).

chpass/pw_yp.c
chpass/pw_yp.h

index 3cf65d1f60f373ce678001721c7305b356d44fe4..a02327de7a5120c577176245b86016da5a4c0e4d 100644 (file)
@@ -81,6 +81,7 @@ static HASHINFO openinfo = {
 int force_old = 0;
 int _use_yp = 0;
 int suser_override = 0;
+int yp_in_pw_file = 0;
 char *yp_domain = NULL;
 char *yp_server = NULL;
 
@@ -278,8 +279,8 @@ int use_yp (user, uid, which)
        bf[0] = _PW_KEYYPENABLED;
        key.data = (u_char *)bf;
        key.size = 1;
-       if ((!(dbp->get)(dbp,&key,&data,0) && _yp_check(NULL)) ||
-                                               (yp_domain && yp_server)) {
+       yp_in_pw_file = !(dbp->get)(dbp,&key,&data,0);
+       if (_yp_check(NULL) || (yp_domain && yp_server)) {
                server = get_yp_master(0);
 
                /* Is the user in the NIS passwd map */
@@ -324,6 +325,7 @@ int use_yp (user, uid, which)
                return(USER_LOCAL_ONLY);
        else if (!user_exists)
                return(USER_UNKNOWN);
+
        return(-1);
 }
 
index 7d37560661e524e5ee84dc2d6365ee7abb6af6c4..2bda1ec1a3da391a9a46003621ccc72486fdabac 100644 (file)
@@ -35,7 +35,7 @@
  * Center for Telecommunications Research
  * Columbia University, New York City
  *
- *     $Id: pw_yp.h,v 1.8 1996/02/17 18:14:23 wpaul Exp $
+ *     $Id: pw_yp.h,v 1.3 1996/02/23 16:08:59 wpaul Exp $
  */
 
 #ifdef YP
@@ -60,6 +60,7 @@ extern        char            *yp_server;
 extern void            yp_submit       __P(( struct passwd * ));
 extern int             use_yp          __P(( char * , uid_t , int ));
 extern char            *get_yp_master  __P(( int ));
+extern int             yp_in_pw_file;
 
 /*
  * Yucky.
@@ -84,7 +85,7 @@ extern        char            *get_yp_master  __P(( int ));
                } else                                                  \
                        errx(1, "unknown NIS user: uid %u", X);         \
        } else if (_use_yp == USER_YP_AND_LOCAL) {                      \
-               if (!force_local) {                                     \
+               if (!force_local && (force_yp || yp_in_pw_file)) {      \
                        _use_yp = 1;                                    \
                        pw = (struct passwd *)&yp_password;             \
                } else {                                                \
@@ -113,7 +114,7 @@ extern      char            *get_yp_master  __P(( int ));
                } else                                                  \
                        errx(1, "unknown NIS user: %s.", X);            \
        } else if (_use_yp == USER_YP_AND_LOCAL) {                      \
-               if (!force_local) {                                     \
+               if (!force_local && (force_yp || yp_in_pw_file)) {      \
                        _use_yp = 1;                                    \
                        pw = (struct passwd *)&yp_password;             \
                } else {                                                \