user_from_uid()

NAME

user_from_uid(), group_from_gid() - get user or group name from uid or gid

SYNOPSIS

#include <pwd.h>
#include <grp.h>

int pwcache_enable ;
char * user_from_uid(uid_t userid, int d) char * group_from_gid(gid_t groupid, int d)

DESCRIPTION

The user_from_uid(3) returns the user name associated with the argument userid. If the global variable pwcache_enable has been set to the value 1 (the default), the user name is cached so that multiple calls with the same user ID do not make additional calls to getpwuid(2). If there is no user associated with userid, user_from_uid(3) returns a pointer to a string that represents userid. If pwcache_enable is set to 0, caching is disabled.

The group_from_gid(3) returns the group name associated with the argument groupid. If the global variable pwcache_enable has been set to the value 1 (the default), the user name is cached so that multiple calls with the same user ID do not make additional calls to getgrgid(2). If there is no user associated with groupid, group_from_gid(3) returns a pointer to a string that represents groupid. If pwcache_enable is set to 0, caching is disabled.

userid
A user ID number.
d
This argument is reserved for future use; please pass a 0 here.

RETURN VALUE

User_from_uid(3) and group_from_gid(3) always return a pointer to a valid string. Because they call getpwuid(2) and getgrgid(2), the errno value may be set with any of the errors possible from those functions.

Under some circumstances, the pointer will be to a static buffer which may be overwritten by the next call to this function or to getpwuid(2) or getgrgid(2).

SEE ALSO

getgrgid(2)

getpwuid(2)