5 * User database management
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of `become'
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.
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.
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.
36 /*----- Required headers --------------------------------------------------*/
43 /*----- Type definitions --------------------------------------------------*/
45 /* --- Iterator objects --- */
47 typedef sym_iter userdb_iter;
49 /*----- User and group block manipulation ---------------------------------*/
51 /* --- @userdb_copyUser@ --- *
53 * Arguments: @struct passwd *pw@ = pointer to block to copy
55 * Returns: Pointer to the copy.
57 * Use: Copies a user block. The copy is `deep' so all the strings
58 * are copied too. Free the copy with @userdb_freeUser@ when
59 * you don't want it any more.
62 extern struct passwd *userdb_copyUser(struct passwd */*pw*/);
64 /* --- @userdb_freeUser@ --- *
66 * Arguments: @void *rec@ = pointer to a user record
70 * Use: Frees a user record.
73 extern void userdb_freeUser(void */*rec*/);
75 /* --- @userdb_copyGroup@ --- *
77 * Arguments: @struct group *gr@ = pointer to group block
79 * Returns: Pointer to copied block
81 * Use: Copies a group block. The copy is `deep' so all the strings
82 * are copied too. Free the copy with @userdb_freeGroup@ when
83 * you don't want it any more.
86 extern struct group *userdb_copyGroup(struct group */*gr*/);
88 /* --- @userdb_freeGroup@ --- *
90 * Arguments: @void *rec@ = pointer to a group record
94 * Use: Frees a group record.
97 extern void userdb_freeGroup(void */*rec*/);
99 /*----- Internal user database mapping ------------------------------------*/
101 /* --- @userdb_local@ --- *
107 * Use: Reads the local list of users into the maps.
110 extern void userdb_local(void);
112 /* --- @userdb_yp@ --- *
118 * Use: Fetches the YP database of users.
121 extern void userdb_yp(void);
123 /* --- @userdb_userByName@, @userdb_userById@ --- *
125 * Arguments: @const char *name@ = pointer to user's name
126 * @uid_t id@ = user id to find
128 * Returns: Pointer to user block, or zero if not found.
130 * Use: Looks up a user by name or id.
133 extern struct passwd *userdb_userByName(const char */*name*/);
134 extern struct passwd *userdb_userById(uid_t /*id*/);
136 /* --- @userdb_iterateUsers@, @userdb_iterateUsers_r@ --- *
138 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
142 * Use: Initialises an iteration for the user database.
145 extern void userdb_iterateUsers(void);
146 extern void userdb_iterateUsers_r(userdb_iter */*i*/);
148 /* --- @userdb_nextUser@, @userdb_nextUser_r@ --- *
150 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
152 * Returns: Pointer to the next user block, or null.
154 * Use: Returns another user block.
157 extern struct passwd *userdb_nextUser(void);
158 extern struct passwd *userdb_nextUser_r(userdb_iter */*i*/);
160 /* --- @userdb_groupByName@, @userdb_groupById@ --- *
162 * Arguments: @const char *name@ = pointer to group's name
163 * @gid_t id@ = group id to find
165 * Returns: Pointer to group block, or zero if not found.
167 * Use: Looks up a group by name or id.
170 extern struct group *userdb_groupByName(const char */*name*/);
171 extern struct group *userdb_groupById(gid_t /*id*/);
173 /* --- @userdb_iterateGroups@, @userdb_iterateGroups_r@ --- *
175 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
179 * Use: Initialises an iteration for the group database.
182 extern void userdb_iterateGroups(void);
183 extern void userdb_iterateGroups_r(userdb_iter */*i*/);
185 /* --- @userdb_nextGroup@, @userdb_nextGroup_r@ --- *
187 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
189 * Returns: Pointer to the next group block, or null.
191 * Use: Returns another group block.
194 extern struct group *userdb_nextGroup(void);
195 extern struct group *userdb_nextGroup_r(userdb_iter */*i*/);
197 /* --- @userdb_init@ --- *
203 * Use: Initialises the user database.
206 extern void userdb_init(void);
208 /* --- @userdb_end@ --- *
214 * Use: Closes down the user database.
217 extern void userdb_end(void);
219 /*----- That's all, folks -------------------------------------------------*/