kernel: Adjust some comments to the unionfs removal.
[dragonfly.git] / include / pwd.h
CommitLineData
984263bc
MD
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 *
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. 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.
25 *
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
36 * SUCH DAMAGE.
37 *
38 * @(#)pwd.h 8.2 (Berkeley) 1/21/94
61ec5fb1 39 * $FreeBSD: src/include/pwd.h,v 1.17 2009/03/14 19:13:01 das Exp $
7c4af8e1 40 * $DragonFly: src/include/pwd.h,v 1.2 2003/11/14 01:01:43 dillon Exp $
984263bc
MD
41 */
42
43#ifndef _PWD_H_
44#define _PWD_H_
45
61ec5fb1 46#include <sys/cdefs.h>
984263bc
MD
47#include <sys/types.h>
48
61ec5fb1
PA
49#ifndef _GID_T_DECLARED
50typedef __uint32_t gid_t;
51#define _GID_T_DECLARED
52#endif
53
ed5d5720
PA
54#ifndef _TIME_T_DECLARED
55typedef __time_t time_t;
56#define _TIME_T_DECLARED
57#endif
58
61ec5fb1
PA
59#ifndef _UID_T_DECLARED
60typedef __uint32_t uid_t;
61#define _UID_T_DECLARED
62#endif
63
ed5d5720
PA
64#ifndef _SIZE_T_DECLARED
65typedef __size_t size_t;
66#define _SIZE_T_DECLARED
67#endif
68
984263bc
MD
69#define _PATH_PWD "/etc"
70#define _PATH_PASSWD "/etc/passwd"
71#define _PASSWD "passwd"
72#define _PATH_MASTERPASSWD "/etc/master.passwd"
73#define _MASTERPASSWD "master.passwd"
74
75#define _PATH_MP_DB "/etc/pwd.db"
76#define _MP_DB "pwd.db"
77#define _PATH_SMP_DB "/etc/spwd.db"
78#define _SMP_DB "spwd.db"
79
80#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb"
81
ed5d5720
PA
82/* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
83 * `1 octet tag | key', where the tag is one of the _PW_KEY* values
84 * listed below. These values happen to be ASCII digits.
85 * The tag is now still a single octet, but the
86 * upper 4 bits are interpreted as a version. Previous format
87 * entries are version `3' -- this conveniently results in the same
88 * key values as before. The new, architecture-independent entries
89 * are version `4'.
90 * As it happens, some applications read the database directly.
91 * (Bad app, no cookie!) Thus, we leave the _PW_KEY* symbols at their
92 * old values so these apps still work. Consequently
93 * we have to muck around a bit more to get the correct, versioned
94 * tag, and that is what the _PW_VERSIONED macro is about.
95 */
96
97#define _PW_VERSION_MASK '\xF0'
98#define _PW_VERSIONED(x, v) ((unsigned char)(((x) & 0xCF) | ((v)<<4)))
99
100#define _PW_KEYBYNAME '\x31' /* stored by name */
101#define _PW_KEYBYNUM '\x32' /* stored by entry in the "file" */
102#define _PW_KEYBYUID '\x33' /* stored by uid */
103#define _PW_KEYYPENABLED '\x34' /* YP is enabled */
104#define _PW_KEYYPBYNUM '\x35' /* special +@netgroup entries */
105
106/* The database also contains a key to indicate the format version of
107 * the entries therein. There may be other, older versioned entries
108 * as well.
109 */
110#define _PWD_VERSION_KEY "\xFF" "VERSION"
111#define _PWD_CURRENT_VERSION '\x04'
984263bc
MD
112
113#define _PASSWORD_EFMT1 '_' /* extended encryption format */
114
115#define _PASSWORD_LEN 128 /* max length, not counting NULL */
984263bc
MD
116
117struct passwd {
118 char *pw_name; /* user name */
119 char *pw_passwd; /* encrypted password */
120 uid_t pw_uid; /* user uid */
121 gid_t pw_gid; /* user gid */
122 time_t pw_change; /* password change time */
123 char *pw_class; /* user access class */
124 char *pw_gecos; /* Honeywell login info */
125 char *pw_dir; /* home directory */
126 char *pw_shell; /* default shell */
127 time_t pw_expire; /* account expiration */
128 int pw_fields; /* internal: fields filled in */
129};
130
131/* Mapping from fields to bits for pw_fields. */
132#define _PWF(x) (1 << x)
133#define _PWF_NAME _PWF(0)
134#define _PWF_PASSWD _PWF(1)
135#define _PWF_UID _PWF(2)
136#define _PWF_GID _PWF(3)
137#define _PWF_CHANGE _PWF(4)
138#define _PWF_CLASS _PWF(5)
139#define _PWF_GECOS _PWF(6)
140#define _PWF_DIR _PWF(7)
141#define _PWF_SHELL _PWF(8)
142#define _PWF_EXPIRE _PWF(9)
143
ed5d5720
PA
144/* XXX These flags are bogus. With nsswitch, there are many
145 * possible sources and they cannot be represented in a small integer.
146 */
147#define _PWF_SOURCE 0x3000
148#define _PWF_FILES 0x1000
149#define _PWF_NIS 0x2000
150#define _PWF_HESIOD 0x3000
151
984263bc 152__BEGIN_DECLS
ed5d5720
PA
153struct passwd *getpwnam(const char *);
154struct passwd *getpwuid(uid_t);
155
61ec5fb1 156#if __XSI_VISIBLE >= 500
ed5d5720
PA
157void endpwent(void);
158struct passwd *getpwent(void);
159void setpwent(void);
61ec5fb1
PA
160#endif
161
162#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
ed5d5720
PA
163int getpwnam_r(const char *, struct passwd *, char *, size_t,
164 struct passwd **);
165int getpwuid_r(uid_t, struct passwd *, char *, size_t,
166 struct passwd **);
167#endif
168
169#if __BSD_VISIBLE
e7e1e0fa 170int getpwent_r(struct passwd *, char *, size_t, struct passwd **);
ed5d5720
PA
171int setpassent(int);
172const char *user_from_uid(uid_t, int);
984263bc
MD
173#endif
174__END_DECLS
175
176#endif /* !_PWD_H_ */