《UNIX高级环境编程》中没有给出struct passwd和struct spwd。查阅资料,如下:
struct passwd
{
char * pw_name; /* Username, POSIX.1 */
char * pw_passwd; /* Password */
__uid_t pw_uid; /* User ID, POSIX.1 */
__gid_t pw_gid; /* Group ID, POSIX.1 */
char * pw_gecos; /* Real Name or Comment field */
char * pw_dir; /* Home directory, POSIX.1 */
char * pw_shell; /* Shell Program, POSIX.1 */
};
struct spwd
{
char *sp_namp; /* Login name */
char *sp_pwdp; /* Encrypted password */
long int sp_lstchg; /* Date of last change */
long int sp_min; /* Minimum number of days between changes */
long int sp_max; /* Maximum number of days between changes */
long int sp_warn; /* Number of days to warn user to change the password */
long int sp_inact; /* Number of days the account may be inactive */
long int sp_expire; /* Number of days since 1970-01-01 until account expires */
unsigned long int sp_flag; /* Reserved */
};