您的位置:首页 > 其它

Unix系统数据文件

2015-06-23 13:29 501 查看
UNIX系统的正常运行需要使用大量与系统有关的数据文件,例如口令文件/etc/passwd、组文件/etc/group、网路服务/etc/services、协议信息/etc/protocols、网络信息/etc/networks、主机数据/etc/hosts等。下面主要说明一下口令文件。

口令文件——

UNIX系统的口令文件在Linux上可能有下面一行:

root:x:0:0:root:/root:/bin/bash


上面各字段以冒号分割,与“pwd.h”中定义的passwd结构对应:

/* The passwd structure.  */
struct passwd
{
char *pw_name;                /* Username.  */
char *pw_passwd;              /* Password.  */
__uid_t pw_uid;               /* User ID.  */
__gid_t pw_gid;               /* Group ID.  */
char *pw_gecos;               /* Real name.  */
char *pw_dir;                 /* Home directory.  */
char *pw_shell;               /* Shell program.  */
};


加密口令字段包含了一个占位符x,在早期的UNIX系统版本中,该字段存放加密口令,将加密口令存放在一个人人可读的文件中构成了一个安全性漏洞,所以现在将加密口令存放在另一个位置,下文提到的阴影口令。

在某些系统上,查看口令文件可使用finger命令,编辑口令文件可使用vipw命令。

阴影口令——

加密口令是经单向加密算法处理过的用户口令副本,在某些系统上,加密口令存放在另一个通常称为阴影口令的文件/etc/shadow中,“shadow.h”中定义了对应的spwd结构:

/* Structure of the password file.  */
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.  */
};


不同的类UNIX系统,存储加密口令的方式可能是不同的。

除了上文提到的数据文件,大多数UNIX系统还都提供了utmp和wtmp两个数据文件,前者记录当前登录进系统的各个用户,后者跟踪各个登录和注销事件。另外,系统标识信息、时间和日期数据也是必不可少的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: