11.7. User and Group ID Information Routines
These are a handful of routines that act as frontends to the standard Unix getpwnam( ) and getgrnam( ) functions. In addition to their role as easy-to-use wrappers, they provide portability with operating systems that don't provide these calls, such as Win32 systems.
These routines are declared in httpd.h:
uid_t ap_uname2id (const char *uname)
Used internally to process the User configuration directive, this function will use getpwnam() to look up the given user login name and return the user's UID. If the name is prefixed with the # symbol, as in #501, the string is converted into integer format and simply returned. Under Win32 systems, this function always returns 1.
uid_t id = ap_uname2id(uname);
gid_t ap_gname2id (const char *gname)
This function behaves identically to ap_uname2id(), except that it operates on group names and group IDs, using the Unix getgrnam() for its lookups. Under Win32 systems, this function will always return 1.
gid_t id = ap_gname2id(gname);
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access