[2] | 1 |
|
---|
| 2 | :mod:`grp` --- The group database
|
---|
| 3 | =================================
|
---|
| 4 |
|
---|
| 5 | .. module:: grp
|
---|
| 6 | :platform: Unix
|
---|
| 7 | :synopsis: The group database (getgrnam() and friends).
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | This module provides access to the Unix group database. It is available on all
|
---|
| 11 | Unix versions.
|
---|
| 12 |
|
---|
| 13 | Group database entries are reported as a tuple-like object, whose attributes
|
---|
| 14 | correspond 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 |
|
---|
| 31 | The gid is an integer, name and password are strings, and the member list is a
|
---|
| 32 | list of strings. (Note that most users are not explicitly listed as members of
|
---|
| 33 | the group they are in according to the password database. Check both databases
|
---|
[391] | 34 | to get complete membership information. Also note that a ``gr_name`` that
|
---|
| 35 | starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be
|
---|
| 36 | accessible via :func:`getgrnam` or :func:`getgrgid`.)
|
---|
[2] | 37 |
|
---|
| 38 | It defines the following items:
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | .. function:: getgrgid(gid)
|
---|
| 42 |
|
---|
| 43 | Return the group database entry for the given numeric group ID. :exc:`KeyError`
|
---|
| 44 | is raised if the entry asked for cannot be found.
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | .. function:: getgrnam(name)
|
---|
| 48 |
|
---|
| 49 | Return the group database entry for the given group name. :exc:`KeyError` is
|
---|
| 50 | raised if the entry asked for cannot be found.
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | .. function:: getgrall()
|
---|
| 54 |
|
---|
| 55 | Return a list of all available group entries, in arbitrary order.
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | .. seealso::
|
---|
| 59 |
|
---|
| 60 | Module :mod:`pwd`
|
---|
| 61 | An interface to the user database, similar to this.
|
---|
| 62 |
|
---|
| 63 | Module :mod:`spwd`
|
---|
| 64 | An interface to the shadow password database, similar to this.
|
---|
| 65 |
|
---|