Debian Codegraph @

Doc/library/grp.rst

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