Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

updatepwgr(1SX)

getlogin(3C)

getgrent(3C)

passwd(4)



getpwent(3C)                                         getpwent(3C)



NAME
     getpwent, getpwuid, getpwnam, setpwent, endpwent, fgetpwent
     - get password file entry

SYNOPSIS
     #include <pwd.h>

     struct passwd *getpwent ( )

     struct passwd *getpwuid (uid)
     int uid;

     struct passwd *getpwnam (name)
     char *name;

     void setpwent ( )

     void endpwent ( )

SYNOPSIS (SYSV.2)
     struct passwd *fgetpwent (f)
     FILE *f;

DESCRIPTION
     getpwent, getpwuid and getpwnam each returns a pointer to an
     object with the following structure containing the broken-
     out fields of a line in the /etc/passwd file.  Each line in
     the file contains a passwd structure, declared in the
     <pwd.h> header file.  The structure has the following
     members:

               char      *pw_name;
               char      *pw_passwd;
               uid_t     pw_uid;
               gid_t     pw_gid;
               int       pw_quota;
               char      *pw_age;
               char      *pw_comment;
               char      *pw_gecos;
               char      *pw_dir;
               char      *pw_shell;
          };

     This structure is declared in <pwd.h> so it is not necessary
     to redeclare it.

     The pw_comment field is unused; the others have meanings
     described in passwd(4).

     getpwent when first called returns a pointer to the first
     passwd structure in the file; thereafter, it returns a
     pointer to the next passwd structure in the file; so



Page 1                        CX/UX Programmer's Reference Manual





getpwent(3C)                                         getpwent(3C)



     successive calls can be used to search the entire file.
     Getpwuid searches from the beginning of the file until a
     numerical user id matching uid is found and returns a
     pointer to the particular structure in which it was found.
     Getpwnam searches from the beginning of the file until a
     login name matching name is found, and returns a pointer to
     the particular structure in which it was found.  If an end-
     of-file or an error is encountered on reading, these func-
     tions return a NULL pointer.

     A call to setpwent has the effect of rewinding the password
     file to allow repeated searches.  Endpwent may be called to
     close the password file when processing is complete.

     Fgetpwent returns a pointer to the next passwd structure in
     the stream f, which matches the format of /etc/passwd.

SECURITY FEATURES
     In CX/SX, the encrypted passwords are kept in /mls/passwd
     which is unreadable except by components of the Trusted Com-
     puting Base.  The file "/etc/passwd" is a user visible "sha-
     dow" password file which is identical to the real password
     file (i.e. /mls/passwd) except that the password field con-
     tains an

     If the effective-user-id of the process is "root" then
     getpwent, getpwuid and getpwnam attempt to open the
     "/mls/passwd" file.  If this fails then they attempt to open
     the user visible copy of the password file (/etc/passwd).

FILES
     /etc/passwd /mls/passwd

SEE ALSO
     updatepwgr(1SX), getlogin(3C), getgrent(3C), passwd(4).

DIAGNOSTICS
     A NULL pointer is returned on EOF or error.

WARNING
     The above routines use <stdio.h>, which causes them to
     increase the size of programs, not otherwise using standard
     I/O, more than might be expected.

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








Page 2                        CX/UX Programmer's Reference Manual



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