Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-grp.html" /> | |
13 | <link rel="prev" href="module-posix.html" /> | |
14 | <link rel="parent" href="unix.html" /> | |
15 | <link rel="next" href="module-grp.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>8.2 pwd -- The password database</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="8.1.2 Module Contents" | |
25 | href="posix-contents.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" | |
28 | href="unix.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="8.3 grp " | |
31 | href="module-grp.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="posix-contents.html">8.1.2 Module Contents</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="module-grp.html">8.3 grp </A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION0010200000000000000000"> | |
56 | 8.2 <tt class="module">pwd</tt> -- | |
57 | The password database</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-pwd"></A> | |
62 | <p class="availability">Availability: <span | |
63 | class="platform">Unix</span>.</p> | |
64 | ||
65 | <P> | |
66 | This module provides access to the <span class="Unix">Unix</span> user account and password | |
67 | database. It is available on all <span class="Unix">Unix</span> versions. | |
68 | ||
69 | <P> | |
70 | Password database entries are reported as a tuple-like object, whose | |
71 | attributes correspond to the members of the <code>passwd</code> structure | |
72 | (Attribute field below, see <code><pwd.h></code>): | |
73 | ||
74 | <P> | |
75 | <div class="center"><table class="realtable"> | |
76 | <thead> | |
77 | <tr> | |
78 | <th class="right" >Index</th> | |
79 | <th class="left" >Attribute</th> | |
80 | <th class="left" >Meaning</th> | |
81 | </tr> | |
82 | </thead> | |
83 | <tbody> | |
84 | <tr><td class="right" valign="baseline">0</td> | |
85 | <td class="left" ><code>pw_name</code></td> | |
86 | <td class="left" >Login name</td></tr> | |
87 | <tr><td class="right" valign="baseline">1</td> | |
88 | <td class="left" ><code>pw_passwd</code></td> | |
89 | <td class="left" >Optional encrypted password</td></tr> | |
90 | <tr><td class="right" valign="baseline">2</td> | |
91 | <td class="left" ><code>pw_uid</code></td> | |
92 | <td class="left" >Numerical user ID</td></tr> | |
93 | <tr><td class="right" valign="baseline">3</td> | |
94 | <td class="left" ><code>pw_gid</code></td> | |
95 | <td class="left" >Numerical group ID</td></tr> | |
96 | <tr><td class="right" valign="baseline">4</td> | |
97 | <td class="left" ><code>pw_gecos</code></td> | |
98 | <td class="left" >User name or comment field</td></tr> | |
99 | <tr><td class="right" valign="baseline">5</td> | |
100 | <td class="left" ><code>pw_dir</code></td> | |
101 | <td class="left" >User home directory</td></tr> | |
102 | <tr><td class="right" valign="baseline">6</td> | |
103 | <td class="left" ><code>pw_shell</code></td> | |
104 | <td class="left" >User command interpreter</td></tr></tbody> | |
105 | </table></div> | |
106 | ||
107 | <P> | |
108 | The uid and gid items are integers, all others are strings. | |
109 | <tt class="exception">KeyError</tt> is raised if the entry asked for cannot be found. | |
110 | ||
111 | <P> | |
112 | <span class="note"><b class="label">Note:</b> | |
113 | In traditional <span class="Unix">Unix</span> the field <code>pw_passwd</code> usually | |
114 | contains a password encrypted with a DES derived algorithm (see module | |
115 | <tt class="module"><a href="module-crypt.html">crypt</a></tt><a id='l2h-2973' xml:id='l2h-2973'></a>). However most modern unices | |
116 | use a so-called <em>shadow password</em> system. On those unices the | |
117 | <var>pw_passwd</var> field only contains an asterisk (<code>'*'</code>) or the | |
118 | letter "<tt class="character">x</tt>" where the encrypted password is stored in a file | |
119 | <span class="file">/etc/shadow</span> which is not world readable. Whether the <var>pw_passwd</var> | |
120 | field contains anything useful is system-dependent.</span> | |
121 | ||
122 | <P> | |
123 | It defines the following items: | |
124 | ||
125 | <P> | |
126 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
127 | <td><nobr><b><tt id='l2h-2974' xml:id='l2h-2974' class="function">getpwuid</tt></b>(</nobr></td> | |
128 | <td><var>uid</var>)</td></tr></table></dt> | |
129 | <dd> | |
130 | Return the password database entry for the given numeric user ID. | |
131 | </dl> | |
132 | ||
133 | <P> | |
134 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
135 | <td><nobr><b><tt id='l2h-2975' xml:id='l2h-2975' class="function">getpwnam</tt></b>(</nobr></td> | |
136 | <td><var>name</var>)</td></tr></table></dt> | |
137 | <dd> | |
138 | Return the password database entry for the given user name. | |
139 | </dl> | |
140 | ||
141 | <P> | |
142 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
143 | <td><nobr><b><tt id='l2h-2976' xml:id='l2h-2976' class="function">getpwall</tt></b>(</nobr></td> | |
144 | <td><var></var>)</td></tr></table></dt> | |
145 | <dd> | |
146 | Return a list of all available password database entries, in arbitrary order. | |
147 | </dl> | |
148 | ||
149 | <P> | |
150 | <div class="seealso"> | |
151 | <p class="heading">See Also:</p> | |
152 | ||
153 | <dl compact="compact" class="seemodule"> | |
154 | <dt>Module <b><tt class="module"><a href="module-grp.html">grp</a></tt>:</b> | |
155 | <dd>An interface to the group database, similar to this. | |
156 | </dl> | |
157 | </div> | |
158 | ||
159 | <DIV CLASS="navigation"> | |
160 | <div class='online-navigation'> | |
161 | <p></p><hr /> | |
162 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
163 | <tr> | |
164 | <td class='online-navigation'><a rel="prev" title="8.1.2 Module Contents" | |
165 | href="posix-contents.html"><img src='../icons/previous.png' | |
166 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
167 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" | |
168 | href="unix.html"><img src='../icons/up.png' | |
169 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
170 | <td class='online-navigation'><a rel="next" title="8.3 grp " | |
171 | href="module-grp.html"><img src='../icons/next.png' | |
172 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
173 | <td align="center" width="100%">Python Library Reference</td> | |
174 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
175 | href="contents.html"><img src='../icons/contents.png' | |
176 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
177 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
178 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
179 | <td class='online-navigation'><a rel="index" title="Index" | |
180 | href="genindex.html"><img src='../icons/index.png' | |
181 | border='0' height='32' alt='Index' width='32' /></A></td> | |
182 | </tr></table> | |
183 | <div class='online-navigation'> | |
184 | <b class="navlabel">Previous:</b> | |
185 | <a class="sectref" rel="prev" href="posix-contents.html">8.1.2 Module Contents</A> | |
186 | <b class="navlabel">Up:</b> | |
187 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> | |
188 | <b class="navlabel">Next:</b> | |
189 | <a class="sectref" rel="next" href="module-grp.html">8.3 grp </A> | |
190 | </div> | |
191 | </div> | |
192 | <hr /> | |
193 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
194 | </DIV> | |
195 | <!--End of Navigation Panel--> | |
196 | <ADDRESS> | |
197 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
198 | </ADDRESS> | |
199 | </BODY> | |
200 | </HTML> |