summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pw/bitmap.c7
-rw-r--r--usr.sbin/pw/cpdir.c19
-rw-r--r--usr.sbin/pw/edgroup.c8
-rw-r--r--usr.sbin/pw/fileupd.c7
-rw-r--r--usr.sbin/pw/grupd.c8
-rw-r--r--usr.sbin/pw/psdate.c7
-rw-r--r--usr.sbin/pw/pw.8104
-rw-r--r--usr.sbin/pw/pw.c78
-rw-r--r--usr.sbin/pw/pw.conf.534
-rw-r--r--usr.sbin/pw/pw.h3
-rw-r--r--usr.sbin/pw/pw_conf.c7
-rw-r--r--usr.sbin/pw/pw_group.c34
-rw-r--r--usr.sbin/pw/pw_log.c7
-rw-r--r--usr.sbin/pw/pw_nis.c7
-rw-r--r--usr.sbin/pw/pw_user.c100
-rw-r--r--usr.sbin/pw/pwupd.c7
-rw-r--r--usr.sbin/pw/rm_r.c7
17 files changed, 228 insertions, 216 deletions
diff --git a/usr.sbin/pw/bitmap.c b/usr.sbin/pw/bitmap.c
index 810d1ad..bb55c5b 100644
--- a/usr.sbin/pw/bitmap.c
+++ b/usr.sbin/pw/bitmap.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/pw/cpdir.c b/usr.sbin/pw/cpdir.c
index 51891da..048a87b 100644
--- a/usr.sbin/pw/cpdir.c
+++ b/usr.sbin/pw/cpdir.c
@@ -22,20 +22,24 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <fcntl.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
#include <sys/param.h>
-#include <errno.h>
+#include <dirent.h>
#include "pwupd.h"
@@ -47,8 +51,7 @@ copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid
char dst[MAXPATHLEN];
if (mkdir(dir, mode) != 0 && errno != EEXIST) {
- sprintf(src, "mkdir(%s)", dir);
- perror(src);
+ warn("mkdir(%s)", dir);
} else {
int infd, outfd;
struct stat st;
diff --git a/usr.sbin/pw/edgroup.c b/usr.sbin/pw/edgroup.c
index 9dcbc63..c927b06 100644
--- a/usr.sbin/pw/edgroup.c
+++ b/usr.sbin/pw/edgroup.c
@@ -22,16 +22,18 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
-#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
diff --git a/usr.sbin/pw/fileupd.c b/usr.sbin/pw/fileupd.c
index c20b4ad..3782bf7 100644
--- a/usr.sbin/pw/fileupd.c
+++ b/usr.sbin/pw/fileupd.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index cf0584e..feff430 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -22,16 +22,18 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
-#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/usr.sbin/pw/psdate.c b/usr.sbin/pw/psdate.c
index 14b7340..9b9cf78 100644
--- a/usr.sbin/pw/psdate.c
+++ b/usr.sbin/pw/psdate.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/pw/pw.8 b/usr.sbin/pw/pw.8
index 119b1ee..32c90e1 100644
--- a/usr.sbin/pw/pw.8
+++ b/usr.sbin/pw/pw.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: pw.8,v 1.9 1997/02/22 16:12:25 peter Exp $
+.\" $Id: pw.8,v 1.10 1997/03/04 07:55:43 danny Exp $
.\"
.Dd December 9, 1996
.Dt PW 8
@@ -156,18 +156,18 @@
.Op Fl C Ar config
.Op Fl q
.Sh DESCRIPTION
-.Nm pw
+.Nm Pw
is a command-line based editor for the system
-.Em user
+.Ar user
and
-.Em group
+.Ar group
files, allowing the superuser an easy to use and standardized way of adding,
modifying and removing users and groups.
Note that
-.Nm pw
+.Nm
only operates on the local user and group files; NIS users and groups must be
maintained on the NIS server.
-.Nm pw
+.Nm Pw
handles updating the
.Pa passwd ,
.Pa master.passwd ,
@@ -192,7 +192,7 @@ or
and may be specified in either order (ie. showuser, usershow, show user and user show
are all considered to be the same thing).
This flexibility is useful for interactive scripts which call
-.Nm pw
+.Nm
for the actual user and group database manipulation.
Following these keywords, you may optionally specify the user or group name or numeric
id as an alternative to using the
@@ -206,7 +206,7 @@ The following flags are common to all or most modes of operation:
.Bl -tag -width "-G grouplist"
.It Fl C Ar config
By default,
-.Nm pw
+.Nm
reads the file
.Pa /etc/pw.conf
to obtain policy information on how new user accounts and groups are to be created,
@@ -218,14 +218,14 @@ options, but it may be more useful to set up standard information for addition o
new accounts in the configuration file.
.It Fl q
Use of this option causes
-.Nm pw
+.Nm
to suppress error messages, which may be useful in interactive environments where it
is preferable to interpret status codes returned by
-.Nm pw
+.Nm
rather than messing up a carefully formatted display.
.It Fl N
This option is available in add and modify operations, and causes
-.Nm pw
+.Nm
to skip updating the user/group databases and instead print the result
of the operation without actually performing it.
You may use the
@@ -233,7 +233,7 @@ You may use the
option to switch between standard passwd and readable formats.
.It Fl Y
Using this option with any of the update modes causes
-.Nm pw
+.Nm
to run
.Xr make 1
after changing to the directory
@@ -255,9 +255,9 @@ commands:
.Pp
.Bl -tag -width "-G grouplist"
.It Fl n Ar name
-Specifies the user/account name.
+Specify the user/account name.
.It Fl u Ar uid
-Specifies the user/account numeric id.
+Specify the user/account numeric id.
.Pp
Usually, you need only to provide one or the other of these options, as the account
name will imply the uid, and vice versa.
@@ -276,7 +276,7 @@ For example, when changing the uid of an existing user with
.Ar usermod ,
or overriding the default uid when creating a new account.
If you wish
-.Nm pw
+.Nm
to automatically allocate the uid to a new user on
.Ar useradd ,
then you should
@@ -308,13 +308,15 @@ character also cannot be used as this is the field separator in the passwd file.
This option sets the account's home directory.
Normally, you will only use this if the home directory is to be different from the
default (which is determined from pw.conf, which specifies the base home directory
-- normally /home - with the account name as a subdirectory).
+- normally
+.Pa /home
+- with the account name as a subdirectory).
.It Fl e Ar date
-Sets the account's expiration date.
+Set the account's expiration date.
Format of the date is either a UNIX time in decimal, or a date in
.Ql \& dd-mmm-yy[yy]
format, where dd is the day, mmm is the month, either in numeric or alphabetic format
-('Jan', 'Feb' etc) and year is either a two or four digit year.
+('Jan', 'Feb', etc) and year is either a two or four digit year.
This option also accepts a relative date in the form
.Ql \&+n[mhdwoy]
where
@@ -323,12 +325,12 @@ is a decimal, octal (leading 0) or hexadecimal (leading 0x) digit followed by th
number of Minutes, Hours, Days, Weeks, Months or Years from the current date at
which the expiry date is to be set.
.It Fl p Ar date
-Sets the account's password expiration date.
+Set the account's password expiration date.
This field is identical to the account expiration date option, except that it
applies to forced password changes.
The same formats are accepted as with the account expiration option.
.It Fl g Ar group
-Sets the account's primary group to the given group.
+Set the account's primary group to the given group.
.Ar group
may be either the group name or its corresponding group id number.
.It Fl G Ar grouplist
@@ -351,7 +353,7 @@ See
for more information on user classes.
.It Fl m
This option instructs
-.Nm pw
+.Nm
to attempt to create the user's home directory.
While primarily useful when adding a new account with
.Ar useradd ,
@@ -378,7 +380,7 @@ This may be overridden with the
.Ql Fl d Ar dir
option on the command line, if desired.
.It Fl k Ar dir
-Sets the
+Set the
.Ar skeleton
subdirectory, from which the basic startup and configuration files are copied when
the user's home directory is created.
@@ -387,10 +389,10 @@ This option only has meaning when used with
(see below) or
.Ql Fl m .
.It Fl s Ar shell
-Sets or changes the user's login shell to
+Set or changes the user's login shell to
.Ar shell .
If the path to the shell program is omitted,
-.Nm pw
+.Nm
searches the
.Ar shellpath
specified in
@@ -398,14 +400,14 @@ specified in
and fills it in as appropriate.
Note that unless you have a specific reason to do so, you should avoid
specifying the path - this will allow
-.Nm pw
+.Nm
to validate that the program exists and is executable.
Specifying a full path (or supplying a blank "" shell) avoids this check
and allows for such entries as
-.Ql \& /nonexistent
+.Pa /nonexistent
that should be set for accounts not intended for interactive login.
.It Fl L Ar class
-Sets the
+Set the
.Em class
field in the user's passwd record.
This field is not currently used, but will be in the future used to specify a
@@ -419,7 +421,7 @@ set an account password using
.Nm pw .
Because the command line and environment are fundamental insecure mechanisms
by which programs can accept information,
-.Nm pw
+.Nm
will only allow setting of account and group passwords via a file descriptor
(usually a pipe between an interactive script and the program).
.Ar sh ,
@@ -469,7 +471,7 @@ command also has the ability to set new user and group defaults by using the
.Ql Fl D
option.
Instead of adding a new user,
-.Nm pw
+.Nm
writes a new set of defaults to its configuration file,
.Pa /etc/pw.conf .
When using the
@@ -493,28 +495,28 @@ configuration file, or a different named configuration file if the
.Ql Fl C Ar config
option is used.
.It Fl b Ar dir
-Sets the root directory in which user home directories are created.
+Set the root directory in which user home directories are created.
The default value for this is
-.Ql \&/home ,
+.Pa /home ,
but it may be set elsewhere as desired.
.It Fl e Ar days
-Sets the default account expiration period in days.
+Set the default account expiration period in days.
Unlike use without
.Ql Fl D ,
the argument must be numeric, which specifies the number of days after creation when
the account is to expire.
A value of 0 suppresses automatic calculation of the expiry date.
.It Fl p Ar days
-Sets the default password expiration period in days.
+Set the default password expiration period in days.
.It Fl g Ar group
-Sets the default group for new users.
+Set the default group for new users.
If a blank group is specified using
.Ql Fl g Ar \&"" ,
then new users will be allocated their own private primary group (a new group created
with the same name as their login name).
If a group is supplied, either its name or uid may be given as an argument.
.It Fl G Ar grouplist
-Sets the default groups in which new users are made members.
+Set the default groups in which new users are made members.
This is a separate set of groups from the primary group, and you should avoid
nominating the same group as both the primary and in extra groups.
In other words, these extra groups determine membership in groups
@@ -528,10 +530,10 @@ by their symbolic names.
.It Fl L Ar class
This option sets the default login class for new users.
.It Fl k Ar dir
-Sets the default
+Set the default
.Em skeleton
directory, from which prototype shell and other initialization files are copied when
-.Nm pw
+.Nm
creates a user's home directory.
.It Fl u Ar min,max , Fl i Ar min,max
These options set the minimum and maximum user and group ids allocated for new accounts
@@ -555,13 +557,13 @@ is one of:
.Pp
.Bl -tag -width random -offset indent -compact
.It no
-disables login on newly created accounts
+disable login on newly created accounts
.It yes
-forces the password to be the account name
+force the password to be the account name
.It none
-forces a blank password
+force a blank password
.It random
-Generates a random password
+generate a random password
.El
.Pp
The
@@ -569,7 +571,7 @@ The
or
.Ql \&no
methods are the most secure; in the former case,
-.Nm pw
+.Nm
generates a password and prints it to stdout, which is suitable where you issue
users with passwords to access their accounts rather than having the user nominate
their own (possibly poorly chosen) password.
@@ -597,9 +599,9 @@ The additional option is:
.Bl -tag -width "-G grouplist"
.It Fl r
This tells
-.Nm pw
+.Nm
to remove the user's home directory and all of its contents.
-.Nm pw
+.Nm Pw
errs on the side of caution when removing files from the system.
Firstly, it will not do so if the uid of the account being removed is also used by
another account on the system, and the 'home' directory in the password file is
@@ -629,7 +631,7 @@ with the password field replaced with a
If the
.Ql Fl P
option is used, then
-.Nm pw
+.Nm
outputs the account details in a more human readable form.
The
.Ql Fl a
@@ -652,9 +654,9 @@ with the group manipulation commands.
Other common options to all group-related commands are:
.Bl -tag -width "-m newmembers"
.It Fl n Ar name
-Specifies the group name.
+Specify the group name.
.It Fl g Ar gid
-Specifies the group numeric id.
+Specify the group numeric id.
.Pp
As with the account name and id fields, you will usually only need
to supply one of these, as the group name implies the uid and vice
@@ -712,7 +714,7 @@ The command
.Ar groupnext
returns the next available group id on standard output.
.Sh DIAGNOSTICS
-.Nm pw
+.Nm Pw
returns EXIT_SUCCESS on successful operation, otherwise one of the
following exit codes defined by
.Xr sysexits 3
@@ -721,7 +723,7 @@ as follows:
.It EX_USAGE
.Bl -bullet -compact
.It
-Command line syntax errors (invalid keyword, unknown option)
+Command line syntax errors (invalid keyword, unknown option).
.El
.It EX_NOPERM
.Bl -bullet -compact
@@ -787,7 +789,7 @@ For example,
.Dl pw useradd help
lists all available options for the useradd operation.
.Pp
-.Nm pw
+.Nm Pw
allows 8-bit characters in the passwd gecos field (user's full name,
office, work and home phone number subfields), but disallows them in
user login and group names.
@@ -835,7 +837,7 @@ Pw default options file
.Xr pwd_mkdb 8 ,
.Xr vipw 8
.Sh HISTORY
-.Nm pw
+.Nm Pw
was written to mimic many of the options used in the SYSV
.Em shadow
support suite, but is modified for passwd and group fields specific to
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c
index 6333322..634716e 100644
--- a/usr.sbin/pw/pw.c
+++ b/usr.sbin/pw/pw.c
@@ -22,16 +22,18 @@
* 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.
- *
- * $Id: pw.c,v 1.5 1997/02/22 16:12:25 peter Exp $
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include "pw.h"
+#include <err.h>
#include <paths.h>
#include <sys/wait.h>
-static char *progname = "pw";
-
const char *Modes[] = {"add", "del", "mod", "show", "next", NULL};
const char *Which[] = {"user", "group", NULL};
static const char *Combo1[] = {
@@ -82,12 +84,6 @@ main(int argc, char *argv[])
};
umask(0); /* We wish to handle this manually */
- progname = strrchr(argv[0], '/');
- if (progname != NULL)
- ++progname;
- else
- progname = argv[0];
-
LIST_INIT(&arglist);
/*
@@ -109,7 +105,7 @@ main(int argc, char *argv[])
else if (which != -1 && mode != -1 && arglist.lh_first == NULL)
addarg(&arglist, 'n', argv[1]);
else
- cmderr(EX_USAGE, "Unknown keyword `%s'\n", argv[1]);
+ errx(EX_USAGE, "unknown keyword `%s'", argv[1]);
++argv;
--argc;
}
@@ -124,12 +120,11 @@ main(int argc, char *argv[])
* We know which mode we're in and what we're about to do, so now
* let's dispatch the remaining command line args in a genric way.
*/
- argv[0] = progname; /* Preserve this */
optarg = NULL;
while ((ch = getopt(argc, argv, opts[which][mode])) != -1) {
if (ch == '?')
- cmderr(EX_USAGE, NULL);
+ errx(EX_USAGE, NULL);
else
addarg(&arglist, ch, optarg);
optarg = NULL;
@@ -139,7 +134,7 @@ main(int argc, char *argv[])
* Must be root to attempt an update
*/
if (geteuid() != 0 && mode != M_PRINT && mode != M_NEXT && getarg(&arglist, 'N')==NULL)
- cmderr(EX_NOPERM, "you must be root to run this program\n");
+ errx(EX_NOPERM, "you must be root to run this program");
/*
* We should immediately look for the -q 'quiet' switch so that we
@@ -163,9 +158,9 @@ main(int argc, char *argv[])
fflush(NULL);
if (chdir(_PATH_YP) == -1)
- perror("chdir(" _PATH_YP ")");
+ warn("chdir(" _PATH_YP ")");
else if ((pid = fork()) == -1)
- perror("fork()");
+ warn("fork()");
else if (pid == 0) {
/* Is make anywhere else? */
execlp("/usr/bin/make", "make", NULL);
@@ -174,7 +169,7 @@ main(int argc, char *argv[])
int i;
waitpid(pid, &i, 0);
if ((i = WEXITSTATUS(i)) != 0)
- cmderr(ch, "warning: make exited with status %d\n", i);
+ errx(ch, "make exited with status %d", i);
else
pw_log(cnf, mode, which, "NIS maps updated");
}
@@ -202,33 +197,12 @@ getindex(const char *words[], const char *word)
*/
static void
-banner(void)
-{
- fprintf(stderr, "%s: ", progname);
-}
-
-void
-cmderr(int ec, char const * fmt,...)
-{
- if (fmt != NULL) {
- va_list argp;
-
- banner();
- va_start(argp, fmt);
- vfprintf(stderr, fmt, argp);
- va_end(argp);
- }
- exit(ec);
-}
-
-static void
cmdhelp(int mode, int which)
{
- banner();
if (which == -1)
- fprintf(stderr, "usage: %s [user|group] [add|del|mod|show|next] [ help | switches/values ]\n", progname);
+ fprintf(stderr, "usage: pw [user|group] [add|del|mod|show|next] [ help | switches/values ]\n");
else if (mode == -1)
- fprintf(stderr, "usage: %s %s [add|del|mod|show|next] [ help | switches/values ]\n", progname, Which[which]);
+ fprintf(stderr, "usage: pw %s [add|del|mod|show|next] [ help | switches/values ]\n", Which[which]);
else {
/*
@@ -237,7 +211,7 @@ cmdhelp(int mode, int which)
static const char *help[W_NUM][M_NUM] =
{
{
- "usage: %s useradd [name] [switches]\n"
+ "usage: pw useradd [name] [switches]\n"
"\t-C config configuration file\n"
"\t-q quiet operation\n"
" Adding users:\n"
@@ -270,12 +244,12 @@ cmdhelp(int mode, int which)
"\t-w method set default password method\n"
"\t-s shell default shell\n"
"\t-y path set NIS passwd file path\n",
- "usage: %s userdel [uid|name] [switches]\n"
+ "usage: pw userdel [uid|name] [switches]\n"
"\t-n name login name\n"
"\t-u uid user id\n"
"\t-Y update NIS maps\n"
"\t-r remove home & contents\n",
- "usage: %s usermod [uid|name] [switches]\n"
+ "usage: pw usermod [uid|name] [switches]\n"
"\t-C config configuration file\n"
"\t-q quiet operation\n"
"\t-F force add if no user\n"
@@ -295,17 +269,17 @@ cmdhelp(int mode, int which)
"\t-h fd read password on fd\n"
"\t-Y update NIS maps\n"
"\t-N no update\n",
- "usage: %s usershow [uid|name] [switches]\n"
+ "usage: pw usershow [uid|name] [switches]\n"
"\t-n name login name\n"
"\t-u uid user id\n"
"\t-F force print\n"
"\t-P prettier format\n"
"\t-a print all users\n",
- "usage: %s usernext [switches]\n"
+ "usage: pw usernext [switches]\n"
"\t-C config configuration file\n"
},
{
- "usage: %s groupadd [group|gid] [switches]\n"
+ "usage: pw groupadd [group|gid] [switches]\n"
"\t-C config configuration file\n"
"\t-q quiet operation\n"
"\t-n group group name\n"
@@ -314,11 +288,11 @@ cmdhelp(int mode, int which)
"\t-o duplicate gid ok\n"
"\t-Y update NIS maps\n"
"\t-N no update\n",
- "usage: %s groupdel [group|gid] [switches]\n"
+ "usage: pw groupdel [group|gid] [switches]\n"
"\t-n name group name\n"
"\t-g gid group id\n"
"\t-Y update NIS maps\n",
- "usage: %s groupmod [group|gid] [switches]\n"
+ "usage: pw groupmod [group|gid] [switches]\n"
"\t-C config configuration file\n"
"\t-q quiet operation\n"
"\t-F force add if not exists\n"
@@ -329,18 +303,18 @@ cmdhelp(int mode, int which)
"\t-l name new group name\n"
"\t-Y update NIS maps\n"
"\t-N no update\n",
- "usage: %s groupshow [group|gid] [switches]\n"
+ "usage: pw groupshow [group|gid] [switches]\n"
"\t-n name group name\n"
"\t-g gid group id\n"
"\t-F force print\n"
"\t-P prettier format\n"
"\t-a print all accounting groups\n",
- "usage: %s groupnext [switches]\n"
+ "usage: pw groupnext [switches]\n"
"\t-C config configuration file\n"
}
};
- fprintf(stderr, help[which][mode], progname);
+ fprintf(stderr, help[which][mode]);
}
exit(EXIT_FAILURE);
}
@@ -361,7 +335,7 @@ addarg(struct cargs * _args, int ch, char *argstr)
struct carg *ca = malloc(sizeof(struct carg));
if (ca == NULL)
- cmderr(EX_OSERR, "Abort - out of memory\n");
+ errx(EX_OSERR, "out of memory");
ca->ch = ch;
ca->val = argstr;
LIST_INSERT_HEAD(_args, ca, list);
diff --git a/usr.sbin/pw/pw.conf.5 b/usr.sbin/pw/pw.conf.5
index 2b885e5..c06f040 100644
--- a/usr.sbin/pw/pw.conf.5
+++ b/usr.sbin/pw/pw.conf.5
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: pw.conf.5,v 1.6 1997/02/22 16:12:26 peter Exp $
.\"
.Dd December 9, 1996
.Dt PW.CONF 5
@@ -43,9 +43,9 @@ files, allowing users and groups to be added, deleted and changed.
This file may be modified via the
.Xr pw 8
command using the
-.Ql \&useradd
+.Ar useradd
command and the
-.Ql \&-D
+.Fl D
option, or by editing it directly with a text editor.
.Pp
Each line in
@@ -61,7 +61,7 @@ Keywords recognised by
are:
.Bl -tag -width password_days -offset indent -compact
.It defaultpasswd
-affects passwords generated for new users
+affect passwords generated for new users
.It reuseuids
reuse gaps in uid sequences
.It reusegids
@@ -102,16 +102,16 @@ days after which password expires
.Pp
Valid values for
.Ar defaultpasswd
-are
+are:
.Bl -tag -width password_days -offset indent -compact
.It no
-disables login on newly created accounts
+disable login on newly created accounts
.It yes
-forces the password to be the account name
+force the password to be the account name
.It none
-forces a blank password
+force a blank password
.It random
-Generates a random password
+generate a random password
.El
.Pp
The second and third options are insecure and should be avoided if
@@ -124,7 +124,7 @@ The final option causes
.Xr pw 8
to respond by printing a randomly generated password on stdout.
This is the preferred and most secure option.
-.Xr pw 8
+.Xr Pw 8
also provides a method of setting a specific password for the new
user via a filehandle (command lines are not secure).
.Pp
@@ -148,7 +148,7 @@ previous user or group deletions.
Note that if the default group is not specified using the
.Ar defaultgroup
keyword,
-Xr pw 8
+.Xr pw 8
will create a new group for the user and attempt to keep the new
user's uid and gid the same.
If the new user's uid is currently in use as a group id, then the next
@@ -168,8 +168,8 @@ new home directory is constructed.
This is
.Pa /usr/share/skel
by default.
-.Xr pw 8 's
-.Ql \&-m
+.Xr Pw 8 's
+.Fl m
option causes the user's home directory to be created and populated
using the files contained in the
.Ar skeleton
@@ -240,7 +240,7 @@ file.
This is useful where all users share some resources, and is preferable
to placing users into the same primary group.
The effect of this keyword can be overridden using the
-.Ql \&-G
+.Fl G
option on the
.Xr pw 8
command line.
@@ -264,9 +264,9 @@ minimum and maximum respectively.
The user and group id's actually used when creating an account with
.Xr pw 8
may be overridden using the
-.Ql \&-u
+.Fl u
and
-.Ql \&-g
+.Fl g
command line options.
.Pp
The
@@ -299,5 +299,3 @@ as comments.
.Xr login.conf 5 ,
.Xr passwd 5 ,
.Xr pw 8
-
-
diff --git a/usr.sbin/pw/pw.h b/usr.sbin/pw/pw.h
index 4383a11..b52891a 100644
--- a/usr.sbin/pw/pw.h
+++ b/usr.sbin/pw/pw.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: pw.h,v 1.6 1997/02/22 16:12:27 peter Exp $
*/
#include <stdio.h>
@@ -98,7 +98,6 @@ struct userconf *read_userconfig(char const * file);
int write_userconfig(char const * file);
struct carg *addarg(struct cargs * _args, int ch, char *argstr);
struct carg *getarg(struct cargs * _args, int ch);
-void cmderr(int ec, char const * fmt,...);
int pw_user(struct userconf * cnf, int mode, struct cargs * _args);
int pw_group(struct userconf * cnf, int mode, struct cargs * _args);
diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c
index 144737f..63742a7 100644
--- a/usr.sbin/pw/pw_conf.c
+++ b/usr.sbin/pw/pw_conf.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id: pw_conf.c,v 1.5 1997/02/22 16:12:27 peter Exp $
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c
index b8c82b4..ce1b230 100644
--- a/usr.sbin/pw/pw_group.c
+++ b/usr.sbin/pw/pw_group.c
@@ -22,13 +22,17 @@
* 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.
- *
- * $Id$
*/
-#include <unistd.h>
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <ctype.h>
+#include <err.h>
#include <termios.h>
+#include <unistd.h>
#include "pw.h"
#include "bitmap.h"
@@ -80,7 +84,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
}
if (a_gid == NULL) {
if (a_name == NULL)
- cmderr(EX_DATAERR, "group name or id required\n");
+ errx(EX_DATAERR, "group name or id required");
if (mode != M_ADD && grp == NULL && isdigit(*a_name->val)) {
(a_gid = a_name)->ch = 'g';
@@ -102,7 +106,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
fakegroup.gr_mem = fmems;
return print_group(&fakegroup, getarg(args, 'P') != NULL);
}
- cmderr(EX_DATAERR, "unknown group `%s'\n", a_name ? a_name->val : a_gid->val);
+ errx(EX_DATAERR, "unknown group `%s'", a_name ? a_name->val : a_gid->val);
}
if (a_name == NULL) /* Needed later */
a_name = addarg(args, 'n', grp->gr_name);
@@ -114,7 +118,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
gid_t gid = grp->gr_gid;
if (delgrent(grp) == -1)
- cmderr(EX_IOERR, "Error updating group file: %s\n", strerror(errno));
+ err(EX_IOERR, "error updating group file");
pw_log(cnf, mode, W_GROUP, "%s(%ld) removed", a_name->val, (long) gid);
return EXIT_SUCCESS;
} else if (mode == M_PRINT)
@@ -127,9 +131,9 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
grp->gr_name = pw_checkname((u_char *)arg->val, 0);
} else {
if (a_name == NULL) /* Required */
- cmderr(EX_DATAERR, "group name required\n");
+ errx(EX_DATAERR, "group name required");
else if (grp != NULL) /* Exists */
- cmderr(EX_DATAERR, "group name `%s' already exists\n", a_name->val);
+ errx(EX_DATAERR, "group name `%s' already exists", a_name->val);
extendarray(&members, &grmembers, 200);
members[0] = NULL;
@@ -177,14 +181,14 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
fflush(stdout);
}
if (b < 0) {
- perror("-h file descriptor");
+ warn("-h file descriptor");
return EX_OSERR;
}
line[b] = '\0';
if ((p = strpbrk(line, " \t\r\n")) != NULL)
*p = '\0';
if (!*line)
- cmderr(EX_DATAERR, "empty password read on file descriptor %d\n", fd);
+ errx(EX_DATAERR, "empty password read on file descriptor %d", fd);
grp->gr_passwd = pw_pwcrypt(line);
}
}
@@ -210,7 +214,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
int j;
if ((pwd = getpwnam(p)) == NULL) {
if (!isdigit(*p) || (pwd = getpwuid((uid_t) atoi(p))) == NULL)
- cmderr(EX_NOUSER, "user `%s' does not exist\n", p);
+ errx(EX_NOUSER, "user `%s' does not exist", p);
}
/*
* Check for duplicates
@@ -229,12 +233,12 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args)
return print_group(grp, getarg(args, 'P') != NULL);
if ((mode == M_ADD && !addgrent(grp)) || (mode == M_UPDATE && !chggrent(a_name->val, grp))) {
- perror("group update");
+ warn("group update");
return EX_IOERR;
}
/* grp may have been invalidated */
if ((grp = getgrnam(a_name->val)) == NULL)
- cmderr(EX_SOFTWARE, "group disappeared during update\n");
+ errx(EX_SOFTWARE, "group disappeared during update");
pw_log(cnf, mode, W_GROUP, "%s(%ld)", grp->gr_name, (long) grp->gr_gid);
@@ -259,7 +263,7 @@ gr_gidpolicy(struct userconf * cnf, struct cargs * args)
gid = (gid_t) atol(a_gid->val);
if ((grp = getgrgid(gid)) != NULL && getarg(args, 'o') == NULL)
- cmderr(EX_DATAERR, "gid `%ld' has already been allocated\n", (long) grp->gr_gid);
+ errx(EX_DATAERR, "gid `%ld' has already been allocated", (long) grp->gr_gid);
} else {
struct bitmap bm;
@@ -300,7 +304,7 @@ gr_gidpolicy(struct userconf * cnf, struct cargs * args)
* Another sanity check
*/
if (gid < cnf->min_gid || gid > cnf->max_gid)
- cmderr(EX_SOFTWARE, "unable to allocate a new gid - range fully used\n");
+ errx(EX_SOFTWARE, "unable to allocate a new gid - range fully used");
bm_dealloc(&bm);
}
return gid;
diff --git a/usr.sbin/pw/pw_log.c b/usr.sbin/pw/pw_log.c
index 7a4ae9b..e11e5ee 100644
--- a/usr.sbin/pw/pw_log.c
+++ b/usr.sbin/pw/pw_log.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <fcntl.h>
#include "pw.h"
diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c
index 781cfdd..fe89685 100644
--- a/usr.sbin/pw/pw_nis.c
+++ b/usr.sbin/pw/pw_nis.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 652a21b..d10c528 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -22,20 +22,24 @@
* 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.
- *
- * $Id: pw_user.c,v 1.21 1997/06/14 00:23:49 ache Exp $
*/
-#include <unistd.h>
-#include <fcntl.h>
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <ctype.h>
-#include <paths.h>
+#include <err.h>
+#include <fcntl.h>
#include <sys/param.h>
#include <dirent.h>
+#include <paths.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <unistd.h>
#include <utmp.h>
#if defined(USE_MD5RAND)
#include <md5.h>
@@ -155,7 +159,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
cnf->home[--l] = '\0';
if (l < 2 || *cnf->home != '/') /* Check for absolute path name */
- cmderr(EX_DATAERR, "invalid base directory for home '%s'\n", cnf->home);
+ errx(EX_DATAERR, "invalid base directory for home '%s'", cnf->home);
if (stat(cnf->home, &st) == -1) {
char dbuf[MAXPATHLEN];
@@ -185,18 +189,18 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
goto direrr;
chown(dbuf, 0, 0);
} else if (!S_ISDIR(st.st_mode))
- cmderr(EX_OSFILE, "'%s' (root home parent) is not a directory\n", dbuf);
+ errx(EX_OSFILE, "'%s' (root home parent) is not a directory", dbuf);
*p = '/';
}
}
if (stat(dbuf, &st) == -1) {
if (mkdir(dbuf, 0755) == -1) {
- direrr: cmderr(EX_OSFILE, "mkdir '%s': %s\n", dbuf, strerror(errno));
+ direrr: err(EX_OSFILE, "mkdir '%s'", dbuf);
}
chown(dbuf, 0, 0);
}
} else if (!S_ISDIR(st.st_mode))
- cmderr(EX_OSFILE, "root home `%s' is not a directory\n", cnf->home);
+ errx(EX_OSFILE, "root home `%s' is not a directory", cnf->home);
}
@@ -213,7 +217,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
p = arg->val;
if ((grp = getgrnam(p)) == NULL) {
if (!isdigit(*p) || (grp = getgrgid((gid_t) atoi(p))) == NULL)
- cmderr(EX_NOUSER, "group `%s' does not exist\n", p);
+ errx(EX_NOUSER, "group `%s' does not exist", p);
}
cnf->default_group = newstr(grp->gr_name);
}
@@ -226,7 +230,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
for (p = strtok(arg->val, ", \t"); p != NULL; p = strtok(NULL, ", \t")) {
if ((grp = getgrnam(p)) == NULL) {
if (!isdigit(*p) || (grp = getgrgid((gid_t) atoi(p))) == NULL)
- cmderr(EX_NOUSER, "group `%s' does not exist\n", p);
+ errx(EX_NOUSER, "group `%s' does not exist", p);
}
if (extendarray(&cnf->groups, &cnf->numgroups, i + 2) != -1)
cnf->groups[i++] = newstr(grp->gr_name);
@@ -236,14 +240,14 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
if ((arg = getarg(args, 'k')) != NULL) {
if (stat(cnf->dotdir = arg->val, &st) == -1 || !S_ISDIR(st.st_mode))
- cmderr(EX_OSFILE, "skeleton `%s' is not a directory or does not exist\n", cnf->dotdir);
+ errx(EX_OSFILE, "skeleton `%s' is not a directory or does not exist", cnf->dotdir);
}
if ((arg = getarg(args, 's')) != NULL)
cnf->shell_default = arg->val;
if (mode == M_ADD && getarg(args, 'D')) {
if (getarg(args, 'n') != NULL)
- cmderr(EX_DATAERR, "can't combine `-D' with `-n name'\n");
+ errx(EX_DATAERR, "can't combine `-D' with `-n name'");
if ((arg = getarg(args, 'u')) != NULL && (p = strtok(arg->val, ", \t")) != NULL) {
if ((cnf->min_uid = (uid_t) atoi(p)) == 0)
cnf->min_uid = 1000;
@@ -262,7 +266,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
arg = getarg(args, 'C');
if (write_userconfig(arg ? arg->val : NULL))
return EXIT_SUCCESS;
- perror("config update");
+ warn("config update");
return EX_IOERR;
}
if (mode == M_PRINT && getarg(args, 'a')) {
@@ -280,7 +284,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (a_uid == NULL) {
if (a_name == NULL)
- cmderr(EX_DATAERR, "user name or id required\n");
+ errx(EX_DATAERR, "user name or id required");
/*
* Determine whether 'n' switch is name or uid - we don't
@@ -306,8 +310,8 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
return print_user(&fakeuser, getarg(args, 'P') != NULL);
}
if (a_name == NULL)
- cmderr(EX_NOUSER, "no such uid `%s'\n", a_uid->val);
- cmderr(EX_NOUSER, "no such user `%s'\n", a_name->val);
+ errx(EX_NOUSER, "no such uid `%s'", a_uid->val);
+ errx(EX_NOUSER, "no such user `%s'", a_name->val);
}
if (a_name == NULL) /* May be needed later */
a_name = addarg(args, 'n', newstr(pwd->pw_name));
@@ -321,7 +325,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
uid_t uid = pwd->pw_uid;
if (strcmp(pwd->pw_name, "root") == 0)
- cmderr(EX_DATAERR, "cannot remove user 'root'\n");
+ errx(EX_DATAERR, "cannot remove user 'root'");
/*
* Remove skey record from /etc/skeykeys
@@ -346,10 +350,10 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
home[sizeof home - 1] = '\0';
if (!delpwent(pwd))
- cmderr(EX_IOERR, "Error updating passwd file: %s\n", strerror(errno));
+ err(EX_IOERR, "error updating passwd file");
if (cnf->nispasswd && *cnf->nispasswd=='/' && !delnispwent(cnf->nispasswd, a_name->val))
- perror("WARNING: NIS passwd update");
+ warn("WARNING: NIS passwd update");
editgroups(a_name->val, NULL);
@@ -386,15 +390,15 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if ((arg = getarg(args, 'l')) != NULL) {
if (strcmp(pwd->pw_name, "root") == 0)
- cmderr(EX_DATAERR, "can't rename `root' account\n");
+ errx(EX_DATAERR, "can't rename `root' account");
pwd->pw_name = pw_checkname((u_char *)arg->val, 0);
}
if ((arg = getarg(args, 'u')) != NULL && isdigit(*arg->val)) {
pwd->pw_uid = (uid_t) atol(arg->val);
if (pwd->pw_uid != 0 && strcmp(pwd->pw_name, "root") == 0)
- cmderr(EX_DATAERR, "can't change uid of `root' account\n");
+ errx(EX_DATAERR, "can't change uid of `root' account");
if (pwd->pw_uid == 0 && strcmp(pwd->pw_name, "root") != 0)
- fprintf(stderr, "WARNING: account `%s' will have a uid of 0 (superuser access!)\n", pwd->pw_name);
+ warnx("WARNING: account `%s' will have a uid of 0 (superuser access!)", pwd->pw_name);
}
if ((arg = getarg(args, 'g')) != NULL && pwd->pw_uid != 0) /* Already checked this */
pwd->pw_gid = (gid_t) getgrnam(cnf->default_group)->gr_gid;
@@ -407,7 +411,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
time_t expire = parse_date(now, arg->val);
if (now == expire)
- cmderr(EX_DATAERR, "Invalid password change date `%s'\n", arg->val);
+ errx(EX_DATAERR, "invalid password change date `%s'", arg->val);
pwd->pw_change = expire;
}
}
@@ -419,7 +423,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
time_t expire = parse_date(now, arg->val);
if (now == expire)
- cmderr(EX_DATAERR, "Invalid account expiry date `%s'\n", arg->val);
+ errx(EX_DATAERR, "invalid account expiry date `%s'", arg->val);
pwd->pw_expire = expire;
}
}
@@ -432,9 +436,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if ((arg = getarg(args, 'd')) != NULL) {
if (stat(pwd->pw_dir = arg->val, &st) == -1) {
if (getarg(args, 'm') == NULL && strcmp(pwd->pw_dir, "/nonexistent") != 0)
- fprintf(stderr, "WARNING: home `%s' does not exist\n", pwd->pw_dir);
+ warnx("WARNING: home `%s' does not exist", pwd->pw_dir);
} else if (!S_ISDIR(st.st_mode))
- fprintf(stderr, "WARNING: home `%s' is not a directory\n", pwd->pw_dir);
+ warnx("WARNING: home `%s' is not a directory", pwd->pw_dir);
}
if ((arg = getarg(args, 'w')) != NULL && getarg(args, 'h') == NULL)
@@ -442,9 +446,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
} else {
if (a_name == NULL) /* Required */
- cmderr(EX_DATAERR, "login name required\n");
+ errx(EX_DATAERR, "login name required");
else if ((pwd = getpwnam(a_name->val)) != NULL) /* Exists */
- cmderr(EX_DATAERR, "login name `%s' already exists\n", a_name->val);
+ errx(EX_DATAERR, "login name `%s' already exists", a_name->val);
/*
* Now, set up defaults for a new user
@@ -461,7 +465,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
pwd->pw_shell = pw_shellpolicy(cnf, args, NULL);
if (pwd->pw_uid == 0 && strcmp(pwd->pw_name, "root") != 0)
- fprintf(stderr, "WARNING: new account `%s' has a uid of 0 (superuser access!)\n", pwd->pw_name);
+ warnx("WARNING: new account `%s' has a uid of 0 (superuser access!)", pwd->pw_name);
}
/*
@@ -499,14 +503,14 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
fflush(stdout);
}
if (b < 0) {
- perror("-h file descriptor");
+ warn("-h file descriptor");
return EX_IOERR;
}
line[b] = '\0';
if ((p = strpbrk(line, " \t\r\n")) != NULL)
*p = '\0';
if (!*line)
- cmderr(EX_DATAERR, "empty password read on file descriptor %d\n", fd);
+ errx(EX_DATAERR, "empty password read on file descriptor %d", fd);
pwd->pw_passwd = pw_pwcrypt(line);
}
}
@@ -529,10 +533,10 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
}
if (!r) {
- perror("password update");
+ warn("password update");
return EX_IOERR;
} else if (!r1) {
- perror("WARNING: NIS password update");
+ warn("WARNING: NIS password update");
/* Keep on trucking */
}
@@ -545,7 +549,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
/* pwd may have been invalidated */
if ((pwd = getpwnam(a_name->val)) == NULL)
- cmderr(EX_NOUSER, "user '%s' disappeared during update\n", a_name->val);
+ errx(EX_NOUSER, "user '%s' disappeared during update", a_name->val);
grp = getgrgid(pwd->pw_gid);
pw_log(cnf, mode, W_USER, "%s(%ld):%s(%d):%s:%s:%s",
@@ -573,7 +577,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
FILE *pfp = popen(_PATH_SENDMAIL " -t", "w");
if (pfp == NULL)
- perror("sendmail");
+ warn("sendmail");
else {
fprintf(pfp, "From: root\n" "To: %s\n" "Subject: Welcome!\n\n", pwd->pw_name);
while (fgets(line, sizeof(line), fp) != NULL) {
@@ -615,7 +619,7 @@ pw_uidpolicy(struct userconf * cnf, struct cargs * args)
uid = (uid_t) atol(a_uid->val);
if ((pwd = getpwuid(uid)) != NULL && getarg(args, 'o') == NULL)
- cmderr(EX_DATAERR, "uid `%ld' has already been allocated\n", (long) pwd->pw_uid);
+ errx(EX_DATAERR, "uid `%ld' has already been allocated", (long) pwd->pw_uid);
} else {
struct bitmap bm;
@@ -650,7 +654,7 @@ pw_uidpolicy(struct userconf * cnf, struct cargs * args)
* Another sanity check
*/
if (uid < cnf->min_uid || uid > cnf->max_uid)
- cmderr(EX_SOFTWARE, "unable to allocate a new uid - range fully used\n");
+ errx(EX_SOFTWARE, "unable to allocate a new uid - range fully used");
bm_dealloc(&bm);
}
return uid;
@@ -678,7 +682,7 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer
if ((grp = getgrnam(a_gid->val)) == NULL) {
gid = (gid_t) atol(a_gid->val);
if ((gid == 0 && !isdigit(*a_gid->val)) || (grp = getgrgid(gid)) == NULL)
- cmderr(EX_NOUSER, "group `%s' is not defined\n", a_gid->val);
+ errx(EX_NOUSER, "group `%s' is not defined", a_gid->val);
}
gid = grp->gr_gid;
} else if ((grp = getgrnam(nam)) != NULL && grp->gr_mem[0] == NULL) {
@@ -736,7 +740,7 @@ pw_pwdpolicy(struct userconf * cnf, struct cargs * args)
if (arg != NULL) {
if ((result = parse_date(now, arg->val)) == now)
- cmderr(EX_DATAERR, "invalid date/time `%s'\n", arg->val);
+ errx(EX_DATAERR, "invalid date/time `%s'", arg->val);
} else if (cnf->password_days > 0)
result = now + ((long) cnf->password_days * 86400L);
return result;
@@ -752,7 +756,7 @@ pw_exppolicy(struct userconf * cnf, struct cargs * args)
if (arg != NULL) {
if ((result = parse_date(now, arg->val)) == now)
- cmderr(EX_DATAERR, "invalid date/time `%s'\n", arg->val);
+ errx(EX_DATAERR, "invalid date/time `%s'", arg->val);
} else if (cnf->expire_days > 0)
result = now + ((long) cnf->expire_days * 86400L);
return result;
@@ -770,7 +774,7 @@ pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
static char home[128];
if (cnf->home == NULL || *cnf->home == '\0')
- cmderr(EX_CONFIG, "no base home directory set\n");
+ errx(EX_CONFIG, "no base home directory set");
sprintf(home, "%s/%s", cnf->home, user);
return home;
}
@@ -806,8 +810,8 @@ shell_path(char const * path, char *shells[], char *sh)
}
}
if (sh == NULL)
- cmderr(EX_OSFILE, "can't find shell `%s' in shell paths\n", sh);
- cmderr(EX_CONFIG, "no default shell available or defined\n");
+ errx(EX_OSFILE, "can't find shell `%s' in shell paths", sh);
+ errx(EX_CONFIG, "no default shell available or defined");
return NULL;
}
}
@@ -1041,14 +1045,14 @@ pw_checkname(u_char *name, int gecos)
if (strchr(notch, name[l]) != NULL || name[l] < ' ' || name[l] == 127 ||
(!gecos && l==0 && name[l] == '-') || /* leading '-' */
(!gecos && name[l] & 0x80)) /* 8-bit */
- cmderr(EX_DATAERR, (name[l] >= ' ' && name[l] < 127)
- ? "invalid character `%c' in field\n"
- : "invalid character 0x%02x in field\n",
+ errx(EX_DATAERR, (name[l] >= ' ' && name[l] < 127)
+ ? "invalid character `%c' in field"
+ : "invalid character 0x%02x in field",
name[l]);
++l;
}
if (!gecos && l > LOGNAMESIZE)
- cmderr(EX_DATAERR, "name too long `%s'\n", name);
+ errx(EX_DATAERR, "name too long `%s'", name);
return (char *)name;
}
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index 1162d0c..0b68266 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/usr.sbin/pw/rm_r.c b/usr.sbin/pw/rm_r.c
index 3394469..f671486 100644
--- a/usr.sbin/pw/rm_r.c
+++ b/usr.sbin/pw/rm_r.c
@@ -22,10 +22,13 @@
* 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.
- *
- * $Id$
*/
+#ifndef lint
+static const char rcsid[] =
+ "$Id$";
+#endif /* not lint */
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
OpenPOWER on IntegriCloud