blob: 88821406a33d690ae774321fcc920e9754208f99 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001:mod:`grp` --- The group database
2=================================
3
4.. module:: grp
5 :platform: Unix
6 :synopsis: The group database (getgrnam() and friends).
7
8
9This module provides access to the Unix group database. It is available on all
10Unix versions.
11
12Group database entries are reported as a tuple-like object, whose attributes
13correspond to the members of the ``group`` structure (Attribute field below, see
14``<pwd.h>``):
15
16+-------+-----------+---------------------------------+
17| Index | Attribute | Meaning |
18+=======+===========+=================================+
19| 0 | gr_name | the name of the group |
20+-------+-----------+---------------------------------+
21| 1 | gr_passwd | the (encrypted) group password; |
22| | | often empty |
23+-------+-----------+---------------------------------+
24| 2 | gr_gid | the numerical group ID |
25+-------+-----------+---------------------------------+
26| 3 | gr_mem | all the group member's user |
27| | | names |
28+-------+-----------+---------------------------------+
29
30The gid is an integer, name and password are strings, and the member list is a
31list of strings. (Note that most users are not explicitly listed as members of
32the group they are in according to the password database. Check both databases
R. David Murrayec073312010-12-14 16:20:53 +000033to get complete membership information. Also note that a ``gr_name`` that
34starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be
35accessible via :func:`getgrnam` or :func:`getgrgid`.)
Georg Brandl116aa622007-08-15 14:28:22 +000036
37It defines the following items:
38
39
40.. function:: getgrgid(gid)
41
42 Return the group database entry for the given numeric group ID. :exc:`KeyError`
43 is raised if the entry asked for cannot be found.
44
45
46.. function:: getgrnam(name)
47
48 Return the group database entry for the given group name. :exc:`KeyError` is
49 raised if the entry asked for cannot be found.
50
51
52.. function:: getgrall()
53
54 Return a list of all available group entries, in arbitrary order.
55
56
57.. seealso::
58
59 Module :mod:`pwd`
60 An interface to the user database, similar to this.
61
62 Module :mod:`spwd`
63 An interface to the shadow password database, similar to this.
64