Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

CentOS 3.1

getpwuid(3)


GETPWNAM

GETPWNAM

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
FILES
CONFORMING TO
NOTES
SEE ALSO

NAME

getpwnam, getpwuid − get password file entry

SYNOPSIS

#include <pwd.h>
#include <sys/types.h>

struct passwd *getpwnam(const char *name);

struct passwd *getpwuid(uid_t uid);

DESCRIPTION

The getpwnam() function returns a pointer to a structure containing the broken out fields of a line from /etc/passwd for the entry that matches the user name name.

The getpwuid() function returns a pointer to a structure containing the broken out fields of a line from /etc/passwd for the entry that matches the user uid uid.

The passwd structure is defined in <pwd.h> as follows:

struct passwd {

char *pw_name;

/* user name */
char *pw_passwd;

/* user password */
uid_t pw_uid;

/* user id */
gid_t pw_gid;

/* group id */

char *pw_gecos; /* real name */

char *pw_dir;

/* home directory */

char *pw_shell; /* shell program */
};

RETURN VALUE

The getpwnam() and getpwuid() functions return a pointer to the passwd structure, or NULL if the matching entry is not found or an error occurs. If an error occurs, errno is set appropriately.

The return value may point to static area, and may be overwritten by subsequent calls.

ERRORS

0 or ENOENT or ESRCH or EBADF or EPERM or ...

The given name or gid was not found.

ENOMEM

Insufficient memory to allocate passwd structure.

EIO

I/O error.

EINTR

A signal was caught.

EMFILE

The maximum number (OPEN_MAX) of files was open already in the calling process.

ENFILE

The maximum number of files was open already in the system.

FILES

/etc/passwd

password database file

CONFORMING TO

SVID 3, POSIX, BSD 4.3

NOTES

The formulation given above under "RETURN VALUE" is from POSIX 1003.1-2001. It does not call "not found" an error, hence does not specify what value errno might have in this situation. But that makes it impossible to recognize errors. One might argue that according to POSIX errno should be left unchanged if an entry is not found. Experiments on various Unix-like systems shows that lots of different values occur in this situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others.

SEE ALSO

fgetpwent(3), getgrnam(3), getpwent(3), setpwent(3), endpwent(3), getpw(3), putpwent(3), passwd(5)



getpwuid(3)