第6章系统数据文件和信息总结

1 口令文件的shell字段

 如果是空,则使用系统默认的shell,一般是/bin/sh

 /dev/null:阻止对应的用户名登陆系统

 /bin/false:同样是阻止特定用户登录,以不成功状态终止

 /bin/true:阻止特定用户登录,以成功状态终止

2 获取口令文件内容的函数

 通过用户ID或用户名可以获取该用户在口令文件中的对应项

struct passwd* getpwuid(uid_t uid)

struct passwd* getpwnam(const char *name)

 获取整个口令文件内容:

struct passwd *getpwent()

 示例:

struct passwd *a;
printf("name\tpasswd\tshell\n");
while( (a = getpwent()) != NULL)
{
     printf("%s\t%s\t%s\n",a->pw_name,a->pw_passwd,a->pw_shell);
}
endpwent();

 调用getpwent函数时,一定要调用endpwent函数关闭

 在getpwent之前调用setpwent可以反绕口令文件,使定位到口令文件开始处,防止口令文件已经被getpwent掉用过

3 阴影口令

关于阴影口令有一组与口令文件类似的函数:

struct spwd *getspnam(const char *name)

struct spwd *getspent()

void setspent()

void endspent()

 

posted @ 2014-12-04 11:21  bupt_lyn  阅读(104)  评论(0编辑  收藏  举报