Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fgetspwent(3C) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getgrent(3C)

getlogin(3C)

getpwent(3C)

putspwent(3C)

passwd(4)

spasswd(4)

ypcat(1)

GETSPWENT(3C)

NAME

getspwent, getspwuid, getspwaid, getspwnam, setspwent, endspwent, fgetspwent − get secure password file entry

SYNOPSIS

#include <pwd.h>

struct s_passwd ∗getspwent ( )

struct s_passwd ∗getspwuid (uid)
uid_t uid;

struct s_passwd ∗getspwaid (aid)
aid_t aid;

struct s_passwd ∗getspwnam (name)
char ∗name;

void setspwent ( )

void endspwent ( )

struct s_passwd ∗fgetspwent (f)
FILE ∗f;

DESCRIPTION

These privileged routines provide access to the secure password file in a manner similar to the way getpwent(3C) routines handle the regular password file, (/etc/passwd).

These routines are particularly useful in situations where it is not necessary to get information from the regular password file.  Getspwent(3C) routines run significantly faster than getpwent(3C) routines because they avoid unnecessary scanning of the password file and use of Yellow Pages.

Getspwent, getspwuid, getspwaid, and getspwnam each return a pointer to an object.  The s_passwd structure is written in the /.secure/etc/passwd file, and consists of five fields per line, as follows:

struct s_passwd {
        char   ∗pw_name;  /* login name */
        char   ∗pw_passwd; /* encrypted password */
        char   ∗pw_age;/* password age */
        int      pw_audid;            /* audit ID   */
        int      pw_audflg;           /* audit flag 1=on, 0=off */
};

Since the s_passwd structure is declared in the <pwd.h> header file, it is unnecessary to redeclare it. 

When first called, getspwent returns a pointer to each s_passwd structure in /.secure/etc/passwd in sequence; subsequent calls can be used to search the entire file.  Getspwuid searches each entry from the beginning of the file until it finds a numerical user ID matching uid; then it returns a pointer to the particular structure in which uid is found.  Similarly, getspwaid searches for a numerical audit ID matching aid and returns a pointer to the particular structure in which aid is found. (See spasswd(4) for details on this field.) Getspwnam 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 name is found. 

A call to setspwent resets the file pointer to the beginning of the /.secure/etc/passwrd file to allow repeated searches.  Endspwent can be called to close the secure password file when processing is complete. 

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

DIAGNOSTICS

Getspwent returns a NULL pointer if any of these routines encounter an end-of-file or error while searching, or if the effective user ID of the calling process is not zero. 

WARNINGS

The above routines use <stdio.h>, which causes them to increase the size of programs by more than might be expected. 

Since all information is contained in a static area, it must be copied to be saved. 

AUTHOR

Getspwent was developed by HP. 

FILES

/.secure/etc/passwd

SEE ALSO

getgrent(3C), getlogin(3C), getpwent(3C), putspwent(3C), passwd(4), spasswd(4). 

ypcat(1) in HP-UX Networking Reference. 

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

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