getpwuid_r() — Search user database for a user ID

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, Version 2
Single UNIX Specification, Version 3

both OS/390 V2R8

Format

#define _XOPEN_SOURCE 500
#include <sys/types.h>
#include <pwd.h>

int getpwuid_r(uid_t uid, struct passwd *pwd,
char *buffer, size_t bufsize, struct passwd **result);

General description

The getpwuid_r() function updates the passwd structure pointed to by pwd and stores a pointer to that structure at the location pointed to by result. The structure will contain an entry from the user database with a matching uid. Storage referenced by the structure is allocated from the memory provided with the buffer parameter, which is bufsize characters in size. A NULL pointer is returned at the location pointed to by result on error or if the requested entry is not found.

Returned value

If successful, getpwuid_r() returns 0.

If unsuccessful, getpwuid_r() returns a NULL pointer and sets errno to one of the following values:
Error Code
Description
EINVAL
One of the input arguments was not valid. Arguments pwd, buffer, and result must not be NULL. Argument bufsize must not be 0.
EMVSSAF2ERR
The system authorization facility (SAF) or RACF Get GMAP or Get UMAP service had an error.
EMVSSAFEXTRERR
The SAF or RACF RACROUTE EXTRACT service had an error.
ERANGE
Insufficient storage was supplied in buffer and bufsize to contain the data to be referenced by the resulting passwd structure.

Related information