— utility functions for interactive passwd
struct passwd *pw
const struct passwd
These functions are designed as conveniences for interactive programs which
update the passwd file and do nothing else. They generally handle errors by
printing out a message to the standard error stream and possibly aborting the
() function prepares for a passwd update
by unlimiting all resource constraints, disabling core dumps (thus preventing
dumping the contents of the passwd database into a world-readable file), and
disabling most signals.
() function sets an alternative
directory where the rest of the functions look for password-related files. Use
this if you are writing utilities that should be able to handle password files
outside of /etc
() function transforms filenames so that
they end up in the directory specified to the latest
() call. The rule is that all
directories are stripped of the given name and only the filename is appended
to the directory.
() function runs an editor (named by the
environment variable EDITOR, or /usr/bin/vi
EDITOR is not set) on the file filename
is NULL). If
() will set the effective user and group
ID to the real user and group ID before running the editor.
() function asks the user whether he
or she wants to re-edit the password file; if the answer is no,
() deletes the lock file and exits the
() function reads a passwd file from
and writes it to
, updating the entry corresponding to
pw->pw_name with the information in pw
is not NULL, opw->pw_name will be used
for matching instead. Additionally, if the existing entry does not match
, the operation is aborted. The use of
allows the caller to change the user name
in an entry as well as guarantee that the entry being replaced has not changed
in the meantime.
() function accepts in
a passwd entry as it would be represented
and fills in
with corresponding values; string fields
will be pointers into
. Some characters in
will be overwritten with 0s in order to
terminate the strings pointed to by pw
is non-null, it is filled in with the
- The uid field of bp is
- The gid field of bp is
- The change field of bp is
- The expire field of bp is
() function displays an error message,
aborts the current passwd update, and exits the current process. If
is non-zero, a warning message beginning
is printed for the current value of
. The process exits with status
() function prints a warning message and
returns 0 if the string in the bp
not a valid passwd string. Otherwise, pw_scan
- Current password file.
- Legacy password file.
- Password lock file.
- Insecure password database file.
- Secure password database file.