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