• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2:mod:`spwd` --- The shadow password database
3============================================
4
5.. module:: spwd
6   :platform: Unix
7   :synopsis: The shadow password database (getspnam() and friends).
8
9
10.. versionadded:: 2.5
11
12This module provides access to the Unix shadow password database. It is
13available on various Unix versions.
14
15You must have enough privileges to access the shadow password database (this
16usually means you have to be root).
17
18Shadow password database entries are reported as a tuple-like object, whose
19attributes correspond to the members of the ``spwd`` structure (Attribute field
20below, see ``<shadow.h>``):
21
22+-------+---------------+---------------------------------+
23| Index | Attribute     | Meaning                         |
24+=======+===============+=================================+
25| 0     | ``sp_nam``    | Login name                      |
26+-------+---------------+---------------------------------+
27| 1     | ``sp_pwd``    | Encrypted password              |
28+-------+---------------+---------------------------------+
29| 2     | ``sp_lstchg`` | Date of last change             |
30+-------+---------------+---------------------------------+
31| 3     | ``sp_min``    | Minimal number of days between  |
32|       |               | changes                         |
33+-------+---------------+---------------------------------+
34| 4     | ``sp_max``    | Maximum number of days between  |
35|       |               | changes                         |
36+-------+---------------+---------------------------------+
37| 5     | ``sp_warn``   | Number of days before password  |
38|       |               | expires to warn user about it   |
39+-------+---------------+---------------------------------+
40| 6     | ``sp_inact``  | Number of days after password   |
41|       |               | expires until account is        |
42|       |               | blocked                         |
43+-------+---------------+---------------------------------+
44| 7     | ``sp_expire`` | Number of days since 1970-01-01 |
45|       |               | until account is disabled       |
46+-------+---------------+---------------------------------+
47| 8     | ``sp_flag``   | Reserved                        |
48+-------+---------------+---------------------------------+
49
50The sp_nam and sp_pwd items are strings, all others are integers.
51:exc:`KeyError` is raised if the entry asked for cannot be found.
52
53It defines the following items:
54
55
56.. function:: getspnam(name)
57
58   Return the shadow password database entry for the given user name.
59
60
61.. function:: getspall()
62
63   Return a list of all available shadow password database entries, in arbitrary
64   order.
65
66
67.. seealso::
68
69   Module :mod:`grp`
70      An interface to the group database, similar to this.
71
72   Module :mod:`pwd`
73      An interface to the normal password database, similar to this.
74
75