Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`grp` --- The group database |
| 2 | ================================= |
| 3 | |
| 4 | .. module:: grp |
| 5 | :platform: Unix |
| 6 | :synopsis: The group database (getgrnam() and friends). |
| 7 | |
| 8 | |
| 9 | This module provides access to the Unix group database. It is available on all |
| 10 | Unix versions. |
| 11 | |
| 12 | Group database entries are reported as a tuple-like object, whose attributes |
| 13 | correspond 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 | |
| 30 | The gid is an integer, name and password are strings, and the member list is a |
| 31 | list of strings. (Note that most users are not explicitly listed as members of |
| 32 | the group they are in according to the password database. Check both databases |
R. David Murray | ec07331 | 2010-12-14 16:20:53 +0000 | [diff] [blame^] | 33 | to get complete membership information. Also note that a ``gr_name`` that |
| 34 | starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be |
| 35 | accessible via :func:`getgrnam` or :func:`getgrgid`.) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 36 | |
| 37 | It 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 | |