|
|
int pw_nametoid(name) char *name;char *pw_idtoname(id) int id;
int gr_nametoid(name) char *name;
char *gr_idtoname(id) int id;
pw_idtoname- map between user IDs and names
gr_nametoid- map between group names and IDs
gr_idtoname- map between group IDs and names
These routines provide an efficient mapping between user and group names and identifiers (IDs). They maintain a separate binary database, which is automatically updated each time the routines encounter a changed /etc/passwd or /etc/group file. Also, these routines do not interfere with the behavior of the getpwent(S) and getgrent(S) routines, and are thus used by the Protected Database routines, which must frequently convert between names and identifiers but may not disrupt an application's use of password mapping routines.
The pw_nametoid expects the character argument name, a user name, and returns its associated user ID. The pw_idtoname expects the argument id, a user ID number, and returns its associated user name.
The gr_nametoid expects the character argument name, a group name, and returns its associated group ID. The gr_idtoname expects the argument id, a group ID number, and returns its associated group name.
These routines are much more efficient than the getpwent(S) and getgrent(S) routines, in that they do not parse the underlying files and keep the database in memory after the first use. Thus, savings are much greater for the second and subsequent lookups. The binary databases are stored in the /etc/auth/system directory, which is maintained by the Auth protected subsystem.
Upon successful completion, the pw_nametoid and the gr_nametoid routines return a non-negative user or group ID. On failure, these routines return a value of -1.