1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>35.2. pwd — The password database — Python 3.5.1 documentation</title>
11
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/sidebar.js"></script>
27
<link rel="search" type="application/opensearchdescription+xml"
28
title="Search within Python 3.5.1 documentation"
29
href="../_static/opensearch.xml"/>
30
<link rel="author" title="About these documents" href="../about.html" />
31
<link rel="copyright" title="Copyright" href="../copyright.html" />
32
<link rel="top" title="Python 3.5.1 documentation" href="../contents.html" />
33
<link rel="up" title="35. Unix Specific Services" href="unix.html" />
34
<link rel="next" title="35.3. spwd — The shadow password database" href="spwd.html" />
35
<link rel="prev" title="35.1. posix — The most common POSIX system calls" href="posix.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="spwd.html" title="35.3. spwd — The shadow password database"
55
accesskey="N">next</a> |</li>
57
<a href="posix.html" title="35.1. posix — The most common POSIX system calls"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">3.5.1</span>
64
<a href="../index.html">Documentation </a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
68
<li class="nav-item nav-item-2"><a href="unix.html" accesskey="U">35. Unix Specific Services</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="module-pwd">
78
<span id="pwd-the-password-database"></span><h1>35.2. <a class="reference internal" href="#module-pwd" title="pwd: The password database (getpwnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">pwd</span></code></a> — The password database<a class="headerlink" href="#module-pwd" title="Permalink to this headline">¶</a></h1>
79
<p>This module provides access to the Unix user account and password database. It
80
is available on all Unix versions.</p>
81
<p>Password database entries are reported as a tuple-like object, whose attributes
82
correspond to the members of the <code class="docutils literal"><span class="pre">passwd</span></code> structure (Attribute field below,
83
see <code class="docutils literal"><span class="pre"><pwd.h></span></code>):</p>
84
<table border="1" class="docutils">
90
<thead valign="bottom">
91
<tr class="row-odd"><th class="head">Index</th>
92
<th class="head">Attribute</th>
93
<th class="head">Meaning</th>
97
<tr class="row-even"><td>0</td>
98
<td><code class="docutils literal"><span class="pre">pw_name</span></code></td>
101
<tr class="row-odd"><td>1</td>
102
<td><code class="docutils literal"><span class="pre">pw_passwd</span></code></td>
103
<td>Optional encrypted password</td>
105
<tr class="row-even"><td>2</td>
106
<td><code class="docutils literal"><span class="pre">pw_uid</span></code></td>
107
<td>Numerical user ID</td>
109
<tr class="row-odd"><td>3</td>
110
<td><code class="docutils literal"><span class="pre">pw_gid</span></code></td>
111
<td>Numerical group ID</td>
113
<tr class="row-even"><td>4</td>
114
<td><code class="docutils literal"><span class="pre">pw_gecos</span></code></td>
115
<td>User name or comment field</td>
117
<tr class="row-odd"><td>5</td>
118
<td><code class="docutils literal"><span class="pre">pw_dir</span></code></td>
119
<td>User home directory</td>
121
<tr class="row-even"><td>6</td>
122
<td><code class="docutils literal"><span class="pre">pw_shell</span></code></td>
123
<td>User command interpreter</td>
127
<p>The uid and gid items are integers, all others are strings. <a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal"><span class="pre">KeyError</span></code></a> is
128
raised if the entry asked for cannot be found.</p>
129
<div class="admonition note">
130
<p class="first admonition-title">Note</p>
131
<p class="last" id="index-0">In traditional Unix the field <code class="docutils literal"><span class="pre">pw_passwd</span></code> usually contains a password
132
encrypted with a DES derived algorithm (see module <a class="reference internal" href="crypt.html#module-crypt" title="crypt: The crypt() function used to check Unix passwords. (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">crypt</span></code></a>). However most
133
modern unices use a so-called <em>shadow password</em> system. On those unices the
134
<em>pw_passwd</em> field only contains an asterisk (<code class="docutils literal"><span class="pre">'*'</span></code>) or the letter <code class="docutils literal"><span class="pre">'x'</span></code>
135
where the encrypted password is stored in a file <code class="file docutils literal"><span class="pre">/etc/shadow</span></code> which is
136
not world readable. Whether the <em>pw_passwd</em> field contains anything useful is
137
system-dependent. If available, the <a class="reference internal" href="spwd.html#module-spwd" title="spwd: The shadow password database (getspnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">spwd</span></code></a> module should be used where
138
access to the encrypted password is required.</p>
140
<p>It defines the following items:</p>
141
<dl class="function">
142
<dt id="pwd.getpwuid">
143
<code class="descclassname">pwd.</code><code class="descname">getpwuid</code><span class="sig-paren">(</span><em>uid</em><span class="sig-paren">)</span><a class="headerlink" href="#pwd.getpwuid" title="Permalink to this definition">¶</a></dt>
144
<dd><p>Return the password database entry for the given numeric user ID.</p>
147
<dl class="function">
148
<dt id="pwd.getpwnam">
149
<code class="descclassname">pwd.</code><code class="descname">getpwnam</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#pwd.getpwnam" title="Permalink to this definition">¶</a></dt>
150
<dd><p>Return the password database entry for the given user name.</p>
153
<dl class="function">
154
<dt id="pwd.getpwall">
155
<code class="descclassname">pwd.</code><code class="descname">getpwall</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pwd.getpwall" title="Permalink to this definition">¶</a></dt>
156
<dd><p>Return a list of all available password database entries, in arbitrary order.</p>
159
<div class="admonition seealso">
160
<p class="first admonition-title">See also</p>
161
<dl class="last docutils">
162
<dt>Module <a class="reference internal" href="grp.html#module-grp" title="grp: The group database (getgrnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">grp</span></code></a></dt>
163
<dd>An interface to the group database, similar to this.</dd>
164
<dt>Module <a class="reference internal" href="spwd.html#module-spwd" title="spwd: The shadow password database (getspnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">spwd</span></code></a></dt>
165
<dd>An interface to the shadow password database, similar to this.</dd>
174
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
175
<div class="sphinxsidebarwrapper">
176
<h4>Previous topic</h4>
177
<p class="topless"><a href="posix.html"
178
title="previous chapter">35.1. <code class="docutils literal"><span class="pre">posix</span></code> — The most common POSIX system calls</a></p>
180
<p class="topless"><a href="spwd.html"
181
title="next chapter">35.3. <code class="docutils literal"><span class="pre">spwd</span></code> — The shadow password database</a></p>
183
<ul class="this-page-menu">
184
<li><a href="../bugs.html">Report a Bug</a></li>
185
<li><a href="../_sources/library/pwd.txt"
186
rel="nofollow">Show Source</a></li>
189
<div id="searchbox" style="display: none" role="search">
190
<h3>Quick search</h3>
191
<form class="search" action="../search.html" method="get">
192
<input type="text" name="q" />
193
<input type="submit" value="Go" />
194
<input type="hidden" name="check_keywords" value="yes" />
195
<input type="hidden" name="area" value="default" />
197
<p class="searchtip" style="font-size: 90%">
198
Enter search terms or a module, class or function name.
201
<script type="text/javascript">$('#searchbox').show(0);</script>
204
<div class="clearer"></div>
206
<div class="related" role="navigation" aria-label="related navigation">
209
<li class="right" style="margin-right: 10px">
210
<a href="../genindex.html" title="General Index"
213
<a href="../py-modindex.html" title="Python Module Index"
216
<a href="spwd.html" title="35.3. spwd — The shadow password database"
219
<a href="posix.html" title="35.1. posix — The most common POSIX system calls"
221
<li><img src="../_static/py.png" alt=""
222
style="vertical-align: middle; margin-top: -1px"/></li>
223
<li><a href="https://www.python.org/">Python</a> »</li>
225
<span class="version_switcher_placeholder">3.5.1</span>
226
<a href="../index.html">Documentation </a> »
229
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
230
<li class="nav-item nav-item-2"><a href="unix.html" >35. Unix Specific Services</a> »</li>
234
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
236
The Python Software Foundation is a non-profit corporation.
237
<a href="https://www.python.org/psf/donations/">Please donate.</a>
239
Last updated on Jan 22, 2016.
240
<a href="../bugs.html">Found a bug</a>?
242
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'