1996-12-09 14:05:35 +00:00
|
|
|
/*-
|
1996-12-10 23:59:04 +00:00
|
|
|
* Copyright (C) 1996
|
|
|
|
* David L. Nugent. All rights reserved.
|
1996-12-09 14:05:35 +00:00
|
|
|
*
|
|
|
|
* 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
|
1996-12-10 23:59:04 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1996-12-09 14:05:35 +00:00
|
|
|
* 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.
|
|
|
|
*
|
1996-12-10 23:59:04 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND
|
1996-12-09 14:05:35 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
1996-12-10 23:59:04 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
|
1996-12-09 14:05:35 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1997-10-10 06:23:42 +00:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] =
|
1999-08-28 01:35:59 +00:00
|
|
|
"$FreeBSD$";
|
1997-10-10 06:23:42 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <err.h>
|
1998-08-04 22:31:26 +00:00
|
|
|
#include <fcntl.h>
|
2000-06-22 16:48:41 +00:00
|
|
|
#include <locale.h>
|
1997-01-05 07:15:37 +00:00
|
|
|
#include <paths.h>
|
|
|
|
#include <sys/wait.h>
|
1999-02-23 07:15:11 +00:00
|
|
|
#include "pw.h"
|
1996-12-09 14:05:35 +00:00
|
|
|
|
2000-01-15 00:20:22 +00:00
|
|
|
#if !defined(_PATH_YP)
|
|
|
|
#define _PATH_YP "/var/yp/"
|
|
|
|
#endif
|
1999-10-26 08:34:09 +00:00
|
|
|
const char *Modes[] = {
|
|
|
|
"add", "del", "mod", "show", "next",
|
|
|
|
NULL};
|
1996-12-09 14:05:35 +00:00
|
|
|
const char *Which[] = {"user", "group", NULL};
|
1996-12-09 23:55:27 +00:00
|
|
|
static const char *Combo1[] = {
|
|
|
|
"useradd", "userdel", "usermod", "usershow", "usernext",
|
1999-10-26 08:34:09 +00:00
|
|
|
"lock", "unlock",
|
1996-12-09 23:55:27 +00:00
|
|
|
"groupadd", "groupdel", "groupmod", "groupshow", "groupnext",
|
|
|
|
NULL};
|
|
|
|
static const char *Combo2[] = {
|
|
|
|
"adduser", "deluser", "moduser", "showuser", "nextuser",
|
1999-10-26 08:34:09 +00:00
|
|
|
"lock", "unlock",
|
1996-12-09 23:55:27 +00:00
|
|
|
"addgroup", "delgroup", "modgroup", "showgroup", "nextgroup",
|
1999-10-26 08:34:09 +00:00
|
|
|
NULL};
|
1996-12-09 14:05:35 +00:00
|
|
|
|
1999-02-23 07:15:11 +00:00
|
|
|
struct pwf PWF =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
setpwent,
|
|
|
|
endpwent,
|
|
|
|
getpwent,
|
|
|
|
getpwuid,
|
|
|
|
getpwnam,
|
|
|
|
setgrent,
|
|
|
|
endgrent,
|
|
|
|
getgrent,
|
|
|
|
getgrgid,
|
|
|
|
getgrnam,
|
|
|
|
|
|
|
|
};
|
|
|
|
struct pwf VPWF =
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
vsetpwent,
|
|
|
|
vendpwent,
|
|
|
|
vgetpwent,
|
|
|
|
vgetpwuid,
|
|
|
|
vgetpwnam,
|
|
|
|
vsetgrent,
|
|
|
|
vendgrent,
|
|
|
|
vgetgrent,
|
|
|
|
vgetgrgid,
|
|
|
|
vgetgrnam,
|
|
|
|
};
|
|
|
|
|
1996-12-09 14:05:35 +00:00
|
|
|
static struct cargs arglist;
|
|
|
|
|
|
|
|
static int getindex(const char *words[], const char *word);
|
|
|
|
static void cmdhelp(int mode, int which);
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
int mode = -1;
|
|
|
|
int which = -1;
|
1999-02-23 07:15:11 +00:00
|
|
|
char *config = NULL;
|
1996-12-09 14:05:35 +00:00
|
|
|
struct userconf *cnf;
|
2014-11-12 22:27:53 +00:00
|
|
|
struct stat st;
|
1996-12-09 14:05:35 +00:00
|
|
|
|
|
|
|
static const char *opts[W_NUM][M_NUM] =
|
|
|
|
{
|
1996-12-09 23:55:27 +00:00
|
|
|
{ /* user */
|
2007-03-26 23:29:20 +00:00
|
|
|
"V:C:qn:u:c:d:e:p:g:G:mM:k:s:oL:i:w:h:H:Db:NPy:Y",
|
1999-02-23 10:35:47 +00:00
|
|
|
"V:C:qn:u:rY",
|
2007-03-26 23:29:20 +00:00
|
|
|
"V:C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:FNPY",
|
1999-03-02 00:53:33 +00:00
|
|
|
"V:C:qn:u:FPa7",
|
1999-10-26 08:34:09 +00:00
|
|
|
"V:C:q",
|
|
|
|
"V:C:q",
|
1999-02-23 10:35:47 +00:00
|
|
|
"V:C:q"
|
1996-12-09 23:55:27 +00:00
|
|
|
},
|
|
|
|
{ /* grp */
|
2006-09-18 14:00:39 +00:00
|
|
|
"V:C:qn:g:h:H:M:opNPY",
|
1999-02-23 10:35:47 +00:00
|
|
|
"V:C:qn:g:Y",
|
2008-02-23 01:25:22 +00:00
|
|
|
"V:C:qn:d:g:l:h:H:FM:m:NPY",
|
1999-02-23 10:35:47 +00:00
|
|
|
"V:C:qn:g:FPa",
|
|
|
|
"V:C:q"
|
1996-12-09 23:55:27 +00:00
|
|
|
}
|
1996-12-09 14:05:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int (*funcs[W_NUM]) (struct userconf * _cnf, int _mode, struct cargs * _args) =
|
|
|
|
{ /* Request handlers */
|
|
|
|
pw_user,
|
|
|
|
pw_group
|
|
|
|
};
|
|
|
|
|
|
|
|
LIST_INIT(&arglist);
|
|
|
|
|
2000-06-24 13:36:13 +00:00
|
|
|
(void)setlocale(LC_ALL, "");
|
2000-06-22 16:48:41 +00:00
|
|
|
|
1996-12-09 14:05:35 +00:00
|
|
|
/*
|
|
|
|
* Break off the first couple of words to determine what exactly
|
|
|
|
* we're being asked to do
|
|
|
|
*/
|
1999-02-23 07:15:11 +00:00
|
|
|
while (argc > 1) {
|
1996-12-09 14:05:35 +00:00
|
|
|
int tmp;
|
|
|
|
|
1999-02-23 07:15:11 +00:00
|
|
|
if (*argv[1] == '-') {
|
|
|
|
/*
|
|
|
|
* Special case, allow pw -V<dir> <operation> [args] for scripts etc.
|
|
|
|
*/
|
|
|
|
if (argv[1][1] == 'V') {
|
|
|
|
optarg = &argv[1][2];
|
|
|
|
if (*optarg == '\0') {
|
2014-11-12 22:27:53 +00:00
|
|
|
if (stat(argv[2], &st) != 0)
|
|
|
|
errx(EX_OSFILE, \
|
|
|
|
"no such directory `%s'",
|
|
|
|
argv[2]);
|
|
|
|
if (!S_ISDIR(st.st_mode))
|
|
|
|
errx(EX_OSFILE, "`%s' not a "
|
|
|
|
"directory", argv[2]);
|
1999-02-23 07:15:11 +00:00
|
|
|
optarg = argv[2];
|
|
|
|
++argv;
|
|
|
|
--argc;
|
|
|
|
}
|
|
|
|
addarg(&arglist, 'V', optarg);
|
1999-02-23 10:35:47 +00:00
|
|
|
} else
|
|
|
|
break;
|
1999-02-23 07:15:11 +00:00
|
|
|
}
|
2000-06-18 02:39:17 +00:00
|
|
|
else if (mode == -1 && (tmp = getindex(Modes, argv[1])) != -1)
|
1996-12-09 14:05:35 +00:00
|
|
|
mode = tmp;
|
2000-06-18 02:39:17 +00:00
|
|
|
else if (which == -1 && (tmp = getindex(Which, argv[1])) != -1)
|
1996-12-09 14:05:35 +00:00
|
|
|
which = tmp;
|
2000-06-18 02:39:17 +00:00
|
|
|
else if ((mode == -1 && which == -1) &&
|
|
|
|
((tmp = getindex(Combo1, argv[1])) != -1 ||
|
|
|
|
(tmp = getindex(Combo2, argv[1])) != -1)) {
|
1996-12-09 14:05:35 +00:00
|
|
|
which = tmp / M_NUM;
|
|
|
|
mode = tmp % M_NUM;
|
2000-06-18 02:39:17 +00:00
|
|
|
} else if (strcmp(argv[1], "help") == 0 && argv[2] == NULL)
|
1996-12-09 14:05:35 +00:00
|
|
|
cmdhelp(mode, which);
|
1999-02-23 11:01:50 +00:00
|
|
|
else if (which != -1 && mode != -1)
|
1996-12-09 14:05:35 +00:00
|
|
|
addarg(&arglist, 'n', argv[1]);
|
|
|
|
else
|
1997-10-10 06:23:42 +00:00
|
|
|
errx(EX_USAGE, "unknown keyword `%s'", argv[1]);
|
1996-12-09 14:05:35 +00:00
|
|
|
++argv;
|
|
|
|
--argc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bail out unless the user is specific!
|
|
|
|
*/
|
|
|
|
if (mode == -1 || which == -1)
|
|
|
|
cmdhelp(mode, which);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
optarg = NULL;
|
|
|
|
|
|
|
|
while ((ch = getopt(argc, argv, opts[which][mode])) != -1) {
|
|
|
|
if (ch == '?')
|
2000-01-15 00:20:22 +00:00
|
|
|
errx(EX_USAGE, "unknown switch");
|
1996-12-09 14:05:35 +00:00
|
|
|
else
|
|
|
|
addarg(&arglist, ch, optarg);
|
|
|
|
optarg = NULL;
|
|
|
|
}
|
|
|
|
|
1996-12-09 23:55:27 +00:00
|
|
|
/*
|
|
|
|
* Must be root to attempt an update
|
|
|
|
*/
|
1997-07-17 08:37:47 +00:00
|
|
|
if (geteuid() != 0 && mode != M_PRINT && mode != M_NEXT && getarg(&arglist, 'N')==NULL)
|
1997-10-10 06:23:42 +00:00
|
|
|
errx(EX_NOPERM, "you must be root to run this program");
|
1996-12-09 23:55:27 +00:00
|
|
|
|
1996-12-09 14:05:35 +00:00
|
|
|
/*
|
|
|
|
* We should immediately look for the -q 'quiet' switch so that we
|
|
|
|
* don't bother with extraneous errors
|
|
|
|
*/
|
|
|
|
if (getarg(&arglist, 'q') != NULL)
|
2000-12-09 09:35:55 +00:00
|
|
|
freopen(_PATH_DEVNULL, "w", stderr);
|
1996-12-09 14:05:35 +00:00
|
|
|
|
1999-02-23 07:15:11 +00:00
|
|
|
/*
|
|
|
|
* Set our base working path if not overridden
|
|
|
|
*/
|
|
|
|
|
|
|
|
config = getarg(&arglist, 'C') ? getarg(&arglist, 'C')->val : NULL;
|
|
|
|
|
|
|
|
if (getarg(&arglist, 'V') != NULL) {
|
|
|
|
char * etcpath = getarg(&arglist, 'V')->val;
|
|
|
|
if (*etcpath) {
|
|
|
|
if (config == NULL) { /* Only override config location if -C not specified */
|
2015-05-31 10:02:01 +00:00
|
|
|
asprintf(&config, "%s/pw.conf", etcpath);
|
|
|
|
if (config == NULL)
|
|
|
|
errx(EX_OSERR, "out of memory");
|
1999-02-23 07:15:11 +00:00
|
|
|
}
|
|
|
|
memcpy(&PWF, &VPWF, sizeof PWF);
|
|
|
|
setpwdir(etcpath);
|
|
|
|
setgrdir(etcpath);
|
|
|
|
}
|
|
|
|
}
|
2008-02-23 01:17:42 +00:00
|
|
|
|
1996-12-09 14:05:35 +00:00
|
|
|
/*
|
|
|
|
* Now, let's do the common initialisation
|
|
|
|
*/
|
1999-02-23 07:15:11 +00:00
|
|
|
cnf = read_userconfig(config);
|
1998-08-04 22:31:26 +00:00
|
|
|
|
1998-08-04 22:20:11 +00:00
|
|
|
ch = funcs[which] (cnf, mode, &arglist);
|
1997-01-05 07:15:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If everything went ok, and we've been asked to update
|
|
|
|
* the NIS maps, then do it now
|
|
|
|
*/
|
|
|
|
if (ch == EXIT_SUCCESS && getarg(&arglist, 'Y') != NULL) {
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
fflush(NULL);
|
|
|
|
if (chdir(_PATH_YP) == -1)
|
1997-10-10 06:23:42 +00:00
|
|
|
warn("chdir(" _PATH_YP ")");
|
1997-01-05 07:15:37 +00:00
|
|
|
else if ((pid = fork()) == -1)
|
1997-10-10 06:23:42 +00:00
|
|
|
warn("fork()");
|
1997-01-05 07:15:37 +00:00
|
|
|
else if (pid == 0) {
|
|
|
|
/* Is make anywhere else? */
|
2001-07-09 09:24:06 +00:00
|
|
|
execlp("/usr/bin/make", "make", (char *)NULL);
|
1997-01-05 07:15:37 +00:00
|
|
|
_exit(1);
|
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
waitpid(pid, &i, 0);
|
|
|
|
if ((i = WEXITSTATUS(i)) != 0)
|
1997-10-10 06:23:42 +00:00
|
|
|
errx(ch, "make exited with status %d", i);
|
1997-01-05 07:15:37 +00:00
|
|
|
else
|
|
|
|
pw_log(cnf, mode, which, "NIS maps updated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ch;
|
1996-12-09 14:05:35 +00:00
|
|
|
}
|
|
|
|
|
1998-08-04 22:31:26 +00:00
|
|
|
|
1996-12-09 14:05:35 +00:00
|
|
|
static int
|
|
|
|
getindex(const char *words[], const char *word)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (words[i]) {
|
|
|
|
if (strcmp(words[i], word) == 0)
|
|
|
|
return i;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is probably an overkill for a cmdline help system, but it reflects
|
|
|
|
* the complexity of the command line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
cmdhelp(int mode, int which)
|
|
|
|
{
|
|
|
|
if (which == -1)
|
1999-10-26 08:34:09 +00:00
|
|
|
fprintf(stderr, "usage:\n pw [user|group|lock|unlock] [add|del|mod|show|next] [help|switches/values]\n");
|
1996-12-09 14:05:35 +00:00
|
|
|
else if (mode == -1)
|
1999-10-26 08:34:09 +00:00
|
|
|
fprintf(stderr, "usage:\n pw %s [add|del|mod|show|next] [help|switches/values]\n", Which[which]);
|
1996-12-09 14:05:35 +00:00
|
|
|
else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to give mode specific help
|
|
|
|
*/
|
|
|
|
static const char *help[W_NUM][M_NUM] =
|
|
|
|
{
|
|
|
|
{
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw useradd [name] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n"
|
|
|
|
" Adding users:\n"
|
|
|
|
"\t-n name login name\n"
|
|
|
|
"\t-u uid user id\n"
|
|
|
|
"\t-c comment user name/comment\n"
|
|
|
|
"\t-d directory home directory\n"
|
|
|
|
"\t-e date account expiry date\n"
|
|
|
|
"\t-p date password expiry date\n"
|
|
|
|
"\t-g grp initial group\n"
|
|
|
|
"\t-G grp1,grp2 additional groups\n"
|
|
|
|
"\t-m [ -k dir ] create and set up home\n"
|
2007-03-30 10:02:47 +00:00
|
|
|
"\t-M mode home directory permissions\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-s shell name of login shell\n"
|
|
|
|
"\t-o duplicate uid ok\n"
|
|
|
|
"\t-L class user class\n"
|
|
|
|
"\t-h fd read password on fd\n"
|
2004-01-11 18:28:08 +00:00
|
|
|
"\t-H fd read encrypted password on fd\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-Y update NIS maps\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-N no update\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
" Setting defaults:\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
|
|
|
"\t-D set user defaults\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-b dir default home root dir\n"
|
|
|
|
"\t-e period default expiry period\n"
|
|
|
|
"\t-p period default password change period\n"
|
|
|
|
"\t-g group default group\n"
|
|
|
|
"\t-G grp1,grp2 additional groups\n"
|
|
|
|
"\t-L class default user class\n"
|
|
|
|
"\t-k dir default home skeleton\n"
|
2007-03-30 11:23:10 +00:00
|
|
|
"\t-M mode home directory permissions\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-u min,max set min,max uids\n"
|
|
|
|
"\t-i min,max set min,max gids\n"
|
|
|
|
"\t-w method set default password method\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-s shell default shell\n"
|
|
|
|
"\t-y path set NIS passwd file path\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw userdel [uid|name] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-n name login name\n"
|
|
|
|
"\t-u uid user id\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-Y update NIS maps\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-r remove home & contents\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw usermod [uid|name] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n"
|
|
|
|
"\t-F force add if no user\n"
|
|
|
|
"\t-n name login name\n"
|
|
|
|
"\t-u uid user id\n"
|
|
|
|
"\t-c comment user name/comment\n"
|
|
|
|
"\t-d directory home directory\n"
|
|
|
|
"\t-e date account expiry date\n"
|
|
|
|
"\t-p date password expiry date\n"
|
|
|
|
"\t-g grp initial group\n"
|
|
|
|
"\t-G grp1,grp2 additional groups\n"
|
|
|
|
"\t-l name new login name\n"
|
|
|
|
"\t-L class user class\n"
|
|
|
|
"\t-m [ -k dir ] create and set up home\n"
|
2007-03-30 10:02:47 +00:00
|
|
|
"\t-M mode home directory permissions\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-s shell name of login shell\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-w method set new password using method\n"
|
|
|
|
"\t-h fd read password on fd\n"
|
2004-01-11 18:28:08 +00:00
|
|
|
"\t-H fd read encrypted password on fd\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-Y update NIS maps\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-N no update\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw usershow [uid|name] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-n name login name\n"
|
|
|
|
"\t-u uid user id\n"
|
|
|
|
"\t-F force print\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-P prettier format\n"
|
1999-03-02 00:53:33 +00:00
|
|
|
"\t-a print all users\n"
|
|
|
|
"\t-7 print in v7 format\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw usernext [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-C config configuration file\n"
|
2001-03-14 03:24:30 +00:00
|
|
|
"\t-q quiet operation\n",
|
|
|
|
"usage pw: lock [switches]\n"
|
|
|
|
"\t-V etcdir alternate /etc locations\n"
|
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n",
|
|
|
|
"usage pw: unlock [switches]\n"
|
|
|
|
"\t-V etcdir alternate /etc locations\n"
|
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
},
|
|
|
|
{
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw groupadd [group|gid] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n"
|
|
|
|
"\t-n group group name\n"
|
|
|
|
"\t-g gid group id\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-M usr1,usr2 add users as group members\n"
|
|
|
|
"\t-o duplicate gid ok\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-Y update NIS maps\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-N no update\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw groupdel [group|gid] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-n name group name\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-g gid group id\n"
|
|
|
|
"\t-Y update NIS maps\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw groupmod [group|gid] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-C config configuration file\n"
|
|
|
|
"\t-q quiet operation\n"
|
|
|
|
"\t-F force add if not exists\n"
|
|
|
|
"\t-n name group name\n"
|
|
|
|
"\t-g gid group id\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-M usr1,usr2 replaces users as group members\n"
|
|
|
|
"\t-m usr1,usr2 add users as group members\n"
|
2008-02-23 01:25:22 +00:00
|
|
|
"\t-d usr1,usr2 delete users as group members\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-l name new group name\n"
|
1997-01-05 07:15:37 +00:00
|
|
|
"\t-Y update NIS maps\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-N no update\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw groupshow [group|gid] [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
"\t-n name group name\n"
|
|
|
|
"\t-g gid group id\n"
|
|
|
|
"\t-F force print\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-P prettier format\n"
|
|
|
|
"\t-a print all accounting groups\n",
|
1997-10-10 06:23:42 +00:00
|
|
|
"usage: pw groupnext [switches]\n"
|
1999-02-23 07:15:11 +00:00
|
|
|
"\t-V etcdir alternate /etc location\n"
|
1996-12-09 23:55:27 +00:00
|
|
|
"\t-C config configuration file\n"
|
2001-03-14 03:24:30 +00:00
|
|
|
"\t-q quiet operation\n"
|
1996-12-09 14:05:35 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-07-05 08:01:15 +00:00
|
|
|
fprintf(stderr, "%s", help[which][mode]);
|
1996-12-09 14:05:35 +00:00
|
|
|
}
|
1996-12-09 23:55:27 +00:00
|
|
|
exit(EXIT_FAILURE);
|
1996-12-09 14:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct carg *
|
|
|
|
getarg(struct cargs * _args, int ch)
|
|
|
|
{
|
2000-12-29 18:04:54 +00:00
|
|
|
struct carg *c = LIST_FIRST(_args);
|
1996-12-09 14:05:35 +00:00
|
|
|
|
|
|
|
while (c != NULL && c->ch != ch)
|
2000-12-29 18:04:54 +00:00
|
|
|
c = LIST_NEXT(c, list);
|
1996-12-09 14:05:35 +00:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct carg *
|
|
|
|
addarg(struct cargs * _args, int ch, char *argstr)
|
|
|
|
{
|
|
|
|
struct carg *ca = malloc(sizeof(struct carg));
|
|
|
|
|
|
|
|
if (ca == NULL)
|
1997-10-10 06:23:42 +00:00
|
|
|
errx(EX_OSERR, "out of memory");
|
1996-12-09 14:05:35 +00:00
|
|
|
ca->ch = ch;
|
|
|
|
ca->val = argstr;
|
|
|
|
LIST_INSERT_HEAD(_args, ca, list);
|
|
|
|
return ca;
|
|
|
|
}
|