~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-3.5.1-docs-html/library/pwd.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
 
4
 
 
5
 
<html xmlns="http://www.w3.org/1999/xhtml">
6
 
  <head>
7
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
 
    
9
 
    <title>35.2. pwd — The password database &mdash; Python 3.5.1 documentation</title>
10
 
    
11
 
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
12
 
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
13
 
    
14
 
    <script type="text/javascript">
15
 
      var DOCUMENTATION_OPTIONS = {
16
 
        URL_ROOT:    '../',
17
 
        VERSION:     '3.5.1',
18
 
        COLLAPSE_INDEX: false,
19
 
        FILE_SUFFIX: '.html',
20
 
        HAS_SOURCE:  true
21
 
      };
22
 
    </script>
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>
39
 
    
40
 
 
41
 
 
42
 
  </head>
43
 
  <body role="document">  
44
 
    <div class="related" role="navigation" aria-label="related navigation">
45
 
      <h3>Navigation</h3>
46
 
      <ul>
47
 
        <li class="right" style="margin-right: 10px">
48
 
          <a href="../genindex.html" title="General Index"
49
 
             accesskey="I">index</a></li>
50
 
        <li class="right" >
51
 
          <a href="../py-modindex.html" title="Python Module Index"
52
 
             >modules</a> |</li>
53
 
        <li class="right" >
54
 
          <a href="spwd.html" title="35.3. spwd — The shadow password database"
55
 
             accesskey="N">next</a> |</li>
56
 
        <li class="right" >
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> &raquo;</li>
62
 
        <li>
63
 
          <span class="version_switcher_placeholder">3.5.1</span>
64
 
          <a href="../index.html">Documentation </a> &raquo;
65
 
        </li>
66
 
 
67
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
68
 
          <li class="nav-item nav-item-2"><a href="unix.html" accesskey="U">35. Unix Specific Services</a> &raquo;</li> 
69
 
      </ul>
70
 
    </div>    
71
 
 
72
 
    <div class="document">
73
 
      <div class="documentwrapper">
74
 
        <div class="bodywrapper">
75
 
          <div class="body" role="main">
76
 
            
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> &#8212; 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">&lt;pwd.h&gt;</span></code>):</p>
84
 
<table border="1" class="docutils">
85
 
<colgroup>
86
 
<col width="14%" />
87
 
<col width="29%" />
88
 
<col width="57%" />
89
 
</colgroup>
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>
94
 
</tr>
95
 
</thead>
96
 
<tbody valign="top">
97
 
<tr class="row-even"><td>0</td>
98
 
<td><code class="docutils literal"><span class="pre">pw_name</span></code></td>
99
 
<td>Login name</td>
100
 
</tr>
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>
104
 
</tr>
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>
108
 
</tr>
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>
112
 
</tr>
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>
116
 
</tr>
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>
120
 
</tr>
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>
124
 
</tr>
125
 
</tbody>
126
 
</table>
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>
139
 
</div>
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>
145
 
</dd></dl>
146
 
 
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>
151
 
</dd></dl>
152
 
 
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>
157
 
</dd></dl>
158
 
 
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>
166
 
</dl>
167
 
</div>
168
 
</div>
169
 
 
170
 
 
171
 
          </div>
172
 
        </div>
173
 
      </div>
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> &#8212; The most common POSIX system calls</a></p>
179
 
  <h4>Next topic</h4>
180
 
  <p class="topless"><a href="spwd.html"
181
 
                        title="next chapter">35.3. <code class="docutils literal"><span class="pre">spwd</span></code> &#8212; The shadow password database</a></p>
182
 
<h3>This Page</h3>
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>
187
 
</ul>
188
 
 
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" />
196
 
    </form>
197
 
    <p class="searchtip" style="font-size: 90%">
198
 
    Enter search terms or a module, class or function name.
199
 
    </p>
200
 
</div>
201
 
<script type="text/javascript">$('#searchbox').show(0);</script>
202
 
        </div>
203
 
      </div>
204
 
      <div class="clearer"></div>
205
 
    </div>  
206
 
    <div class="related" role="navigation" aria-label="related navigation">
207
 
      <h3>Navigation</h3>
208
 
      <ul>
209
 
        <li class="right" style="margin-right: 10px">
210
 
          <a href="../genindex.html" title="General Index"
211
 
             >index</a></li>
212
 
        <li class="right" >
213
 
          <a href="../py-modindex.html" title="Python Module Index"
214
 
             >modules</a> |</li>
215
 
        <li class="right" >
216
 
          <a href="spwd.html" title="35.3. spwd — The shadow password database"
217
 
             >next</a> |</li>
218
 
        <li class="right" >
219
 
          <a href="posix.html" title="35.1. posix — The most common POSIX system calls"
220
 
             >previous</a> |</li>
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> &raquo;</li>
224
 
        <li>
225
 
          <span class="version_switcher_placeholder">3.5.1</span>
226
 
          <a href="../index.html">Documentation </a> &raquo;
227
 
        </li>
228
 
 
229
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
230
 
          <li class="nav-item nav-item-2"><a href="unix.html" >35. Unix Specific Services</a> &raquo;</li> 
231
 
      </ul>
232
 
    </div>  
233
 
    <div class="footer">
234
 
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
235
 
    <br />
236
 
    The Python Software Foundation is a non-profit corporation.
237
 
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
238
 
    <br />
239
 
    Last updated on Jan 22, 2016.
240
 
    <a href="../bugs.html">Found a bug</a>?
241
 
    <br />
242
 
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
243
 
    </div>
244
 
 
245
 
  </body>
246
 
</html>
 
 
b'\\ No newline at end of file'