Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{pwd} --- |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 2 | The password database} |
| 3 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 4 | \declaremodule{builtin}{pwd} |
Fred Drake | a54a887 | 1999-03-02 17:03:42 +0000 | [diff] [blame] | 5 | \platform{Unix} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 6 | \modulesynopsis{The password database (\function{getpwnam()} and friends).} |
| 7 | |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 8 | This module provides access to the \UNIX{} user account and password |
| 9 | database. It is available on all \UNIX{} versions. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 10 | |
| 11 | Password database entries are reported as 7-tuples containing the |
Fred Drake | a5aefba | 1998-08-14 17:05:17 +0000 | [diff] [blame] | 12 | following items from the password database (see \code{<pwd.h>}), in order: |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 13 | |
| 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 Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 24 | The uid and gid items are integers, all others are strings. |
Fred Drake | f6863c1 | 1999-03-02 16:37:17 +0000 | [diff] [blame] | 25 | \exception{KeyError} is raised if the entry asked for cannot be found. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 26 | |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 27 | \strong{Note:} In traditional \UNIX{} the field \code{pw_passwd} usually |
| 28 | contains a password encrypted with a DES derived algorithm (see module |
| 29 | \refmodule{crypt}\refbimodindex{crypt}). However most modern unices |
| 30 | use a so-called \emph{shadow password} system. On those unices the |
| 31 | field \code{pw_passwd} only contains a asterisk (\code{'*'}) or the |
| 32 | letter \character{x} where the encrypted password is stored in a file |
| 33 | \file{/etc/shadow} which is not world readable. |
| 34 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 35 | It defines the following items: |
| 36 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 37 | \begin{funcdesc}{getpwuid}{uid} |
| 38 | Return the password database entry for the given numeric user ID. |
| 39 | \end{funcdesc} |
| 40 | |
| 41 | \begin{funcdesc}{getpwnam}{name} |
| 42 | Return the password database entry for the given user name. |
| 43 | \end{funcdesc} |
| 44 | |
| 45 | \begin{funcdesc}{getpwall}{} |
| 46 | Return a list of all available password database entries, in arbitrary order. |
| 47 | \end{funcdesc} |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | \begin{seealso} |
| 51 | \seemodule{grp}{An interface to the group database, similar to this.} |
| 52 | \end{seealso} |