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