passwd file update functions
functions allow a program to update the system passwd database.
function attempts to lock the passwd database by creating the file
/etc/ptmp, and returns the file descriptor of that
file. If retries is greater than zero,
pw_lock() will try multiple times to open
/etc/ptmp, waiting one second between tries. In
addition to being a lock file, /etc/ptmp will also
hold the contents of the new passwd file. A different lock file can be
pw_init(3) must be called before
function updates the passwd file from the contents of
pwd_mkdb(8). If a username is specified, only
the record for the specified user will be updated. The
pwflags are specified by OR'ing the following
By default the secure, insecure and Version 7
format password databases are updated. You should finish writing to and
close the file descriptor returned by
pw_mkdb() fails and you do not wish to retry, you
should make sure to call
pw_abort() to clean up the
function aborts a passwd file update by deleting
/etc/ptmp. The passwd database remains
pw_lock() function returns -1 on error
and sets errno. The
function returns -1 if it is unable to complete properly.
- Current password file.
- A Version 7 format password file.
- Password lock file.
- Insecure password database file.
- Secure password database file.
pw_lock() was called before pw_init(3).
pw_lock() may also fail and set
errno for any of the errors specified for the routine
flock(2), pw_file(3), pw_init(3), pwd_mkdb(8)