关于 /etc/passwd :http://blog.csdn.net/u011641885/article/details/46368465
关于 /etc/shadpw :http://blog.csdn.net/u011641885/article/details/46681697
读取 /etc/passwd 的 API 为
struct passwd *getpwnam(const char *name); # 通过用户名
struct passwd *getpwuid(uid_t uid); # 通过 uid
struct passwd
{
char *pw_name; //用户名
char *pw_passwd; //用户密码
uid_t pw_uid; //用户id
uid_t pw_gid; //用户组id
char *pw_gecos; //用户描述
char *pw_dir; //用户家目录
char *pw_shell; //用户登录shell
};
读取 /etc/shadow 的 API 为
struct spwd *getspnam(const char *name); # 通过用户名
struct spwd {
char *sp_namp; /* 登录名 */
char *sp_pwdp; /* 加密口令 */
long sp_lstchg; /* 最后一次修改时间 */
long sp_min; /* 最小时间间隔 */
long sp_max; /* 最大时间间隔 */
long sp_warn; /* 警告时间 */
long sp_inact; /* 不活动时间 */
long sp_expire; /* 失效时间 */
unsigned long sp_flag; /* 保留 */
};