blob: ae2551b4d465924320f7fb1c8800b4d74fce339b [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{pwd} ---
Fred Drakef6863c11999-03-02 16:37:17 +00002 The password database}
3
Fred Drakeb91e9341998-07-23 17:59:49 +00004\declaremodule{builtin}{pwd}
Fred Drakea54a8871999-03-02 17:03:42 +00005 \platform{Unix}
Fred Drakeb91e9341998-07-23 17:59:49 +00006\modulesynopsis{The password database (\function{getpwnam()} and friends).}
7
Fred Drake38e5d272000-04-03 20:13:55 +00008This module provides access to the \UNIX{} user account and password
9database. It is available on all \UNIX{} versions.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000010
11Password database entries are reported as 7-tuples containing the
Fred Drakea5aefba1998-08-14 17:05:17 +000012following items from the password database (see \code{<pwd.h>}), in order:
Fred Drake38e5d272000-04-03 20:13:55 +000013
14\begin{tableiii}{r|l|l}{textrm}{Index}{Field}{Meaning}
15 \lineiii{0}{\code{pw_name}}{Login name}
16 \lineiii{1}{\code{pw_passwd}}{Optional encrypted password}
17 \lineiii{2}{\code{pw_uid}}{Numerical user ID}
18 \lineiii{3}{\code{pw_gid}}{Numerical group ID}
19 \lineiii{4}{\code{pw_gecos}}{User name or comment field}
20 \lineiii{5}{\code{pw_dir}}{User home directory}
21 \lineiii{6}{\code{pw_shell}}{User command interpreter}
22\end{tableiii}
23
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000024The uid and gid items are integers, all others are strings.
Fred Drakef6863c11999-03-02 16:37:17 +000025\exception{KeyError} is raised if the entry asked for cannot be found.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000026
Fred Drake0aa811c2001-10-20 04:24:09 +000027\note{In traditional \UNIX{} the field \code{pw_passwd} usually
Fred Drake38e5d272000-04-03 20:13:55 +000028contains a password encrypted with a DES derived algorithm (see module
29\refmodule{crypt}\refbimodindex{crypt}). However most modern unices
30use a so-called \emph{shadow password} system. On those unices the
31field \code{pw_passwd} only contains a asterisk (\code{'*'}) or the
32letter \character{x} where the encrypted password is stored in a file
Fred Drake0aa811c2001-10-20 04:24:09 +000033\file{/etc/shadow} which is not world readable.}
Fred Drake38e5d272000-04-03 20:13:55 +000034
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000035It defines the following items:
36
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000037\begin{funcdesc}{getpwuid}{uid}
38Return the password database entry for the given numeric user ID.
39\end{funcdesc}
40
41\begin{funcdesc}{getpwnam}{name}
42Return the password database entry for the given user name.
43\end{funcdesc}
44
45\begin{funcdesc}{getpwall}{}
46Return a list of all available password database entries, in arbitrary order.
47\end{funcdesc}
Fred Drake38e5d272000-04-03 20:13:55 +000048
49
50\begin{seealso}
51 \seemodule{grp}{An interface to the group database, similar to this.}
52\end{seealso}