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

關於 /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;  /* 保留 */
};



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章