Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getgrent(3)

getlogin(3)

ypclnt(3yp)

passwd(5yp)

getpwent(3)

NAME

getpwent, getpwuid, getpwnam, setpwent, endpwent − get password file entry

SYNTAX

#include <pwd.h>

struct passwd *getpwent()

struct passwd *getpwuid(uid)
int uid;

struct passwd *getpwnam(name)
char *name;

int setpwent()

int endpwent()

DESCRIPTION

The routines, getpwent, getpwuid and getpwnam, each return a pointer to an object with the following structure containing the broken-out fields of a line in the password file:

struct  passwd { /* see getpwent(3) */
        char    *pw_name;
        char    *pw_passwd;
        int     pw_uid;
        int     pw_gid;
        int     pw_quota;
        char    *pw_comment;
        char    *pw_gecos;
        char    *pw_dir;
        char    *pw_shell;
};
 struct passwd *getpwent(), *getpwuid(), *getpwnam();

The fields pw_quota and pw_comment are unused; the others have meanings described in passwd(.).

The getpwent routine reads the next line (opening the file if necessary). The setpwent subroutine rewinds the file. The endpwent subroutine closes it.

The getpwuid and getpwnam routines search from the beginning until a matching uid or name is found (or until EOF is encountered). 

RESTRICTIONS

All information is contained in a static area so it must be copied if it is to be saved. 

If YP is running, getpwent does not return the entries in any particular order.

RETURN VALUE

Null pointer (0) returned on EOF or error. 

FILES

/etc/passwd

SEE ALSO

getgrent(3), getlogin(3), ypclnt(3yp), passwd(5yp)

Subroutines

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026