1SHADOW(3)                        Library Calls                       SHADOW(3)
2
3
4

NAME

6       shadow, getspnam - encrypted password file routines
7

SYNTAX

9       #include <shadow.h>
10
11       struct spwd *getspent();
12
13       struct spwd *getspnam(char *name);
14
15       void setspent();
16
17       void endspent();
18
19       struct spwd *fgetspent(FILE *fp);
20
21       struct spwd *sgetspent(char *cp);
22
23       int putspent(struct spwd *p, FILE *fp);
24
25       int lckpwdf();
26
27       int ulckpwdf();
28

DESCRIPTION

30       shadow manipulates the contents of the shadow password file,
31       /etc/shadow. The structure in the #include file is:
32
33          struct spwd {
34                char          *sp_namp; /* user login name */
35                char          *sp_pwdp; /* encrypted password */
36                long int      sp_lstchg; /* last password change */
37                long int      sp_min; /* days until change allowed. */
38                long int      sp_max; /* days before change required */
39                long int      sp_warn; /* days warning for expiration */
40                long int      sp_inact; /* days before account inactive */
41                long int      sp_expire; /* date when account expires */
42                unsigned long int  sp_flag; /* reserved for future use */
43          }
44
45
46       The meanings of each field are:
47
48       ·  sp_namp - pointer to null-terminated user name
49
50       ·  sp_pwdp - pointer to null-terminated password
51
52       ·  sp_lstchg - days since Jan 1, 1970 password was last changed
53
54       ·  sp_min - days before which password may not be changed
55
56       ·  sp_max - days after which password must be changed
57
58       ·  sp_warn - days before password is to expire that user is warned of
59          pending password expiration
60
61       ·  sp_inact - days after password expires that account is considered
62          inactive and disabled
63
64       ·  sp_expire - days since Jan 1, 1970 when account will be disabled
65
66       ·  sp_flag - reserved for future use
67

DESCRIPTION

69       getspent, getspname, fgetspent, and sgetspent each return a pointer to
70       a struct spwd.  getspent returns the next entry from the file, and
71       fgetspent returns the next entry from the given stream, which is
72       assumed to be a file of the proper format.  sgetspent returns a pointer
73       to a struct spwd using the provided string as input.  getspnam searches
74       from the current position in the file for an entry matching name.
75
76       setspent and endspent may be used to begin and end, respectively,
77       access to the shadow password file.
78
79       The lckpwdf and ulckpwdf routines should be used to insure exclusive
80       access to the /etc/shadow file.  lckpwdf attempts to acquire a lock
81       using pw_lock for up to 15 seconds. It continues by attempting to
82       acquire a second lock using spw_lock for the remainder of the initial
83       15 seconds. Should either attempt fail after a total of 15 seconds,
84       lckpwdf returns -1. When both locks are acquired 0 is returned.
85

DIAGNOSTICS

87       Routines return NULL if no more entries are available or if an error
88       occurs during processing. Routines which have int as the return value
89       return 0 for success and -1 for failure.
90

CAVEATS

92       These routines may only be used by the super user as access to the
93       shadow password file is restricted.
94

FILES

96       /etc/shadow
97          Secure user account information.
98

SEE ALSO

100       getpwent(3), shadow(5).
101
102
103
104Library Calls                     07/30/2006                         SHADOW(3)
Impressum