BSD 4_4 development
[unix-history] / usr / share / man / cat3 / setpwfile.0
GETPWENT(3) BSD Programmer's Manual GETPWENT(3)
N\bNA\bAM\bME\bE
g\bge\bet\btp\bpw\bwe\ben\bnt\bt, g\bge\bet\btp\bpw\bwn\bna\bam\bm, g\bge\bet\btp\bpw\bwu\bui\bid\bd, s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt, s\bse\bet\btp\bpw\bwe\ben\bnt\bt, e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt - password
database operations
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bty\byp\bpe\bes\bs.\b.h\bh>\b>
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<p\bpw\bwd\bd.\b.h\bh>\b>
_\bs_\bt_\br_\bu_\bc_\bt _\bp_\ba_\bs_\bs_\bw_\bd _\b*
g\bge\bet\btp\bpw\bwe\ben\bnt\bt(_\bv_\bo_\bi_\bd);
_\bs_\bt_\br_\bu_\bc_\bt _\bp_\ba_\bs_\bs_\bw_\bd _\b*
g\bge\bet\btp\bpw\bwn\bna\bam\bm(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bl_\bo_\bg_\bi_\bn);
_\bs_\bt_\br_\bu_\bc_\bt _\bp_\ba_\bs_\bs_\bw_\bd _\b*
g\bge\bet\btp\bpw\bwu\bui\bid\bd(_\bu_\bi_\bd_\b__\bt _\bu_\bi_\bd);
_\bi_\bn_\bt
s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt(_\bi_\bn_\bt _\bs_\bt_\ba_\by_\bo_\bp_\be_\bn);
_\bi_\bn_\bt
s\bse\bet\btp\bpw\bwe\ben\bnt\bt(_\bv_\bo_\bi_\bd);
_\bv_\bo_\bi_\bd
e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt(_\bv_\bo_\bi_\bd);
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
These functions operate on the password database file which is described
in passwd(5). Each entry in the database is defined by the structure
_\bp_\ba_\bs_\bs_\bw_\bd found in the include file <_\bp_\bw_\bd_\b._\bh>:
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* encrypted password */
uid_t pw_uid; /* user uid */
gid_t pw_gid; /* user gid */
time_t pw_change; /* password change time */
char *pw_class; /* user access class */
char *pw_gecos; /* Honeywell login info */
char *pw_dir; /* home directory */
char *pw_shell; /* default shell */
time_t pw_expire; /* account expiration */
};
The functions g\bge\bet\btp\bpw\bwn\bna\bam\bm() and g\bge\bet\btp\bpw\bwu\bui\bid\bd() search the password database for
the given login name or user uid, respectively, always returning the
first one encountered.
The g\bge\bet\btp\bpw\bwe\ben\bnt\bt() function sequentially reads the password database and is
intended for programs that wish to process the complete list of users.
The s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt() function accomplishes two purposes. First, it causes
g\bge\bet\btp\bpw\bwe\ben\bnt\bt() to ``rewind'' to the beginning of the database. Additionally,
if _\bs_\bt_\ba_\by_\bo_\bp_\be_\bn is non-zero, file descriptors are left open, significantly
speeding up subsequent accesses for all of the routines. (This latter
functionality is unnecessary for g\bge\bet\btp\bpw\bwe\ben\bnt\bt() as it doesn't close its file
descriptors by default.)
It is dangerous for long-running programs to keep the file descriptors
open the database will become out of date if it is updated while the pro-
gram is running.
The s\bse\bet\btp\bpw\bwe\ben\bnt\bt() function is identical to s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt() with an argument of
zero.
The e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt() function closes any open files.
These routines have been written to ``shadow'' the password file, e.g.
allow only certain programs to have access to the encrypted password. If
the process which calls them has an effective uid of 0, the encrypted
password will be returned, otherwise, the password field of the retuned
structure will point to the string `*'.
R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
The functions g\bge\bet\btp\bpw\bwe\ben\bnt\bt(), g\bge\bet\btp\bpw\bwn\bna\bam\bm(), and g\bge\bet\btp\bpw\bwu\bui\bid\bd(), return a valid
pointer to a passwd structure on success and a null pointer if end-of-
file is reached or an error occurs. The functions s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt() and
s\bse\bet\btp\bpw\bwe\ben\bnt\bt() return 0 on failure and 1 on success. The e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt() function
has no return value.
F\bFI\bIL\bLE\bES\bS
/var/db/pwd.db The insecure password database file
/var/db/spwd.db The secure password database file
/etc/master.passwd The current password file
/etc/passwd A Version 7 format password file
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
getlogin(3), getgrent(3), passwd(5), pwd_mkdb(8), vipw(8)
H\bHI\bIS\bST\bTO\bOR\bRY\bY
The g\bge\bet\btp\bpw\bwe\ben\bnt\bt, g\bge\bet\btp\bpw\bwn\bna\bam\bm, g\bge\bet\btp\bpw\bwu\bui\bid\bd, s\bse\bet\btp\bpw\bwe\ben\bnt\bt,\b, and e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt functions ap-
peared in Version 7 AT&T UNIX. The s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt function appeared in
4.3BSD-Reno.
B\bBU\bUG\bGS\bS
The functions g\bge\bet\btp\bpw\bwe\ben\bnt\bt(), g\bge\bet\btp\bpw\bwn\bna\bam\bm(), and g\bge\bet\btp\bpw\bwu\bui\bid\bd(), leave their results
in an internal static object and return a pointer to that object. Subse-
quent calls to the same function will modify the same object.
The routines g\bge\bet\btp\bpw\bwe\ben\bnt\bt(), e\ben\bnd\bdp\bpw\bwe\ben\bnt\bt(), s\bse\bet\btp\bpa\bas\bss\bse\ben\bnt\bt(), and s\bse\bet\btp\bpw\bwe\ben\bnt\bt() are
fairly useless in a networked environment and should be avoided, if pos-
sible.
C\bCO\bOM\bMP\bPA\bAT\bTI\bIB\bBI\bIL\bLI\bIT\bTY\bY
The historic function setpwfile(3), which allowed the specification of
alternate password databases, has been deprecated and is no longer avail-
able.
4.4BSD June 4, 1993 2