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