blob: 57f160a96f3d27f67b6c6aec853fd7e87d54fbcf [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
33to get complete membership information.)
34
35It defines the following items:
36
37
38.. function:: getgrgid(gid)
39
40 Return the group database entry for the given numeric group ID. :exc:`KeyError`
41 is raised if the entry asked for cannot be found.
42
43
44.. function:: getgrnam(name)
45
46 Return the group database entry for the given group name. :exc:`KeyError` is
47 raised if the entry asked for cannot be found.
48
49
50.. function:: getgrall()
51
52 Return a list of all available group entries, in arbitrary order.
53
54
55.. seealso::
56
57 Module :mod:`pwd`
58 An interface to the user database, similar to this.
59
60 Module :mod:`spwd`
61 An interface to the shadow password database, similar to this.
62