Libinfo-406.17.tar.gz
[apple/libinfo.git] / lookup.subproj / pwd.h
1 /*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 * Portions Copyright(C) 1995, Jason Downs. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)pwd.h 8.2 (Berkeley) 1/21/94
40 */
41 /* Portions copyright (c) 2000-2011 Apple Inc. All rights reserved. */
42
43 #ifndef _PWD_H_
44 #define _PWD_H_
45
46 #include <_types.h>
47
48 #ifndef _GID_T
49 typedef __darwin_gid_t gid_t;
50 #define _GID_T
51 #endif
52
53 #ifndef _SIZE_T
54 #define _SIZE_T
55 typedef __darwin_size_t size_t;
56 #endif
57
58 #ifndef _UID_T
59 typedef __darwin_uid_t uid_t;
60 #define _UID_T
61 #endif
62
63 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
64 #define _PATH_PWD "/etc"
65 #define _PATH_PASSWD "/etc/passwd"
66 #define _PASSWD "passwd"
67 #define _PATH_MASTERPASSWD "/etc/master.passwd"
68 #define _PATH_MASTERPASSWD_LOCK "/etc/ptmp"
69 #define _MASTERPASSWD "master.passwd"
70
71 #define _PATH_MP_DB "/etc/pwd.db"
72 #define _MP_DB "pwd.db"
73 #define _PATH_SMP_DB "/etc/spwd.db"
74 #define _SMP_DB "spwd.db"
75
76 #define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb"
77
78 #define _PW_KEYBYNAME '1' /* stored by name */
79 #define _PW_KEYBYNUM '2' /* stored by entry in the "file" */
80 #define _PW_KEYBYUID '3' /* stored by uid */
81
82 #define _PASSWORD_EFMT1 '_' /* extended encryption format */
83
84 #define _PASSWORD_LEN 128 /* max length, not counting NULL */
85
86 #define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */
87 #define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */
88 #define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */
89 #define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */
90
91 #define _PASSWORD_WARNDAYS 14 /* days to warn about expiry */
92 #define _PASSWORD_CHGNOW -1 /* special day to force password
93 * change at next login */
94 #endif
95
96 struct passwd {
97 char *pw_name; /* user name */
98 char *pw_passwd; /* encrypted password */
99 uid_t pw_uid; /* user uid */
100 gid_t pw_gid; /* user gid */
101 __darwin_time_t pw_change; /* password change time */
102 char *pw_class; /* user access class */
103 char *pw_gecos; /* Honeywell login info */
104 char *pw_dir; /* home directory */
105 char *pw_shell; /* default shell */
106 __darwin_time_t pw_expire; /* account expiration */
107 };
108
109 #include <sys/cdefs.h>
110
111 __BEGIN_DECLS
112 struct passwd *getpwuid(uid_t);
113 struct passwd *getpwnam(const char *);
114 int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
115 int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **);
116 struct passwd *getpwent(void);
117 void setpwent(void);
118 void endpwent(void);
119 __END_DECLS
120
121 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
122 #include <uuid/uuid.h>
123 __BEGIN_DECLS
124 int setpassent(int);
125 char *user_from_uid(uid_t, int);
126 struct passwd *getpwuuid(uuid_t);
127 int getpwuuid_r(uuid_t, struct passwd *, char *, size_t, struct passwd **);
128 __END_DECLS
129 #endif
130
131 #endif /* !_PWD_H_ */