Книга: Programming with POSIX® Threads

6.5.6 Group and user database

6.5.6 Group and user database

Group database:

int getgrgid_r (gid_t gid, struct group *grp, char *buffer,

size_t bufsize, struct group **result);

int getgrnam_r (

const char *name, struct group *grp,

char *buffer, size_t bufsize,

struct group **result);

User database:

int getpwuid_r (

uid_t uid, struct passwd *pwd, char *buffer,

size_t bufsize, struct passwd **result); int getpwnam_r (

const char *name, struct passwd *pwd,

char *buffer, size_t bufsize,

struct passwd **result);

These functions store a copy of the group or user record (grp or pwd, respectively) for the specified group or user (gid, uid, or name) in a buffer designated by

the arguments buffer and bufsize. The function return value is in each case either 0 for success, or an error number (such as ERANGE when the buffer is too small) to designate an error. If the requested record is not present in the group or passwd database, the functions may return success but store the value NULL into the result pointer. If the record is found and the buffer is large enough, result becomes a pointer to the struct group or struct passwd record within buffer.

The maximum required size for buffer can be determined by calling sysconf with the argument _SC_GETGR_R_SIZE_MAX (for group data) or with the argument _SC_GETPW_R_SIZE MAX(for user data).

Оглавление книги


Генерация: 1.711. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз