linux C 读取 /etc/passwd 和 /etc/shadow 文件 API

来源:互联网 发布:怎么做淘宝返利链接 编辑:程序博客网 时间:2024/06/02 02:30

关于 /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);# 通过 uidstruct 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;  /* 保留 */};



1 0
原创粉丝点击