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