Add new generic functions to find the next user or group ID available:
find_new_uid() and find_new_gid(). They work the same way as the functions with the same name of useradd or groupadd, except that they check in the local database to make sure an ID was not reserved in an uncommitted change (this is needed to be used in newusers), they report a status instead of calling exit(), and they can receive a preferred ID. They should later support system IDs. This should be a little bit slower, but not too much (if the database is not open the checks against the local database will exit immediately, and if it is already open, all the checks will be done regarding the data in memory).
This commit is contained in:
@ -67,6 +67,10 @@ extern void sanitize_env (void);
|
||||
extern void change_field (char *, size_t, const char *);
|
||||
extern int valid_field (const char *, const char *);
|
||||
|
||||
/* find_new_ids.c */
|
||||
extern int find_new_uid (int sys_user, uid_t *uid, uid_t const *preferred_uid);
|
||||
extern int find_new_gid (int sys_group, gid_t *gid, gid_t const *preferred_gid);
|
||||
|
||||
/* getlong.c */
|
||||
extern int getlong(const char *numstr, long int *result);
|
||||
|
||||
|
Reference in New Issue
Block a user