DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pw_nametoid(S-osr5)


pw_nametoid, pw_idtoname, gr_nametoid, gr_idtoname -- map between user and group names and IDs

Syntax

cc . . . -lprot

int pw_nametoid(name)
char *name;

char *pw_idtoname(id) int id;

int gr_nametoid(name) char *name;

char *gr_idtoname(id) int id;

Description.

pw_nametoid- map between user names and IDs

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-osr5) and getgrent(S-osr5) 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-osr5) and getgrent(S-osr5) 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.

Return value

Upon successful completion, the pw_idtoname and the gr_idtoname routines return a pointer to a string in an internal (to the routines) memory area containing the user or the group names. These routines return a NULL on failure.

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.

Files

/etc/auth/system/pw_id_map
/etc/auth/system/gr_id_map
/etc/passwd
/etc/group

See also

getpwent(S-osr5), getgrent(S-osr5), getprpwent(S-osr5)

Standards conformance

All of these routines are an extension of AT&T System V provided by the Santa Cruz Operation.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005