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
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. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#)pwd.h 8.2 (Berkeley) 1/21/94
39 * $FreeBSD: src/include/pwd.h,v 1.16 2005/01/26 17:26:54 nectar Exp $
40 * $DragonFly: src/include/pwd.h,v 1.2 2003/11/14 01:01:43 dillon Exp $
46 #include <sys/types.h>
48 #ifndef _TIME_T_DECLARED
49 typedef __time_t
time_t;
50 #define _TIME_T_DECLARED
53 #ifndef _SIZE_T_DECLARED
54 typedef __size_t
size_t;
55 #define _SIZE_T_DECLARED
58 #define _PATH_PWD "/etc"
59 #define _PATH_PASSWD "/etc/passwd"
60 #define _PASSWD "passwd"
61 #define _PATH_MASTERPASSWD "/etc/master.passwd"
62 #define _MASTERPASSWD "master.passwd"
64 #define _PATH_MP_DB "/etc/pwd.db"
65 #define _MP_DB "pwd.db"
66 #define _PATH_SMP_DB "/etc/spwd.db"
67 #define _SMP_DB "spwd.db"
69 #define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb"
71 /* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
72 * `1 octet tag | key', where the tag is one of the _PW_KEY* values
73 * listed below. These values happen to be ASCII digits.
74 * The tag is now still a single octet, but the
75 * upper 4 bits are interpreted as a version. Previous format
76 * entries are version `3' -- this conveniently results in the same
77 * key values as before. The new, architecture-independent entries
79 * As it happens, some applications read the database directly.
80 * (Bad app, no cookie!) Thus, we leave the _PW_KEY* symbols at their
81 * old values so these apps still work. Consequently
82 * we have to muck around a bit more to get the correct, versioned
83 * tag, and that is what the _PW_VERSIONED macro is about.
86 #define _PW_VERSION_MASK '\xF0'
87 #define _PW_VERSIONED(x, v) ((unsigned char)(((x) & 0xCF) | ((v)<<4)))
89 #define _PW_KEYBYNAME '\x31' /* stored by name */
90 #define _PW_KEYBYNUM '\x32' /* stored by entry in the "file" */
91 #define _PW_KEYBYUID '\x33' /* stored by uid */
92 #define _PW_KEYYPENABLED '\x34' /* YP is enabled */
93 #define _PW_KEYYPBYNUM '\x35' /* special +@netgroup entries */
95 /* The database also contains a key to indicate the format version of
96 * the entries therein. There may be other, older versioned entries
99 #define _PWD_VERSION_KEY "\xFF" "VERSION"
100 #define _PWD_CURRENT_VERSION '\x04'
102 #define _PASSWORD_EFMT1 '_' /* extended encryption format */
104 #define _PASSWORD_LEN 128 /* max length, not counting NULL */
107 char *pw_name
; /* user name */
108 char *pw_passwd
; /* encrypted password */
109 uid_t pw_uid
; /* user uid */
110 gid_t pw_gid
; /* user gid */
111 time_t pw_change
; /* password change time */
112 char *pw_class
; /* user access class */
113 char *pw_gecos
; /* Honeywell login info */
114 char *pw_dir
; /* home directory */
115 char *pw_shell
; /* default shell */
116 time_t pw_expire
; /* account expiration */
117 int pw_fields
; /* internal: fields filled in */
120 /* Mapping from fields to bits for pw_fields. */
121 #define _PWF(x) (1 << x)
122 #define _PWF_NAME _PWF(0)
123 #define _PWF_PASSWD _PWF(1)
124 #define _PWF_UID _PWF(2)
125 #define _PWF_GID _PWF(3)
126 #define _PWF_CHANGE _PWF(4)
127 #define _PWF_CLASS _PWF(5)
128 #define _PWF_GECOS _PWF(6)
129 #define _PWF_DIR _PWF(7)
130 #define _PWF_SHELL _PWF(8)
131 #define _PWF_EXPIRE _PWF(9)
133 /* XXX These flags are bogus. With nsswitch, there are many
134 * possible sources and they cannot be represented in a small integer.
136 #define _PWF_SOURCE 0x3000
137 #define _PWF_FILES 0x1000
138 #define _PWF_NIS 0x2000
139 #define _PWF_HESIOD 0x3000
141 #include <sys/cdefs.h>
144 struct passwd
*getpwnam(const char *);
145 struct passwd
*getpwuid(uid_t
);
147 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
149 struct passwd
*getpwent(void);
151 int getpwnam_r(const char *, struct passwd
*, char *, size_t,
153 int getpwuid_r(uid_t
, struct passwd
*, char *, size_t,
158 int getpwent_r(struct passwd
*, char *, size_t, struct passwd
**);
160 const char *user_from_uid(uid_t
, int);
164 #endif /* !_PWD_H_ */