cpython/Doc/lib/libpwd.tex

53 lines
1.9 KiB
TeX
Raw Normal View History

\section{\module{pwd} ---
1999-03-02 16:37:17 +00:00
The password database}
1999-03-02 16:37:17 +00:00
\declaremodule{builtin}{pwd}
\platform{Unix}
\modulesynopsis{The password database (\function{getpwnam()} and friends).}
1994-01-02 01:22:07 +00:00
This module provides access to the \UNIX{} user account and password
database. It is available on all \UNIX{} versions.
1994-01-02 01:22:07 +00:00
Password database entries are reported as 7-tuples containing the
following items from the password database (see \code{<pwd.h>}), in order:
\begin{tableiii}{r|l|l}{textrm}{Index}{Field}{Meaning}
\lineiii{0}{\code{pw_name}}{Login name}
\lineiii{1}{\code{pw_passwd}}{Optional encrypted password}
\lineiii{2}{\code{pw_uid}}{Numerical user ID}
\lineiii{3}{\code{pw_gid}}{Numerical group ID}
\lineiii{4}{\code{pw_gecos}}{User name or comment field}
\lineiii{5}{\code{pw_dir}}{User home directory}
\lineiii{6}{\code{pw_shell}}{User command interpreter}
\end{tableiii}
1994-01-02 01:22:07 +00:00
The uid and gid items are integers, all others are strings.
1999-03-02 16:37:17 +00:00
\exception{KeyError} is raised if the entry asked for cannot be found.
1994-01-02 01:22:07 +00:00
\strong{Note:} In traditional \UNIX{} the field \code{pw_passwd} usually
contains a password encrypted with a DES derived algorithm (see module
\refmodule{crypt}\refbimodindex{crypt}). However most modern unices
use a so-called \emph{shadow password} system. On those unices the
field \code{pw_passwd} only contains a asterisk (\code{'*'}) or the
letter \character{x} where the encrypted password is stored in a file
\file{/etc/shadow} which is not world readable.
1994-01-02 01:22:07 +00:00
It defines the following items:
\begin{funcdesc}{getpwuid}{uid}
Return the password database entry for the given numeric user ID.
\end{funcdesc}
\begin{funcdesc}{getpwnam}{name}
Return the password database entry for the given user name.
\end{funcdesc}
\begin{funcdesc}{getpwall}{}
Return a list of all available password database entries, in arbitrary order.
\end{funcdesc}
\begin{seealso}
\seemodule{grp}{An interface to the group database, similar to this.}
\end{seealso}