1ad05182dc270128ed59307ad288b22de2a09190
[become] / src / userdb.h
1 /* -*-c-*-
2 *
3 * $Id*
4 *
5 * User database management
6 *
7 * (c) 1998 EBI
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of `become'
13 *
14 * `Become' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * `Become' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with `become'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: userdb.h,v $
32 * Revision 1.5 2003/10/12 00:14:55 mdw
33 * Major overhaul. Now uses DSA signatures rather than the bogus symmetric
34 * encrypt-and-hope thing. Integrated with mLib and Catacomb.
35 *
36 * Revision 1.4 1998/01/12 16:46:38 mdw
37 * Fix copyright date.
38 *
39 * Revision 1.3 1997/08/20 16:25:08 mdw
40 * Rename `userdb_reinit' to `userdb_end' for more sensible restart.
41 *
42 * Revision 1.2 1997/08/04 10:24:26 mdw
43 * Sources placed under CVS control.
44 *
45 * Revision 1.1 1997/07/21 13:47:42 mdw
46 * Initial revision
47 *
48 */
49
50 #ifndef USERDB_H
51 #define USERDB_H
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 /*----- Required headers --------------------------------------------------*/
58
59 #include <grp.h>
60 #include <pwd.h>
61
62 #include <mLib/sym.h>
63
64 /*----- Type definitions --------------------------------------------------*/
65
66 /* --- Iterator objects --- */
67
68 typedef sym_iter userdb_iter;
69
70 /*----- User and group block manipulation ---------------------------------*/
71
72 /* --- @userdb_copyUser@ --- *
73 *
74 * Arguments: @struct passwd *pw@ = pointer to block to copy
75 *
76 * Returns: Pointer to the copy.
77 *
78 * Use: Copies a user block. The copy is `deep' so all the strings
79 * are copied too. Free the copy with @userdb_freeUser@ when
80 * you don't want it any more.
81 */
82
83 extern struct passwd *userdb_copyUser(struct passwd */*pw*/);
84
85 /* --- @userdb_freeUser@ --- *
86 *
87 * Arguments: @void *rec@ = pointer to a user record
88 *
89 * Returns: ---
90 *
91 * Use: Frees a user record.
92 */
93
94 extern void userdb_freeUser(void */*rec*/);
95
96 /* --- @userdb_copyGroup@ --- *
97 *
98 * Arguments: @struct group *gr@ = pointer to group block
99 *
100 * Returns: Pointer to copied block
101 *
102 * Use: Copies a group block. The copy is `deep' so all the strings
103 * are copied too. Free the copy with @userdb_freeGroup@ when
104 * you don't want it any more.
105 */
106
107 extern struct group *userdb_copyGroup(struct group */*gr*/);
108
109 /* --- @userdb_freeGroup@ --- *
110 *
111 * Arguments: @void *rec@ = pointer to a group record
112 *
113 * Returns: ---
114 *
115 * Use: Frees a group record.
116 */
117
118 extern void userdb_freeGroup(void */*rec*/);
119
120 /*----- Internal user database mapping ------------------------------------*/
121
122 /* --- @userdb_local@ --- *
123 *
124 * Arguments: ---
125 *
126 * Returns: ---
127 *
128 * Use: Reads the local list of users into the maps.
129 */
130
131 extern void userdb_local(void);
132
133 /* --- @userdb_yp@ --- *
134 *
135 * Arguments: ---
136 *
137 * Returns: ---
138 *
139 * Use: Fetches the YP database of users.
140 */
141
142 extern void userdb_yp(void);
143
144 /* --- @userdb_userByName@, @userdb_userById@ --- *
145 *
146 * Arguments: @const char *name@ = pointer to user's name
147 * @uid_t id@ = user id to find
148 *
149 * Returns: Pointer to user block, or zero if not found.
150 *
151 * Use: Looks up a user by name or id.
152 */
153
154 extern struct passwd *userdb_userByName(const char */*name*/);
155 extern struct passwd *userdb_userById(uid_t /*id*/);
156
157 /* --- @userdb_iterateUsers@, @userdb_iterateUsers_r@ --- *
158 *
159 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
160 *
161 * Returns: ---
162 *
163 * Use: Initialises an iteration for the user database.
164 */
165
166 extern void userdb_iterateUsers(void);
167 extern void userdb_iterateUsers_r(userdb_iter */*i*/);
168
169 /* --- @userdb_nextUser@, @userdb_nextUser_r@ --- *
170 *
171 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
172 *
173 * Returns: Pointer to the next user block, or null.
174 *
175 * Use: Returns another user block.
176 */
177
178 extern struct passwd *userdb_nextUser(void);
179 extern struct passwd *userdb_nextUser_r(userdb_iter */*i*/);
180
181 /* --- @userdb_groupByName@, @userdb_groupById@ --- *
182 *
183 * Arguments: @const char *name@ = pointer to group's name
184 * @gid_t id@ = group id to find
185 *
186 * Returns: Pointer to group block, or zero if not found.
187 *
188 * Use: Looks up a group by name or id.
189 */
190
191 extern struct group *userdb_groupByName(const char */*name*/);
192 extern struct group *userdb_groupById(gid_t /*id*/);
193
194 /* --- @userdb_iterateGroups@, @userdb_iterateGroups_r@ --- *
195 *
196 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
197 *
198 * Returns: ---
199 *
200 * Use: Initialises an iteration for the group database.
201 */
202
203 extern void userdb_iterateGroups(void);
204 extern void userdb_iterateGroups_r(userdb_iter */*i*/);
205
206 /* --- @userdb_nextGroup@, @userdb_nextGroup_r@ --- *
207 *
208 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
209 *
210 * Returns: Pointer to the next group block, or null.
211 *
212 * Use: Returns another group block.
213 */
214
215 extern struct group *userdb_nextGroup(void);
216 extern struct group *userdb_nextGroup_r(userdb_iter */*i*/);
217
218 /* --- @userdb_init@ --- *
219 *
220 * Arguments: ---
221 *
222 * Returns: ---
223 *
224 * Use: Initialises the user database.
225 */
226
227 extern void userdb_init(void);
228
229 /* --- @userdb_end@ --- *
230 *
231 * Arguments: ---
232 *
233 * Returns: ---
234 *
235 * Use: Closes down the user database.
236 */
237
238 extern void userdb_end(void);
239
240 /*----- That's all, folks -------------------------------------------------*/
241
242 #ifdef __cplusplus
243 }
244 #endif
245
246 #endif