3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * NIS interface routines for chpass
34 * Written by Bill Paul <wpaul@ctr.columbia.edu>
35 * Center for Telecommunications Research
36 * Columbia University, New York City
38 * $FreeBSD: src/usr.bin/chpass/pw_yp.h,v 1.7.2.1 2002/02/15 00:46:56 des Exp $
39 * $DragonFly: src/usr.bin/chpass/pw_yp.h,v 1.2 2003/06/17 06:29:25 dillon Exp $
43 #include <sys/types.h>
46 #include <rpc/auth_unix.h>
47 /* Four possible return codes from use_yp() */
48 #define USER_UNKNOWN 0
49 #define USER_YP_ONLY 1
50 #define USER_LOCAL_ONLY 2
51 #define USER_YP_AND_LOCAL 3
55 extern int suser_override
;
56 extern struct passwd local_password
;
57 extern struct passwd yp_password
;
58 extern void copy_yp_pass(char *, int, int);
59 extern char *yp_domain
;
60 extern char *yp_server
;
61 extern void yp_submit(struct passwd
*);
62 extern int use_yp(char *, uid_t
, int);
63 extern char *get_yp_master(int);
64 extern int yp_in_pw_file
;
70 _use_yp = use_yp(NULL, X, 1); \
72 if (_use_yp == USER_UNKNOWN) { \
73 errx(1, "unknown user: uid %u", X); \
76 if (_use_yp == USER_YP_ONLY) { \
79 pw = (struct passwd *)&yp_password; \
81 errx(1, "unknown local user: uid %u", X); \
82 } else if (_use_yp == USER_LOCAL_ONLY) { \
85 pw = (struct passwd *)&local_password; \
87 errx(1, "unknown NIS user: uid %u", X); \
88 } else if (_use_yp == USER_YP_AND_LOCAL) { \
89 if (!force_local && (force_yp || yp_in_pw_file)) { \
91 pw = (struct passwd *)&yp_password; \
94 pw = (struct passwd *)&local_password; \
99 _use_yp = use_yp(X, 0, 0); \
101 if (_use_yp == USER_UNKNOWN) { \
102 errx(1, "unknown user: %s", X); \
105 if (_use_yp == USER_YP_ONLY) { \
106 if (!force_local) { \
108 pw = (struct passwd *)&yp_password; \
110 errx(1, "unknown local user: %s.", X); \
111 } else if (_use_yp == USER_LOCAL_ONLY) { \
114 pw = (struct passwd *)&local_password; \
116 errx(1, "unknown NIS user: %s.", X); \
117 } else if (_use_yp == USER_YP_AND_LOCAL) { \
118 if (!force_local && (force_yp || yp_in_pw_file)) { \
120 pw = (struct passwd *)&yp_password; \
123 pw = (struct passwd *)&local_password; \