xref: /onnv-gate/usr/src/head/pwd.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef _PWD_H
32*0Sstevel@tonic-gate #define	_PWD_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.3.1.9 */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/feature_tests.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #include <sys/types.h>
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
41*0Sstevel@tonic-gate #include <stdio.h>
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #ifdef	__cplusplus
45*0Sstevel@tonic-gate extern "C" {
46*0Sstevel@tonic-gate #endif
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate struct passwd {
49*0Sstevel@tonic-gate 	char	*pw_name;
50*0Sstevel@tonic-gate 	char	*pw_passwd;
51*0Sstevel@tonic-gate 	uid_t	pw_uid;
52*0Sstevel@tonic-gate 	gid_t	pw_gid;
53*0Sstevel@tonic-gate 	char	*pw_age;
54*0Sstevel@tonic-gate 	char	*pw_comment;
55*0Sstevel@tonic-gate 	char	*pw_gecos;
56*0Sstevel@tonic-gate 	char	*pw_dir;
57*0Sstevel@tonic-gate 	char	*pw_shell;
58*0Sstevel@tonic-gate };
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
61*0Sstevel@tonic-gate struct comment {
62*0Sstevel@tonic-gate 	char	*c_dept;
63*0Sstevel@tonic-gate 	char	*c_name;
64*0Sstevel@tonic-gate 	char	*c_acct;
65*0Sstevel@tonic-gate 	char	*c_bin;
66*0Sstevel@tonic-gate };
67*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate #if defined(__STDC__)
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate extern struct passwd *getpwuid(uid_t);		/* MT-unsafe */
72*0Sstevel@tonic-gate extern struct passwd *getpwnam(const char *);	/* MT-unsafe */
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
75*0Sstevel@tonic-gate extern struct passwd *getpwent_r(struct passwd *, char *, int);
76*0Sstevel@tonic-gate extern struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
77*0Sstevel@tonic-gate extern struct passwd *fgetpwent(FILE *);	/* MT-unsafe */
78*0Sstevel@tonic-gate extern int putpwent(const struct passwd *, FILE *);
79*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
82*0Sstevel@tonic-gate 	defined(__EXTENSIONS__)
83*0Sstevel@tonic-gate extern void endpwent(void);
84*0Sstevel@tonic-gate extern struct passwd *getpwent(void);		/* MT-unsafe */
85*0Sstevel@tonic-gate extern void setpwent(void);
86*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate #else  /* (__STDC__) */
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate extern struct passwd *getpwuid();		/* MT-unsafe */
91*0Sstevel@tonic-gate extern struct passwd *getpwnam();		/* MT-unsafe */
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
94*0Sstevel@tonic-gate extern struct passwd *getpwent_r();
95*0Sstevel@tonic-gate extern struct passwd *fgetpwent_r();
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate extern struct passwd *fgetpwent();		/* MT-unsafe */
98*0Sstevel@tonic-gate extern int putpwent();
99*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
102*0Sstevel@tonic-gate 	defined(__EXTENSIONS__)
103*0Sstevel@tonic-gate extern void endpwent();
104*0Sstevel@tonic-gate extern struct passwd *getpwent();		/* MT-unsafe */
105*0Sstevel@tonic-gate extern void setpwent();
106*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate #endif /* (__STDC__) */
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate /*
111*0Sstevel@tonic-gate  * getpwuid_r() & getpwnam_r() prototypes are defined here.
112*0Sstevel@tonic-gate  */
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate /*
115*0Sstevel@tonic-gate  * Previous releases of Solaris, starting at 2.3, provided definitions of
116*0Sstevel@tonic-gate  * various functions as specified in POSIX.1c, Draft 6.  For some of these
117*0Sstevel@tonic-gate  * functions, the final POSIX 1003.1c standard had a different number of
118*0Sstevel@tonic-gate  * arguments and return values.
119*0Sstevel@tonic-gate  *
120*0Sstevel@tonic-gate  * The following segment of this header provides support for the standard
121*0Sstevel@tonic-gate  * interfaces while supporting applications written under earlier
122*0Sstevel@tonic-gate  * releases.  The application defines appropriate values of the feature
123*0Sstevel@tonic-gate  * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
124*0Sstevel@tonic-gate  * whether it was written to expect the Draft 6 or standard versions of
125*0Sstevel@tonic-gate  * these interfaces, before including this header.  This header then
126*0Sstevel@tonic-gate  * provides a mapping from the source version of the interface to an
127*0Sstevel@tonic-gate  * appropriate binary interface.  Such mappings permit an application
128*0Sstevel@tonic-gate  * to be built from libraries and objects which have mixed expectations
129*0Sstevel@tonic-gate  * of the definitions of these functions.
130*0Sstevel@tonic-gate  *
131*0Sstevel@tonic-gate  * For applications using the Draft 6 definitions, the binary symbol is the
132*0Sstevel@tonic-gate  * same as the source symbol, and no explicit mapping is needed.  For the
133*0Sstevel@tonic-gate  * standard interface, the function func() is mapped to the binary symbol
134*0Sstevel@tonic-gate  * _posix_func().  The preferred mechanism for the remapping is a compiler
135*0Sstevel@tonic-gate  * #pragma.  If the compiler does not provide such a #pragma, the header file
136*0Sstevel@tonic-gate  * defines a static function func() which calls the _posix_func() version;
137*0Sstevel@tonic-gate  * this has to be done instead of #define since POSIX specifies that an
138*0Sstevel@tonic-gate  * application can #undef the symbol and still be bound to the correct
139*0Sstevel@tonic-gate  * implementation.  Unfortunately, the statics confuse lint so we fallback to
140*0Sstevel@tonic-gate  * #define in that case.
141*0Sstevel@tonic-gate  *
142*0Sstevel@tonic-gate  * NOTE: Support for the Draft 6 definitions is provided for compatibility
143*0Sstevel@tonic-gate  * only.  New applications/libraries should use the standard definitions.
144*0Sstevel@tonic-gate  */
145*0Sstevel@tonic-gate 
146*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
147*0Sstevel@tonic-gate 	defined(_POSIX_PTHREAD_SEMANTICS) || defined(__EXTENSIONS__)
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate #if defined(__STDC__)
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
152*0Sstevel@tonic-gate 
153*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
154*0Sstevel@tonic-gate #pragma redefine_extname getpwuid_r __posix_getpwuid_r
155*0Sstevel@tonic-gate #pragma redefine_extname getpwnam_r __posix_getpwnam_r
156*0Sstevel@tonic-gate extern int getpwuid_r(uid_t, struct passwd *, char *, int, struct passwd **);
157*0Sstevel@tonic-gate extern int getpwnam_r(const char *, struct passwd *, char *,
158*0Sstevel@tonic-gate 							int, struct passwd **);
159*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate extern int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
162*0Sstevel@tonic-gate     struct passwd **);
163*0Sstevel@tonic-gate extern int __posix_getpwnam_r(const char *, struct passwd *, char *,
164*0Sstevel@tonic-gate     size_t, struct passwd **);
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate #ifdef __lint
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate #define	getpwuid_r __posix_getpwuid_r
169*0Sstevel@tonic-gate #define	getpwnam_r __posix_getpwnam_r
170*0Sstevel@tonic-gate 
171*0Sstevel@tonic-gate #else	/* !__lint */
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate static int
getpwuid_r(uid_t __uid,struct passwd * __pwd,char * __buf,int __len,struct passwd ** __res)174*0Sstevel@tonic-gate getpwuid_r(uid_t __uid, struct passwd *__pwd, char *__buf, int __len,
175*0Sstevel@tonic-gate     struct passwd **__res)
176*0Sstevel@tonic-gate {
177*0Sstevel@tonic-gate 	return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res));
178*0Sstevel@tonic-gate }
179*0Sstevel@tonic-gate static int
getpwnam_r(const char * __cb,struct passwd * __pwd,char * __buf,int __len,struct passwd ** __res)180*0Sstevel@tonic-gate getpwnam_r(const char *__cb, struct passwd *__pwd, char *__buf, int __len,
181*0Sstevel@tonic-gate     struct passwd **__res)
182*0Sstevel@tonic-gate {
183*0Sstevel@tonic-gate 	return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res));
184*0Sstevel@tonic-gate }
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate #endif /* !__lint */
187*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate extern struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
192*0Sstevel@tonic-gate extern struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate #endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
195*0Sstevel@tonic-gate 
196*0Sstevel@tonic-gate #else  /* __STDC__ */
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
199*0Sstevel@tonic-gate 
200*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
201*0Sstevel@tonic-gate #pragma redefine_extname getpwuid_r __posix_getpwuid_r
202*0Sstevel@tonic-gate #pragma redefine_extname getpwnam_r __posix_getpwnam_r
203*0Sstevel@tonic-gate extern int getpwuid_r();
204*0Sstevel@tonic-gate extern int getpwnam_r();
205*0Sstevel@tonic-gate #else  /* __PRAGMA_REDEFINE_EXTNAME */
206*0Sstevel@tonic-gate 
207*0Sstevel@tonic-gate extern int __posix_getpwuid_r();
208*0Sstevel@tonic-gate extern int __posix_getpwnam_r();
209*0Sstevel@tonic-gate 
210*0Sstevel@tonic-gate #ifdef	__lint
211*0Sstevel@tonic-gate 
212*0Sstevel@tonic-gate #define	getpwuid_r __posix_getpwuid_r
213*0Sstevel@tonic-gate #define	getpwnam_r __posix_getpwnam_r
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate #else	/* !__lint */
216*0Sstevel@tonic-gate 
217*0Sstevel@tonic-gate static int
getpwuid_r(__uid,__pwd,__buf,__len,__res)218*0Sstevel@tonic-gate getpwuid_r(__uid, __pwd, __buf, __len, __res)
219*0Sstevel@tonic-gate 	uid_t __uid;
220*0Sstevel@tonic-gate 	struct passwd *__pwd;
221*0Sstevel@tonic-gate 	char *__buf;
222*0Sstevel@tonic-gate 	int __len;
223*0Sstevel@tonic-gate 	struct passwd **__res;
224*0Sstevel@tonic-gate {
225*0Sstevel@tonic-gate 	return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res));
226*0Sstevel@tonic-gate }
227*0Sstevel@tonic-gate static int
getpwnam_r(__cb,__pwd,__buf,__len,__res)228*0Sstevel@tonic-gate getpwnam_r(__cb, __pwd, __buf, __len, __res)
229*0Sstevel@tonic-gate 	char *__cb;
230*0Sstevel@tonic-gate 	struct passwd *__pwd;
231*0Sstevel@tonic-gate 	char *__buf;
232*0Sstevel@tonic-gate 	int __len;
233*0Sstevel@tonic-gate 	struct passwd **__res;
234*0Sstevel@tonic-gate {
235*0Sstevel@tonic-gate 	return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res));
236*0Sstevel@tonic-gate }
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate #endif /* !__lint */
239*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
242*0Sstevel@tonic-gate 
243*0Sstevel@tonic-gate extern struct passwd *getpwuid_r();
244*0Sstevel@tonic-gate extern struct passwd *getpwnam_r();
245*0Sstevel@tonic-gate 
246*0Sstevel@tonic-gate #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
247*0Sstevel@tonic-gate 
248*0Sstevel@tonic-gate #endif /* __STDC__ */
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L)... */
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate #ifdef	__cplusplus
253*0Sstevel@tonic-gate }
254*0Sstevel@tonic-gate #endif
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate #endif /* _PWD_H */
257