1 | /* pwd.h,v 1.4 2004/09/14 22:27:35 bird Exp */
|
---|
2 | /**
|
---|
3 | * FreeBSD 5.2
|
---|
4 | * @changed bird: some EMXisms.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*-
|
---|
8 | * Copyright (c) 1989, 1993
|
---|
9 | * The Regents of the University of California. All rights reserved.
|
---|
10 | * (c) UNIX System Laboratories, Inc.
|
---|
11 | * All or some portions of this file are derived from material licensed
|
---|
12 | * to the University of California by American Telephone and Telegraph
|
---|
13 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
---|
14 | * the permission of UNIX System Laboratories, Inc.
|
---|
15 | *
|
---|
16 | * Redistribution and use in source and binary forms, with or without
|
---|
17 | * modification, are permitted provided that the following conditions
|
---|
18 | * are met:
|
---|
19 | * 1. Redistributions of source code must retain the above copyright
|
---|
20 | * notice, this list of conditions and the following disclaimer.
|
---|
21 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
22 | * notice, this list of conditions and the following disclaimer in the
|
---|
23 | * documentation and/or other materials provided with the distribution.
|
---|
24 | * 3. All advertising materials mentioning features or use of this software
|
---|
25 | * must display the following acknowledgement:
|
---|
26 | * This product includes software developed by the University of
|
---|
27 | * California, Berkeley and its contributors.
|
---|
28 | * 4. Neither the name of the University nor the names of its contributors
|
---|
29 | * may be used to endorse or promote products derived from this software
|
---|
30 | * without specific prior written permission.
|
---|
31 | *
|
---|
32 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
40 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
41 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
42 | * SUCH DAMAGE.
|
---|
43 | *
|
---|
44 | * @(#)pwd.h 8.2 (Berkeley) 1/21/94
|
---|
45 | * $FreeBSD: src/include/pwd.h,v 1.15 2003/04/18 14:11:17 nectar Exp $
|
---|
46 | */
|
---|
47 |
|
---|
48 | #ifndef _PWD_H_
|
---|
49 | #define _PWD_H_
|
---|
50 | #define _PWD_H /* bird: EMX */
|
---|
51 |
|
---|
52 | #include <sys/cdefs.h>
|
---|
53 | #include <sys/_types.h>
|
---|
54 |
|
---|
55 | #if !defined(_GID_T_DECLARED) && !defined(_GID_T) /* bird */
|
---|
56 | typedef __gid_t gid_t;
|
---|
57 | #define _GID_T_DECLARED
|
---|
58 | #define _GID_T /* bird */
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | #if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) /* bird */
|
---|
62 | typedef __time_t time_t;
|
---|
63 | #define _TIME_T_DECLARED
|
---|
64 | #define _TIME_T /* bird */
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #if !defined(_UID_T_DECLARED) && !defined(_UID_T) /* bird */
|
---|
68 | typedef __uid_t uid_t;
|
---|
69 | #define _UID_T_DECLARED
|
---|
70 | #define _UID_T /* bird */
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird */
|
---|
74 | typedef __size_t size_t;
|
---|
75 | #define _SIZE_T_DECLARED
|
---|
76 | #define _SIZE_T /* bird */
|
---|
77 | #endif
|
---|
78 |
|
---|
79 |
|
---|
80 | #define _PATH_PWD "/@unixroot/etc"
|
---|
81 | #define _PATH_PASSWD "/@unixroot/etc/passwd"
|
---|
82 | #define _PASSWD "passwd"
|
---|
83 | #define _PATH_MASTERPASSWD "/@unixroot/etc/master.passwd"
|
---|
84 | #define _MASTERPASSWD "master.passwd"
|
---|
85 |
|
---|
86 | #define _PATH_MP_DB "/@unixroot/etc/pwd.db"
|
---|
87 | #define _MP_DB "pwd.db"
|
---|
88 | #define _PATH_SMP_DB "/@unixroot/etc/spwd.db"
|
---|
89 | #define _SMP_DB "spwd.db"
|
---|
90 |
|
---|
91 | #define _PATH_PWD_MKDB "/@unixroot/usr/sbin/pwd_mkdb"
|
---|
92 |
|
---|
93 | /* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
|
---|
94 | * `1 octet tag | key', where the tag is one of the _PW_KEY* values
|
---|
95 | * listed below. These values happen to be ASCII digits. Starting
|
---|
96 | * with FreeBSD 5.1, the tag is now still a single octet, but the
|
---|
97 | * upper 4 bits are interpreted as a version. Pre-FreeBSD 5.1 format
|
---|
98 | * entries are version `3' -- this conveniently results in the same
|
---|
99 | * key values as before. The new, architecture-independent entries
|
---|
100 | * are version `4'.
|
---|
101 | * As it happens, some applications read the database directly.
|
---|
102 | * (Bad app, no cookie!) Thus, we leave the _PW_KEY* symbols at their
|
---|
103 | * old pre-FreeBSD 5.1 values so these apps still work. Consequently
|
---|
104 | * we have to do muck around a bit more to get the correct, versioned
|
---|
105 | * tag, and that is what the _PW_VERSIONED macros is about.
|
---|
106 | */
|
---|
107 |
|
---|
108 | #define _PW_VERSION_MASK '0xF0'
|
---|
109 | #define _PW_VERSIONED(x, v) ((unsigned char)(((x) & 0xCF) | ((v)<<4)))
|
---|
110 |
|
---|
111 | #define _PW_KEYBYNAME '\x31' /* stored by name */
|
---|
112 | #define _PW_KEYBYNUM '\x32' /* stored by entry in the "file" */
|
---|
113 | #define _PW_KEYBYUID '\x33' /* stored by uid */
|
---|
114 | #define _PW_KEYYPENABLED '\x34' /* YP is enabled */
|
---|
115 | #define _PW_KEYYPBYNUM '\x35' /* special +@netgroup entries */
|
---|
116 |
|
---|
117 | /* The database also contains a key to indicate the format version of
|
---|
118 | * the entries therein. There may be other, older versioned entries
|
---|
119 | * as well.
|
---|
120 | */
|
---|
121 | #define _PWD_VERSION_KEY "\xFF" "VERSION"
|
---|
122 | #define _PWD_CURRENT_VERSION '\x04'
|
---|
123 |
|
---|
124 | #define _PASSWORD_EFMT1 '_' /* extended encryption format */
|
---|
125 |
|
---|
126 | #define _PASSWORD_LEN 128 /* max length, not counting NULL */
|
---|
127 |
|
---|
128 | struct passwd {
|
---|
129 | char *pw_name; /* user name */
|
---|
130 | char *pw_passwd; /* encrypted password */
|
---|
131 | uid_t pw_uid; /* user uid */
|
---|
132 | gid_t pw_gid; /* user gid */
|
---|
133 | time_t pw_change; /* password change time */
|
---|
134 | char *pw_class; /* user access class */
|
---|
135 | char *pw_gecos; /* Honeywell login info */
|
---|
136 | char *pw_dir; /* home directory */
|
---|
137 | char *pw_shell; /* default shell */
|
---|
138 | time_t pw_expire; /* account expiration */
|
---|
139 | int pw_fields; /* internal: fields filled in */
|
---|
140 | };
|
---|
141 |
|
---|
142 | /* Mapping from fields to bits for pw_fields. */
|
---|
143 | #define _PWF(x) (1 << x)
|
---|
144 | #define _PWF_NAME _PWF(0)
|
---|
145 | #define _PWF_PASSWD _PWF(1)
|
---|
146 | #define _PWF_UID _PWF(2)
|
---|
147 | #define _PWF_GID _PWF(3)
|
---|
148 | #define _PWF_CHANGE _PWF(4)
|
---|
149 | #define _PWF_CLASS _PWF(5)
|
---|
150 | #define _PWF_GECOS _PWF(6)
|
---|
151 | #define _PWF_DIR _PWF(7)
|
---|
152 | #define _PWF_SHELL _PWF(8)
|
---|
153 | #define _PWF_EXPIRE _PWF(9)
|
---|
154 |
|
---|
155 | /* XXX These flags are bogus. With nsswitch, there are many
|
---|
156 | * possible sources and they cannot be represented in a small integer.
|
---|
157 | */
|
---|
158 | #define _PWF_SOURCE 0x3000
|
---|
159 | #define _PWF_FILES 0x1000
|
---|
160 | #define _PWF_NIS 0x2000
|
---|
161 | #define _PWF_HESIOD 0x3000
|
---|
162 |
|
---|
163 | __BEGIN_DECLS
|
---|
164 | struct passwd *getpwnam(const char *);
|
---|
165 | struct passwd *getpwuid(uid_t);
|
---|
166 |
|
---|
167 | #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
|
---|
168 | void endpwent(void);
|
---|
169 | struct passwd *getpwent(void);
|
---|
170 | void setpwent(void);
|
---|
171 | int getpwnam_r(const char *, struct passwd *, char *, size_t,
|
---|
172 | struct passwd **);
|
---|
173 | int getpwuid_r(uid_t, struct passwd *, char *, size_t,
|
---|
174 | struct passwd **);
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | #if __BSD_VISIBLE
|
---|
178 | int getpwent_r(struct passwd *, char *, size_t, struct passwd **);
|
---|
179 | int setpassent(int);
|
---|
180 | const char *user_from_uid(uid_t, int);
|
---|
181 | #endif
|
---|
182 |
|
---|
183 | /* bird: emx stuff */
|
---|
184 | char *getpass (const char *);
|
---|
185 | char *_getpass1 (const char *);
|
---|
186 | char *_getpass2 (const char *, int);
|
---|
187 | __END_DECLS
|
---|
188 |
|
---|
189 | #endif /* !_PWD_H_ */
|
---|
190 |
|
---|