home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
man
/
cat3
/
getpwent.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
5KB
|
133 lines
GETPWENT(3) UNIX Programmer's Manual GETPWENT(3)
NNAAMMEE
ggeettppwweenntt, ggeettppwwnnaamm, ggeettppwwuuiidd, sseettppaasssseenntt, sseettppwweenntt, eennddppwweenntt - password
database operations
SSYYNNOOPPSSIISS
##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
##iinncclluuddee <<ppwwdd..hh>>
_s_t_r_u_c_t _p_a_s_s_w_d _*
ggeettppwweenntt(_v_o_i_d)
_s_t_r_u_c_t _p_a_s_s_w_d _*
ggeettppwwnnaamm(_c_o_n_s_t _c_h_a_r _*_l_o_g_i_n)
_s_t_r_u_c_t _p_a_s_s_w_d _*
ggeettppwwuuiidd(_u_i_d___t _u_i_d)
_i_n_t
sseettppaasssseenntt(_i_n_t _s_t_a_y_o_p_e_n)
_i_n_t
sseettppwweenntt(_v_o_i_d)
_v_o_i_d
eennddppwweenntt(_v_o_i_d)
DDEESSCCRRIIPPTTIIOONN
These functions operate on the password database file which is described
in passwd(5). Each entry in the database is defined by the structure
_p_a_s_s_w_d found in the include file <_p_w_d_._h>:
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 ggeettppwwnnaamm() and ggeettppwwuuiidd() search the password database for
the given login name or user uid, respectively, always returning the
first one encountered.
The ggeettppwweenntt() function sequentially reads the password database and is
intended for programs that wish to process the complete list of users.
The sseettppaasssseenntt() function accomplishes two purposes. First, it causes
ggeettppwweenntt() to ``rewind'' to the beginning of the database. Additionally,
if _s_t_a_y_o_p_e_n is nonzero, file descriptors are left open, significantly
speeding up subsequent accesses for all of the routines. (This latter
functionality is unnecessary for ggeettppwweenntt() as it doesn't close its file
descriptors by default.)
It is dangerous for longrunning 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 sseettppwweenntt() function is identical to sseettppaasssseenntt() with an argument of
zero.
The eennddppwweenntt() 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 `*'.
RREETTUURRNN VVAALLUUEESS
The functions ggeettppwweenntt(), ggeettppwwnnaamm(), and ggeettppwwuuiidd(), return a valid
pointer to a passwd structure on success and a null pointer if endof
file is reached or an error occurs. The functions sseettppaasssseenntt() and
sseettppwweenntt() return 0 on failure and 1 on success. The eennddppwweenntt() function
has no return value.
FFIILLEESS
/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
SSEEEE AALLSSOO
getlogin(3), getgrent(3), passwd(5), pwd_mkdb(8), vipw(8)
HHIISSTTOORRYY
The ggeettppwweenntt, ggeettppwwnnaamm, ggeettppwwuuiidd, sseettppwweenntt,, and eennddppwweenntt functions ap
peared in Version 7 AT&T UNIX. The sseettppaasssseenntt function appeared in
4.3BSD-Reno.
BBUUGGSS
The functions ggeettppwweenntt(), ggeettppwwnnaamm(), and ggeettppwwuuiidd(), 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 ggeettppwweenntt(), eennddppwweenntt(), sseettppaasssseenntt(), and sseettppwweenntt() are
fairly useless in a networked environment and should be avoided, if pos
sible.
CCOOMMPPAATTIIBBIILLIITTYY
The historic function setpwfile(3), which allowed the specification of
alternate password databases, has been deprecated and is no longer avail
able.
BSD Experimental April 19, 1991 2