blob: 828608199a13dec5100d33b1677afae39c576b0b [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{grp} ---
Fred Drakef6863c11999-03-02 16:37:17 +00002 The group database}
3
Fred Drakeb91e9341998-07-23 17:59:49 +00004\declaremodule{builtin}{grp}
Fred Drakea54a8871999-03-02 17:03:42 +00005 \platform{Unix}
Fred Drakeb91e9341998-07-23 17:59:49 +00006\modulesynopsis{The group database (\function{getgrnam()} and friends).}
7
Fred Drakef6863c11999-03-02 16:37:17 +00008
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00009This module provides access to the \UNIX{} group database.
10It is available on all \UNIX{} versions.
11
12Group database entries are reported as 4-tuples containing the
Fred Drakea5aefba1998-08-14 17:05:17 +000013following items from the group database (see \code{<grp.h>}), in order:
Fred Drake38e5d272000-04-03 20:13:55 +000014
15\begin{tableiii}{r|l|l}{textrm}{Index}{Field}{Meaning}
16 \lineiii{0}{gr_name}{the name of the group}
17 \lineiii{1}{gr_passwd}{the (encrypted) group password; often empty}
18 \lineiii{2}{gr_gid}{the numerical group ID}
19 \lineiii{3}{gr_mem}{all the group member's user names}
20\end{tableiii}
21
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000022The gid is an integer, name and password are strings, and the member
23list is a list of strings.
24(Note that most users are not explicitly listed as members of the
Fred Drake146b2802000-07-08 16:59:03 +000025group they are in according to the password database. Check both
26databases to get complete membership information.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000027
28It defines the following items:
29
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000030\begin{funcdesc}{getgrgid}{gid}
31Return the group database entry for the given numeric group ID.
Fred Drake146b2802000-07-08 16:59:03 +000032\exception{KeyError} is raised if the entry asked for cannot be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000033\end{funcdesc}
34
35\begin{funcdesc}{getgrnam}{name}
36Return the group database entry for the given group name.
Fred Drake146b2802000-07-08 16:59:03 +000037\exception{KeyError} is raised if the entry asked for cannot be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000038\end{funcdesc}
39
40\begin{funcdesc}{getgrall}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000041Return a list of all available group entries, in arbitrary order.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000042\end{funcdesc}
Fred Drake38e5d272000-04-03 20:13:55 +000043
44
45\begin{seealso}
46 \seemodule{pwd}{An interface to the user database, similar to this.}
47\end{seealso}