HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)

g
getspent(3C) getspent(3C)
NAME
getspent(), getspnam(), setspent(), endspent(), getspnam_r(), fgetspent() - access secure password entries
SYNOPSIS
#include <shadow.h>
struct spwd * getspent (void);
struct spwd * getspnam (const char *name);
void setspent (void);
void endspent (void);
struct spwd *fgetspent (FILE *stream);
struct spwd *getspnam_r (const char *name, struct spwd *result,
char *buffer, size_t bufsiz);
DESCRIPTION
The routines getspent() and getspnam() return a pointer to the next secured password entry. Each
entry is a spwd structure, declared in the shadow.h header file with the following members:
char *sp_namp; /* the user’s login name */
char *sp_pwdp; /* the encrypted password for the user */
long sp_lstchg; /* # of days from 1/1/70 when passwd was last modified */
long sp_min; /* min # of days allowed between password changes */
long sp_max; /* max # of days allowed between password changes */
long sp_warn; /* # of days before password expires and warning issued*/
long sp_inact; /* # of days between account inactive and disabled */
long sp_expire; /* # of days from 1/1/70 when account is locked */
unsigned long sp_flag;/* currently unused */
The getspent() routine returns a pointer to the first spwd structure when first called. Subsequent
calls return pointers to successive spwd structures. Repeated calls to getspent() can be used to search
all entries. The getspnam() routine searches password entries from beginning to end until a login name
matching name is found, and returns a pointer to that entry.
If the fields corresponding to
sp_min, sp_max, sp_lstchg , sp_warn, sp_inact ,or sp_expire
are not specified in the entry, they default to -1.
The setspent() routine is used to reset access to the secured password entries. After setspent() is
called, the subsequent call to
getspent() returns the first secured password entry. This mechanism is
used to allow repeated searches of the secured password entries. The endspent() routine is used to indi-
cate that processing of secured password entries is complete.
If libsec patch PHCO_27038 or later is not installed, then getspent() , getspnam() , setspent()
and endspent() are supported only on trusted systems; getspnam_r() and fgetspent() are not
supported. The secured password information is obtained from the Protected Password Database
(
/tcb/files/auth/*/*
).
If libsec patch PHCO_27038 or later is installed, then all of these functions are supported on standard sys-
tems, shadowed standard systems and trusted systems. The one exception to this is that
getspnam_r()
is not supported on trusted systems. On a standard system the secured password information is obtained
from /etc/passwd . If the system has been converted to a trusted system, then the secured password
information is obtained from the Protected Password Database (/tcb/files/auth/*/*
). If the sys-
tem has been converted to use shadow passwords, then the secured password information is obtained from
/etc/shadow . See shadow(4).
The getspnam_r() routine is available only if libsec patch PHCO_27038 or later is installed. This rou-
tine is similar to getspnam() , except that it is thread-safe, does not work on systems which have been
converted to trusted mode, and has three extra parameters. getspnam_r() updates the spwd struc-
ture pointed to by spwd and stores a pointer to that structure at the location pointed to by result. The
structure must contain an entry from the shadow password database with a matching name.Storage
referenced by the spwd structure pointed to by spwd is allocated from the memory provided with the
buffer parameter, which is buflen in size. A buffer length of 1024 is recommended. If an error occurs
or if the requested entry is not found, the result is NULL.
Section 3380 Hewlett-Packard Company 1 HP-UX 11i Version 1: September 2005