source: trunk/src/emx/include/pwd.h@ 1505

Last change on this file since 1505 was 1505, checked in by bird, 21 years ago

Adding BSD stuff like there was no tomorrow.

  • Property cvs2svn:cvs-rev set to 1.3
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 6.7 KB
Line 
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
39 * $FreeBSD: src/include/pwd.h,v 1.15 2003/04/18 14:11:17 nectar Exp $
40 */
41
42/**
43 * FreeBSD 5.2
44 * @changed bird: some EMXisms.
45 */
46
47#ifndef _PWD_H_
48#define _PWD_H_
49#define _PWD_H /* bird: EMX */
50
51#include <sys/cdefs.h>
52#include <sys/_types.h>
53
54#if !defined(_GID_T_DECLARED) && !defined(_GID_T) /* bird */
55typedef __gid_t gid_t;
56#define _GID_T_DECLARED
57#define _GID_T /* bird */
58#endif
59
60#if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) /* bird */
61typedef __time_t time_t;
62#define _TIME_T_DECLARED
63#define _TIME_T /* bird */
64#endif
65
66#if !defined(_UID_T_DECLARED) && !defined(_UID_T) /* bird */
67typedef __uid_t uid_t;
68#define _UID_T_DECLARED
69#define _UID_T /* bird */
70#endif
71
72#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird */
73typedef __size_t size_t;
74#define _SIZE_T_DECLARED
75#define _SIZE_T /* bird */
76#endif
77
78
79#define _PATH_PWD "/etc"
80#define _PATH_PASSWD "/etc/passwd"
81#define _PASSWD "passwd"
82#define _PATH_MASTERPASSWD "/etc/master.passwd"
83#define _MASTERPASSWD "master.passwd"
84
85#define _PATH_MP_DB "/etc/pwd.db"
86#define _MP_DB "pwd.db"
87#define _PATH_SMP_DB "/etc/spwd.db"
88#define _SMP_DB "spwd.db"
89
90#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb"
91
92/* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
93 * `1 octet tag | key', where the tag is one of the _PW_KEY* values
94 * listed below. These values happen to be ASCII digits. Starting
95 * with FreeBSD 5.1, the tag is now still a single octet, but the
96 * upper 4 bits are interpreted as a version. Pre-FreeBSD 5.1 format
97 * entries are version `3' -- this conveniently results in the same
98 * key values as before. The new, architecture-independent entries
99 * are version `4'.
100 * As it happens, some applications read the database directly.
101 * (Bad app, no cookie!) Thus, we leave the _PW_KEY* symbols at their
102 * old pre-FreeBSD 5.1 values so these apps still work. Consequently
103 * we have to do muck around a bit more to get the correct, versioned
104 * tag, and that is what the _PW_VERSIONED macros is about.
105 */
106
107#define _PW_VERSION_MASK '0xF0'
108#define _PW_VERSIONED(x, v) ((unsigned char)(((x) & 0xCF) | ((v)<<4)))
109
110#define _PW_KEYBYNAME '\x31' /* stored by name */
111#define _PW_KEYBYNUM '\x32' /* stored by entry in the "file" */
112#define _PW_KEYBYUID '\x33' /* stored by uid */
113#define _PW_KEYYPENABLED '\x34' /* YP is enabled */
114#define _PW_KEYYPBYNUM '\x35' /* special +@netgroup entries */
115
116/* The database also contains a key to indicate the format version of
117 * the entries therein. There may be other, older versioned entries
118 * as well.
119 */
120#define _PWD_VERSION_KEY "\xFF" "VERSION"
121#define _PWD_CURRENT_VERSION '\x04'
122
123#define _PASSWORD_EFMT1 '_' /* extended encryption format */
124
125#define _PASSWORD_LEN 128 /* max length, not counting NULL */
126
127struct passwd {
128 char *pw_name; /* user name */
129 char *pw_passwd; /* encrypted password */
130 uid_t pw_uid; /* user uid */
131 gid_t pw_gid; /* user gid */
132 time_t pw_change; /* password change time */
133 char *pw_class; /* user access class */
134 char *pw_gecos; /* Honeywell login info */
135 char *pw_dir; /* home directory */
136 char *pw_shell; /* default shell */
137 time_t pw_expire; /* account expiration */
138 int pw_fields; /* internal: fields filled in */
139};
140
141/* Mapping from fields to bits for pw_fields. */
142#define _PWF(x) (1 << x)
143#define _PWF_NAME _PWF(0)
144#define _PWF_PASSWD _PWF(1)
145#define _PWF_UID _PWF(2)
146#define _PWF_GID _PWF(3)
147#define _PWF_CHANGE _PWF(4)
148#define _PWF_CLASS _PWF(5)
149#define _PWF_GECOS _PWF(6)
150#define _PWF_DIR _PWF(7)
151#define _PWF_SHELL _PWF(8)
152#define _PWF_EXPIRE _PWF(9)
153
154/* XXX These flags are bogus. With nsswitch, there are many
155 * possible sources and they cannot be represented in a small integer.
156 */
157#define _PWF_SOURCE 0x3000
158#define _PWF_FILES 0x1000
159#define _PWF_NIS 0x2000
160#define _PWF_HESIOD 0x3000
161
162__BEGIN_DECLS
163struct passwd *getpwnam(const char *);
164struct passwd *getpwuid(uid_t);
165
166#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
167void endpwent(void);
168struct passwd *getpwent(void);
169void setpwent(void);
170int getpwnam_r(const char *, struct passwd *, char *, size_t,
171 struct passwd **);
172int getpwuid_r(uid_t, struct passwd *, char *, size_t,
173 struct passwd **);
174#endif
175
176#if __BSD_VISIBLE
177int getpwent_r(struct passwd *, char *, size_t, struct passwd **);
178int setpassent(int);
179const char *user_from_uid(uid_t, int);
180#endif
181
182/* bird: emx stuff */
183char *getpass (__const__ char *);
184char *_getpass1 (__const__ char *);
185char *_getpass2 (__const__ char *, int);
186__END_DECLS
187
188#endif /* !_PWD_H_ */
189
Note: See TracBrowser for help on using the repository browser.