|File: [cvs.NetBSD.org] / src / lib / libutil / pw_init.3 (download)
Revision 1.6, Fri Nov 19 23:29:47 1999 UTC (20 years, 6 months ago) by kristerw
CVS Tags: wrstuden-devbsize-base, wrstuden-devbsize-19991221, netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, minoura-xpg4dl-base, minoura-xpg4dl
Changes since 1.5: +2 -2
Typos (from OpenBSD)
.\" $NetBSD: pw_init.3,v 1.6 1999/11/19 23:29:47 kristerw Exp $
.\" Copyright (c) 1995
.\" The Regents of the University of California. All rights reserved.
.\" This code is derived from software developed by the Computer Systems
.\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
.\" BG 91-66 and contributed to Berkeley.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd December 15, 1995
.Dt PW_INIT 3
.Nm pw_init ,
.Nm pw_edit ,
.Nm pw_prompt ,
.Nm pw_copy ,
.Nm pw_scan ,
.Nd utility functions for interactive passwd file updates
.Fd #include <pwd.h>
.Fd #include <util.h>
.Fn pw_edit "int notsetuid" "const char *filename"
.Fn pw_copy "int ffd" "int tfd" "struct passwd *pw" "struct passwd *old_pw"
.Fn pw_scan "char *bp" "struct passwd *pw" "int *flags"
.Fn pw_error "const char *name" "int err" "int eval"
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 process.
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 runs an editor (named by the environment variable EDITOR, or
if EDITOR is not set) on the file
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 process.
function reads a passwd file from
and writes it to
.Fa tfd ,
updating the entry corresponding to pw->pw_name with the information
.Fa pw .
is not NULL, it checks to make sure the old entry is the same as
the one described in
or the process is aborted. If an entry is not found to match
.Fa pw ,
a new entry is appended to the passwd file only if the real user
ID is 0.
function accepts in
a passwd entry as it would be represented in
and fills in
with corresponding values; string fields in
will be pointers into
.Fa bp .
Some characters in
will be overwritten with 0s in order to terminate the strings pointed
.Fa pw .
is non-null, it should be cleared and the following options
enabled if required:
.Bl -tag -offset indent -width _PASSWORD_OLDFMT
.It Dv _PASSWORD_NOWARN
Don't print warnings.
.It Dv _PASSWORD_OLDFMT
as an old format entry as found in
.Pa /etc/passwd .
Upon return it is cleared, and filled in with the following flags:
.Bl -tag -offset indent -width _PASSWORD_NOGID
.It Dv _PASSWORD_NOUID
The uid field of
.It Dv _PASSWORD_NOGID
The gid field of
.It Dv _PASSWD_NOCHG
The change field of
.It Dv _PASSWD_NOEXP
The expire field of
function displays an error message, aborts the current passwd update,
and exits the current process. If
is non-zero, a warning message beginning with
is printed for the current value of
.Va errno .
The process exits with status
.Fa eval .
.Sh RETURN VALUES
function prints a warning message and returns 0 if the string in the
argument is not a valid passwd string. Otherwise,
.Bl -tag -width /etc/master.passwd -compact
.It Pa /etc/master.passwd
.It Pa /etc/ptmp
.Sh SEE ALSO
.Xr pw_lock 3 ,
.Xr passwd 5