• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. 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.
21  *
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.
33  *
34  *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
35  */
36 
37 /*-
38  * Portions Copyright(C) 1995, Jason Downs.  All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  *    notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  *    notice, this list of conditions and the following disclaimer in the
47  *    documentation and/or other materials provided with the distribution.
48  *
49  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
50  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
51  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
53  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
54  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
55  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59  * SUCH DAMAGE.
60  */
61 
62 #ifndef _PWD_H_
63 #define _PWD_H_
64 
65 #include <sys/cdefs.h>
66 #include <sys/types.h>
67 
68 #define _PATH_PASSWD        "/etc/passwd"
69 #define _PATH_MASTERPASSWD  "/etc/master.passwd"
70 #define _PATH_MASTERPASSWD_LOCK "/etc/ptmp"
71 
72 #define _PATH_PASSWD_CONF   "/etc/passwd.conf"
73 #define _PATH_PASSWDCONF    _PATH_PASSWD_CONF   /* XXX: compat */
74 #define _PATH_USERMGMT_CONF "/etc/usermgmt.conf"
75 
76 #define _PATH_MP_DB     "/etc/pwd.db"
77 #define _PATH_SMP_DB        "/etc/spwd.db"
78 
79 #define _PATH_PWD_MKDB      "/usr/sbin/pwd_mkdb"
80 
81 #define _PW_KEYBYNAME       '1' /* stored by name */
82 #define _PW_KEYBYNUM        '2' /* stored by entry in the "file" */
83 #define _PW_KEYBYUID        '3' /* stored by uid */
84 
85 #define _PASSWORD_EFMT1     '_' /* extended DES encryption format */
86 #define _PASSWORD_NONDES    '$' /* non-DES encryption formats */
87 
88 #define _PASSWORD_LEN       128 /* max length, not counting NUL */
89 
90 #define _PASSWORD_NOUID     0x01    /* flag for no specified uid. */
91 #define _PASSWORD_NOGID     0x02    /* flag for no specified gid. */
92 #define _PASSWORD_NOCHG     0x04    /* flag for no specified change. */
93 #define _PASSWORD_NOEXP     0x08    /* flag for no specified expire. */
94 
95 #define _PASSWORD_OLDFMT    0x10    /* flag to expect an old style entry */
96 #define _PASSWORD_NOWARN    0x20    /* no warnings for bad entries */
97 
98 #define _PASSWORD_WARNDAYS  14  /* days to warn about expiry */
99 #define _PASSWORD_CHGNOW    -1  /* special day to force password change at next login */
100 
101 struct passwd
102 {
103   char* pw_name;
104   char* pw_passwd;
105   uid_t pw_uid;
106   gid_t pw_gid;
107 #ifdef __LP64__
108   char* pw_gecos;
109 #else
110   // Note: On LP32, we define pw_gecos to pw_passwd since they're both NULL.
111 # define pw_gecos pw_passwd
112 #endif
113   char* pw_dir;
114   char* pw_shell;
115 };
116 
117 __BEGIN_DECLS
118 
119 struct passwd* getpwnam(const char*);
120 struct passwd* getpwuid(uid_t);
121 
122 int getpwnam_r(const char*, struct passwd*, char*, size_t, struct passwd**);
123 int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**);
124 
125 __END_DECLS
126 
127 #endif
128