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