spwdThe shadow password database影子密码数据库

Deprecated since version 3.11: 自3.11版起已弃用:The spwd module is deprecated (see PEP 594 for details).spwd模块已弃用(有关详细信息,请参阅PEP 594)。


This module provides access to the Unix shadow password database. 此模块提供对Unix影子密码数据库的访问。It is available on various Unix versions.它可用于各种Unix版本。

You must have enough privileges to access the shadow password database (this usually means you have to be root).您必须具有足够的权限才能访问影子密码数据库(这通常意味着您必须是root用户)。

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

Index

Attribute

Meaning

0

sp_namp

Login name

1

sp_pwdp

Encrypted password加密的密码

2

sp_lstchg

Date of last change上次更改日期

3

sp_min

Minimal number of days between changes更改之间的最小天数

4

sp_max

Maximum number of days between changes更改之间的最大天数

5

sp_warn

Number of days before password expires to warn user about it密码过期警告用户的天数

6

sp_inact

Number of days after password expires until account is disabled密码过期后直到禁用帐户的天数

7

sp_expire

Number of days since 1970-01-01 when account expires自1970-01-01账户到期后的天数

8

sp_flag

Reserved

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

The following functions are defined:定义了以下功能:

spwd.getspnam(name)

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

Changed in version 3.6:版本3.6中更改: Raises a PermissionError instead of KeyError if the user doesn’t have privileges.如果用户没有权限,则引发PermissionError而不是KeyError

spwd.getspall()

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

See also

Module grp

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

Module pwd

An interface to the normal password database, similar to this.与此类似的普通密码数据库接口。