pwdThe password database密码数据库


This module provides access to the Unix user account and password database. 此模块提供对Unix用户帐户和密码数据库的访问。It is available on all Unix versions.它在所有Unix版本上都可用。

Password database entries are reported as a tuple-like object, whose attributes correspond to the members of the passwd structure (Attribute field below, see <pwd.h>):密码数据库条目报告为类似元组的对象,其属性对应于passwd结构的成员(下面的属性字段,请参阅<pwd.h>):

Index

Attribute

Meaning

0

pw_name

Login name

1

pw_passwd

Optional encrypted password可选加密密码

2

pw_uid

Numerical user ID数字用户ID

3

pw_gid

Numerical group ID数字组ID

4

pw_gecos

User name or comment field用户名或注释字段

5

pw_dir

User home directory用户主目录

6

pw_shell

User command interpreter用户命令解释器

The uid and gid items are integers, all others are strings. uid和gid项是整数,其他项都是字符串。KeyError is raised if the entry asked for cannot be found.如果找不到要求的条目,则引发KeyError

Note

In traditional Unix the field pw_passwd usually contains a password encrypted with a DES derived algorithm (see module crypt). However most modern unices use a so-called shadow password system. 在传统的Unix中,字段pw_passwd通常包含一个用DES派生算法加密的密码(见模块crypt)。然而,大多数现代unices都使用所谓的影子密码系统。On those unices the pw_passwd field only contains an asterisk ('*') or the letter 'x' where the encrypted password is stored in a file /etc/shadow which is not world readable. 在这些unices上,pw_passwd字段只包含星号('*')或字母'x',其中加密密码存储在一个不可读的文件/etc/shadow中。Whether the pw_passwd field contains anything useful is system-dependent. pw_passwd字段是否包含有用的内容取决于系统。If available, the spwd module should be used where access to the encrypted password is required.如果可用,应在需要访问加密密码的地方使用spwd模块。

It defines the following items:它定义了以下项目:

pwd.getpwuid(uid)

Return the password database entry for the given numeric user ID.返回给定数字用户ID的密码数据库条目。

pwd.getpwnam(name)

Return the password database entry for the given user name.返回给定用户名的密码数据库条目。

pwd.getpwall()

Return a list of all available password database entries, in arbitrary order.按任意顺序返回所有可用密码数据库条目的列表。

See also

Module grp

An interface to the group database, similar to this.组数据库的接口,类似于此。

Module spwd

An interface to the shadow password database, similar to this.影子密码数据库的接口,类似于此。