191 lines
6.5 KiB
HTML
191 lines
6.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>endpwent</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="endpwent"></a> <a name="tag_03_121"></a><!-- endpwent -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_121_01"></a>NAME</h4>
|
|
|
|
<blockquote>endpwent, getpwent, setpwent - user database functions</blockquote>
|
|
|
|
<h4><a name="tag_03_121_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/pwd.h.html">pwd.h</a>><br>
|
|
<br>
|
|
void endpwent(void);<br>
|
|
struct passwd *getpwent(void);<br>
|
|
void setpwent(void); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_121_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>These functions shall retrieve information about users.</p>
|
|
|
|
<p>The <i>getpwent</i>() function shall return a pointer to a structure containing the broken-out fields of an entry in the user
|
|
database. Each entry in the user database contains a <b>passwd</b> structure. When first called, <i>getpwent</i>() shall return a
|
|
pointer to a <b>passwd</b> structure containing the first entry in the user database. Thereafter, it shall return a pointer to a
|
|
<b>passwd</b> structure containing the next entry in the user database. Successive calls can be used to search the entire user
|
|
database.</p>
|
|
|
|
<p>If an end-of-file or an error is encountered on reading, <i>getpwent</i>() shall return a null pointer.</p>
|
|
|
|
<p>An implementation that provides extended security controls may impose further implementation-defined restrictions on accessing
|
|
the user database. In particular, the system may deny the existence of some or all of the user database entries associated with
|
|
users other than the caller.</p>
|
|
|
|
<p>The <i>setpwent</i>() function effectively rewinds the user database to allow repeated searches.</p>
|
|
|
|
<p>The <i>endpwent</i>() function may be called to close the user database when processing is complete.</p>
|
|
|
|
<p>These functions need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getpwent</i>() function shall return a null pointer on end-of-file or error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>getpwent</i>(), <i>setpwent</i>(), and <i>endpwent</i>() functions may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EIO]</dt>
|
|
|
|
<dd>An I/O error has occurred.</dd>
|
|
</dl>
|
|
|
|
<p>In addition, <i>getpwent</i>() and <i>setpwent</i>() may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EMFILE]</dt>
|
|
|
|
<dd>{OPEN_MAX} file descriptors are currently open in the calling process.</dd>
|
|
|
|
<dt>[ENFILE]</dt>
|
|
|
|
<dd>The maximum allowable number of files is currently open in the system.</dd>
|
|
</dl>
|
|
|
|
<p>The return value may point to a static area which is overwritten by a subsequent call to <a href=
|
|
"../functions/getpwuid.html"><i>getpwuid</i>()</a>, <a href="../functions/getpwnam.html"><i>getpwnam</i>()</a>, or
|
|
<i>getpwent</i>().<br>
|
|
</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_121_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<h5><a name="tag_03_121_06_01"></a>Searching the User Database</h5>
|
|
|
|
<p>The following example uses the <i>getpwent</i>() function to get successive entries in the user database, returning a pointer to
|
|
a <b>passwd</b> structure that contains information about each user. The call to <i>endpwent</i>() closes the user database and
|
|
cleans up.</p>
|
|
|
|
<pre>
|
|
<tt>#include <pwd.h>
|
|
...
|
|
struct passwd *p;
|
|
...
|
|
while ((p = getpwent ()) != NULL) {
|
|
...
|
|
}
|
|
<br>
|
|
endpwent();
|
|
...
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>These functions are provided due to their historical usage. Applications should avoid dependencies on fields in the password
|
|
database, whether the database is a single file, or where in the file system name space the database resides. Applications should
|
|
use <a href="../functions/getpwuid.html"><i>getpwuid</i>()</a> whenever possible because it avoids these dependencies.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="endgrent.html"><i>endgrent</i>()</a> , <a href="getlogin.html"><i>getlogin</i>()</a> , <a href=
|
|
"getpwnam.html"><i>getpwnam</i>()</a> , <a href="getpwuid.html"><i>getpwuid</i>()</a> , the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/pwd.h.html"><i><pwd.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4, Version 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
|
|
|
<p>Normative text previously in the APPLICATION USAGE section is moved to the RETURN VALUE section.</p>
|
|
|
|
<p>A note indicating that these functions need not be reentrant is added to the DESCRIPTION.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_121_13"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>In the DESCRIPTION, the note about reentrancy is expanded to cover thread-safety.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|