spwd
— The 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 |
|
Login name |
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
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 ofKeyError
if the user doesn’t have privileges.PermissionError
而不是KeyError
。
-
spwd.
getspall
()¶ Return a list of all available shadow password database entries, in arbitrary order.以任意顺序返回所有可用的影子密码数据库条目的列表。