Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > by-pkgid > 0b7eb7009605a11593fbe388d7fbee61 > files > 518

python-docs-2.2-9.1mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>8.2 pwd -- The password database</title>
<META NAME="description" CONTENT="8.2 pwd -- The password database">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="lib.css">
<link rel="first" href="lib.html">
<link rel="contents" href="contents.html" title="Contents">
<link rel="index" href="genindex.html" title="Index">
<LINK REL="next" href="module-grp.html">
<LINK REL="previous" href="module-posix.html">
<LINK REL="up" href="unix.html">
<LINK REL="next" href="module-grp.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="posix-contents.html"><img src="../icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="unix.html"><img src="../icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-grp.html"><img src="../icons/next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html"><img src="../icons/contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" title="Module Index"><img src="../icons/modules.gif"
  border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html"><img src="../icons/index.gif"
  border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="posix-contents.html">8.1.2 Module Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" href="unix.html">8. Unix Specific Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-grp.html">8.3 grp  </A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0010200000000000000000">
8.2 <tt class="module">pwd</tt> --
         The password database</A>
</H1>

<P>
  
<p class="availability">Availability: <span
 class="platform">Unix</span>.</p>

<P>
This module provides access to the Unix user account and password
database.  It is available on all Unix versions.

<P>
Password database entries are reported as 7-tuples containing the
following items from the password database (see <code>&lt;pwd.h&gt;</code>), in order:

<P>
<table border align="center" style="border-collapse: collapse">
  <thead>
    <tr class="tableheader">
      <th align="right"><b>Index</b>&nbsp;</th>
      <th align="left"><b>Field</b>&nbsp;</th>
      <th align="left"><b>Meaning</b>&nbsp;</th>
      </tr>
    </thead>
  <tbody valign="baseline">
    <tr><td align="right" valign="baseline">0&nbsp;</td>
        <td align="left"><code>pw_name</code></td>
        <td align="left">Login name</td>
    <tr><td align="right" valign="baseline">1&nbsp;</td>
        <td align="left"><code>pw_passwd</code></td>
        <td align="left">Optional encrypted password</td>
    <tr><td align="right" valign="baseline">2&nbsp;</td>
        <td align="left"><code>pw_uid</code></td>
        <td align="left">Numerical user ID</td>
    <tr><td align="right" valign="baseline">3&nbsp;</td>
        <td align="left"><code>pw_gid</code></td>
        <td align="left">Numerical group ID</td>
    <tr><td align="right" valign="baseline">4&nbsp;</td>
        <td align="left"><code>pw_gecos</code></td>
        <td align="left">User name or comment field</td>
    <tr><td align="right" valign="baseline">5&nbsp;</td>
        <td align="left"><code>pw_dir</code></td>
        <td align="left">User home directory</td>
    <tr><td align="right" valign="baseline">6&nbsp;</td>
        <td align="left"><code>pw_shell</code></td>
        <td align="left">User command interpreter</td></tbody>
</table>

<P>
The uid and gid items are integers, all others are strings.
<tt class="exception">KeyError</tt> is raised if the entry asked for cannot be found.

<P>
<span class="note"><b class="label">Note:</b>
In traditional Unix the field <code>pw_passwd</code> usually
contains a password encrypted with a DES derived algorithm (see module
<tt class="module"><a href="module-crypt.html">crypt</a></tt><a name="l2h-2126">&nbsp;</a>).  However most modern unices 
use a so-called <i>shadow password</i> system.  On those unices the
field <code>pw_passwd</code> only contains a asterisk (<code>'*'</code>) or the 
letter "<tt class="character">x</tt>" where the encrypted password is stored in a file
<span class="file">/etc/shadow</span> which is not world readable.</span>

<P>
It defines the following items:

<P>
<dl><dt><b><a name="l2h-2127"><tt class="function">getpwuid</tt></a></b>(<var>uid</var>)
<dd>
Return the password database entry for the given numeric user ID.
</dl>

<P>
<dl><dt><b><a name="l2h-2128"><tt class="function">getpwnam</tt></a></b>(<var>name</var>)
<dd>
Return the password database entry for the given user name.
</dl>

<P>
<dl><dt><b><a name="l2h-2129"><tt class="function">getpwall</tt></a></b>()
<dd>
Return a list of all available password database entries, in arbitrary order.
</dl>

<P>
<div class="seealso">
  <p class="heading"><b>See Also:</b></p>

  <dl compact class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-grp.html">grp</a></tt>:</b>
    <dd>An interface to the group database, similar to this.
  </dl>
</div>

<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="posix-contents.html"><img src="../icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="unix.html"><img src="../icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-grp.html"><img src="../icons/next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html"><img src="../icons/contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" title="Module Index"><img src="../icons/modules.gif"
  border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html"><img src="../icons/index.gif"
  border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="posix-contents.html">8.1.2 Module Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" href="unix.html">8. Unix Specific Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-grp.html">8.3 grp  </A>
<hr>
<span class="release-info">Release 2.2, documentation updated on December 21, 2001.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>