Added section on passing contextual information to logging and documentation for...
[python.git] / Doc / library / spwd.rst
blob6cbe925b25d21a9d977fc3d7bce76bd1d02b09ad
2 :mod:`spwd` --- The shadow password database
3 ============================================
5 .. module:: spwd
6    :platform: Unix
7    :synopsis: The shadow password database (getspnam() and friends).
10 .. versionadded:: 2.5
12 This module provides access to the Unix shadow password database. It is
13 available on various Unix versions.
15 You must have enough privileges to access the shadow password database (this
16 usually means you have to be root).
18 Shadow password database entries are reported as a tuple-like object, whose
19 attributes correspond to the members of the ``spwd`` structure (Attribute field
20 below, see ``<shadow.h>``):
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 +-------+---------------+---------------------------------+
50 The 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.
53 It defines the following items:
56 .. function:: getspnam(name)
58    Return the shadow password database entry for the given user name.
61 .. function:: getspall()
63    Return a list of all available shadow password database entries, in arbitrary
64    order.
67 .. seealso::
69    Module :mod:`grp`
70       An interface to the group database, similar to this.
72    Module :mod:`pwd`
73       An interface to the normal password database, similar to this.