blob: 473fc5e37cec005a8404a36d6596169adfafb121 [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
Martin v. Löwisdbd55b32002-03-01 10:38:44 +000012Group database entries are reported as a tuple-like object, whose
13attributes correspond to the members of the \code{group} structure
14(Attribute field below, see \code{<pwd.h>}):
Fred Drake38e5d272000-04-03 20:13:55 +000015
Martin v. Löwisdbd55b32002-03-01 10:38:44 +000016\begin{tableiii}{r|l|l}{textrm}{Index}{Attribute}{Meaning}
Fred Drake38e5d272000-04-03 20:13:55 +000017 \lineiii{0}{gr_name}{the name of the group}
18 \lineiii{1}{gr_passwd}{the (encrypted) group password; often empty}
19 \lineiii{2}{gr_gid}{the numerical group ID}
20 \lineiii{3}{gr_mem}{all the group member's user names}
21\end{tableiii}
22
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000023The gid is an integer, name and password are strings, and the member
24list is a list of strings.
25(Note that most users are not explicitly listed as members of the
Fred Drake146b2802000-07-08 16:59:03 +000026group they are in according to the password database. Check both
27databases to get complete membership information.)
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000028
29It defines the following items:
30
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000031\begin{funcdesc}{getgrgid}{gid}
32Return the group database entry for the given numeric group ID.
Fred Drake146b2802000-07-08 16:59:03 +000033\exception{KeyError} is raised if the entry asked for cannot be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000034\end{funcdesc}
35
36\begin{funcdesc}{getgrnam}{name}
37Return the group database entry for the given group name.
Fred Drake146b2802000-07-08 16:59:03 +000038\exception{KeyError} is raised if the entry asked for cannot be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000039\end{funcdesc}
40
41\begin{funcdesc}{getgrall}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000042Return a list of all available group entries, in arbitrary order.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000043\end{funcdesc}
Fred Drake38e5d272000-04-03 20:13:55 +000044
45
46\begin{seealso}
47 \seemodule{pwd}{An interface to the user database, similar to this.}
48\end{seealso}