summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajacoutot <ajacoutot@openbsd.org>2011-12-31 14:05:51 +0000
committerajacoutot <ajacoutot@openbsd.org>2011-12-31 14:05:51 +0000
commit5c797a001299fb6cd8c6b562e271346c92db640f (patch)
tree9f5d520e1ba72b8e0b6e73fe891796021c1a3552
parentAdd rsu(4) to the sgi GENERICs (but not the RAMDISKs as it requires firmware (diff)
downloadwireguard-openbsd-5c797a001299fb6cd8c6b562e271346c92db640f.tar.xz
wireguard-openbsd-5c797a001299fb6cd8c6b562e271346c92db640f.zip
Remove the EXTENSIONS ifdef danse; it might have made sense in the past
but user(8) behaviour has become OS specific in time so there's no sense keeping this. We are OpenBSD and we use BSD EXTENSIONS unconditionally. ok miod@ millert@ deraadt@
-rw-r--r--usr.sbin/user/Makefile4
-rw-r--r--usr.sbin/user/main.c6
-rw-r--r--usr.sbin/user/user.c132
-rw-r--r--usr.sbin/user/usermgmt.h5
4 files changed, 10 insertions, 137 deletions
diff --git a/usr.sbin/user/Makefile b/usr.sbin/user/Makefile
index 41a71e87ce1..f2f0c07b25a 100644
--- a/usr.sbin/user/Makefile
+++ b/usr.sbin/user/Makefile
@@ -1,10 +1,8 @@
-# $OpenBSD: Makefile,v 1.4 2011/04/16 07:41:08 sobrado Exp $
+# $OpenBSD: Makefile,v 1.5 2011/12/31 14:05:51 ajacoutot Exp $
PROG= user
SRCS= user.c main.c
-CFLAGS+= -DEXTENSIONS
-
LDADD+= -lutil
DPADD+= ${LIBUTIL}
diff --git a/usr.sbin/user/main.c b/usr.sbin/user/main.c
index 3b9e70b23b5..6e7d7612ef1 100644
--- a/usr.sbin/user/main.c
+++ b/usr.sbin/user/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.6 2003/06/08 22:13:01 millert Exp $ */
+/* $OpenBSD: main.c,v 1.7 2011/12/31 14:05:51 ajacoutot Exp $ */
/* $NetBSD: main.c,v 1.3 2002/07/09 10:34:16 tron Exp $ */
/*
@@ -58,20 +58,16 @@ static cmd_t cmds[] = {
{ 2, { "user", "mod" }, usermod },
{ 1, { "userdel", NULL }, userdel },
{ 2, { "user", "del" }, userdel },
-#ifdef EXTENSIONS
{ 1, { "userinfo", NULL }, userinfo },
{ 2, { "user", "info" }, userinfo },
-#endif
{ 1, { "groupadd", NULL }, groupadd },
{ 2, { "group", "add" }, groupadd },
{ 1, { "groupmod", NULL }, groupmod },
{ 2, { "group", "mod" }, groupmod },
{ 1, { "groupdel", NULL }, groupdel },
{ 2, { "group", "del" }, groupdel },
-#ifdef EXTENSIONS
{ 1, { "groupinfo", NULL }, groupinfo },
{ 2, { "group", "info" }, groupinfo },
-#endif
{ 0 }
};
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index 1a51f038ff0..b8e646dfcc1 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.85 2011/12/30 08:39:02 ajacoutot Exp $ */
+/* $OpenBSD: user.c,v 1.86 2011/12/31 14:05:51 ajacoutot Exp $ */
/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
/*
@@ -40,9 +40,7 @@
#include <err.h>
#include <fcntl.h>
#include <grp.h>
-#ifdef EXTENSIONS
#include <login_cap.h>
-#endif
#include <paths.h>
#include <pwd.h>
#include <stdarg.h>
@@ -646,7 +644,6 @@ valid_group(char *group)
return 1;
}
-#ifdef EXTENSIONS
/* return 1 if `class' exists */
static int
valid_class(char *class)
@@ -657,7 +654,6 @@ valid_class(char *class)
login_close(lc);
return lc != NULL;
}
-#endif
/* find the next gid in the range lo .. hi */
static int
@@ -671,7 +667,6 @@ getnextgid(uid_t *gidp, uid_t lo, uid_t hi)
return 0;
}
-#ifdef EXTENSIONS
/* save a range of uids */
static int
save_range(user_t *up, char *cp)
@@ -704,7 +699,6 @@ save_range(user_t *up, char *cp)
}
return 1;
}
-#endif
/* set the defaults in the defaults file */
static int
@@ -714,9 +708,7 @@ setdefaults(user_t *up)
FILE *fp;
int ret;
int fd;
-#ifdef EXTENSIONS
int i;
-#endif
(void) snprintf(template, sizeof(template), "%s.XXXXXXXX", CONFFILE);
if ((fd = mkstemp(template)) < 0) {
@@ -732,23 +724,19 @@ setdefaults(user_t *up)
fprintf(fp, "base_dir\t%s\n", up->u_basedir) <= 0 ||
fprintf(fp, "skel_dir\t%s\n", up->u_skeldir) <= 0 ||
fprintf(fp, "shell\t\t%s\n", up->u_shell) <= 0 ||
-#ifdef EXTENSIONS
fprintf(fp, "class\t\t%s\n", up->u_class) <= 0 ||
-#endif
fprintf(fp, "inactive\t%s\n", (up->u_inactive == NULL) ? UNSET_INACTIVE : up->u_inactive) <= 0 ||
fprintf(fp, "expire\t\t%s\n", (up->u_expire == NULL) ? UNSET_EXPIRY : up->u_expire) <= 0 ||
fprintf(fp, "preserve\t%s\n", (up->u_preserve == 0) ? "false" : "true") <= 0) {
warn("can't write to `%s'", CONFFILE);
ret = 0;
}
-#ifdef EXTENSIONS
for (i = (up->u_defrc != up->u_rc) ? up->u_defrc : 0 ; i < up->u_rc ; i++) {
if (fprintf(fp, "range\t\t%d..%d\n", up->u_rv[i].r_from, up->u_rv[i].r_to) <= 0) {
warn("can't write to `%s'", CONFFILE);
ret = 0;
}
}
-#endif
if (fclose(fp) == EOF) {
warn("can't write to `%s'", CONFFILE);
ret = 0;
@@ -775,9 +763,7 @@ read_defaults(user_t *up)
memsave(&up->u_skeldir, DEF_SKELDIR, strlen(DEF_SKELDIR));
memsave(&up->u_shell, DEF_SHELL, strlen(DEF_SHELL));
memsave(&up->u_comment, DEF_COMMENT, strlen(DEF_COMMENT));
-#ifdef EXTENSIONS
memsave(&up->u_class, DEF_CLASS, strlen(DEF_CLASS));
-#endif
up->u_rsize = 16;
up->u_defrc = 0;
NEWARRAY(range_t, up->u_rv, up->u_rsize, exit(1));
@@ -811,12 +797,10 @@ read_defaults(user_t *up)
for (cp = s + 8 ; isspace(*cp) ; cp++) {
}
memsave(&up->u_password, cp, strlen(cp));
-#ifdef EXTENSIONS
} else if (strncmp(s, "class", 5) == 0) {
for (cp = s + 5 ; isspace(*cp) ; cp++) {
}
memsave(&up->u_class, cp, strlen(cp));
-#endif
} else if (strncmp(s, "inactive", 8) == 0) {
for (cp = s + 8 ; isspace(*cp) ; cp++) {
}
@@ -828,20 +812,16 @@ read_defaults(user_t *up)
} else {
memsave(&up->u_inactive, cp, strlen(cp));
}
-#ifdef EXTENSIONS
} else if (strncmp(s, "range", 5) == 0) {
for (cp = s + 5 ; isspace(*cp) ; cp++) {
}
(void) save_range(up, cp);
-#endif
-#ifdef EXTENSIONS
} else if (strncmp(s, "preserve", 8) == 0) {
for (cp = s + 8 ; isspace(*cp) ; cp++) {
}
up->u_preserve = (strncmp(cp, "true", 4) == 0) ? 1 :
(strncmp(cp, "yes", 3) == 0) ? 1 :
atoi(cp);
-#endif
} else if (strncmp(s, "expire", 6) == 0) {
for (cp = s + 6 ; isspace(*cp) ; cp++) {
}
@@ -985,11 +965,9 @@ adduser(char *login_name, user_t *up)
if (!valid_login(login_name)) {
errx(EXIT_FAILURE, "`%s' is not a valid login name", login_name);
}
-#ifdef EXTENSIONS
if (!valid_class(up->u_class)) {
errx(EXIT_FAILURE, "No such login class `%s'", up->u_class);
}
-#endif
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) {
err(EXIT_FAILURE, "can't open `%s'", _PATH_MASTERPASSWD);
}
@@ -1137,11 +1115,7 @@ adduser(char *login_name, user_t *up)
password,
up->u_uid,
gid,
-#ifdef EXTENSIONS
up->u_class,
-#else
- "",
-#endif
(long) inactive,
(long) expire,
up->u_comment,
@@ -1482,7 +1456,6 @@ moduser(char *login_name, char *newlogin, user_t *up)
pwp->pw_dir = up->u_home;
if (up->u_flags & F_SHELL)
pwp->pw_shell = up->u_shell;
-#ifdef EXTENSIONS
if (up->u_flags & F_CLASS) {
if (!valid_class(up->u_class)) {
(void) close(ptmpfd);
@@ -1492,7 +1465,6 @@ moduser(char *login_name, char *newlogin, user_t *up)
}
pwp->pw_class = up->u_class;
}
-#endif
}
loginc = strlen(login_name);
while (fgets(buf, sizeof(buf), master) != NULL) {
@@ -1509,11 +1481,7 @@ moduser(char *login_name, char *newlogin, user_t *up)
pwp->pw_passwd,
pwp->pw_uid,
pwp->pw_gid,
-#ifdef EXTENSIONS
pwp->pw_class,
-#else
- "",
-#endif
(long)pwp->pw_change,
(long)pwp->pw_expire,
pwp->pw_gecos,
@@ -1590,7 +1558,6 @@ moduser(char *login_name, char *newlogin, user_t *up)
}
-#ifdef EXTENSIONS
/* see if we can find out the user struct */
static struct passwd *
find_user_info(char *name)
@@ -1605,9 +1572,7 @@ find_user_info(char *name)
}
return NULL;
}
-#endif
-#ifdef EXTENSIONS
/* see if we can find out the group struct */
static struct group *
find_group_info(char *name)
@@ -1622,7 +1587,6 @@ find_group_info(char *name)
}
return NULL;
}
-#endif
/* print out usage message, and then exit */
void
@@ -1658,10 +1622,8 @@ usermgmt_usage(const char *prog)
prog);
(void) fprintf(stderr, " %s [-rv] [-p preserve-value] "
"user\n", prog);
-#ifdef EXTENSIONS
} else if (strcmp(prog, "userinfo") == 0) {
(void) fprintf(stderr, "usage: %s [-e] user\n", prog);
-#endif
} else if (strcmp(prog, "groupadd") == 0) {
(void) fprintf(stderr, "usage: %s [-ov] [-g gid] group\n",
prog);
@@ -1672,15 +1634,11 @@ usermgmt_usage(const char *prog)
"group\n", prog);
} else if (strcmp(prog, "user") == 0 || strcmp(prog, "group") == 0) {
(void) fprintf(stderr, "usage: %s [add | del | mod"
-#ifdef EXTENSIONS
" | info"
-#endif
"] ...\n",
prog);
-#ifdef EXTENSIONS
} else if (strcmp(prog, "groupinfo") == 0) {
(void) fprintf(stderr, "usage: %s [-e] group\n", prog);
-#endif
} else {
(void) fprintf(stderr, "This program must be called as {user,group}{add,del,mod,info},\n%s is not an understood name.\n", prog);
}
@@ -1688,12 +1646,6 @@ usermgmt_usage(const char *prog)
/* NOTREACHED */
}
-#ifdef EXTENSIONS
-#define ADD_OPT_EXTENSIONS "p:r:vL:"
-#else
-#define ADD_OPT_EXTENSIONS
-#endif
-
int
useradd(int argc, char **argv)
{
@@ -1701,15 +1653,13 @@ useradd(int argc, char **argv)
int defaultfield;
int bigD;
int c;
-#ifdef EXTENSIONS
int i;
-#endif
(void) memset(&u, 0, sizeof(u));
read_defaults(&u);
u.u_uid = UID_MAX;
defaultfield = bigD = 0;
- while ((c = getopt(argc, argv, "DG:b:c:d:e:f:g:k:mou:s:" ADD_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "DG:L:b:c:d:e:f:g:k:mop:r:s:u:v")) != -1) {
switch(c) {
case 'D':
bigD = 1;
@@ -1752,30 +1702,24 @@ useradd(int argc, char **argv)
defaultfield = 1;
memsave(&u.u_skeldir, optarg, strlen(optarg));
break;
-#ifdef EXTENSIONS
case 'L':
defaultfield = 1;
memsave(&u.u_class, optarg, strlen(optarg));
break;
-#endif
case 'm':
u.u_flags |= F_MKDIR;
break;
case 'o':
u.u_flags |= F_DUPUID;
break;
-#ifdef EXTENSIONS
case 'p':
memsave(&u.u_password, optarg, strlen(optarg));
memset(optarg, 'X', strlen(optarg));
break;
-#endif
-#ifdef EXTENSIONS
case 'r':
defaultfield = 1;
(void) save_range(&u, optarg);
break;
-#endif
case 's':
defaultfield = 1;
memsave(&u.u_shell, optarg, strlen(optarg));
@@ -1786,11 +1730,9 @@ useradd(int argc, char **argv)
}
u.u_uid = atoi(optarg);
break;
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("useradd");
/* NOTREACHED */
@@ -1805,16 +1747,12 @@ useradd(int argc, char **argv)
(void) printf("base_dir\t%s\n", u.u_basedir);
(void) printf("skel_dir\t%s\n", u.u_skeldir);
(void) printf("shell\t\t%s\n", u.u_shell);
-#ifdef EXTENSIONS
(void) printf("class\t\t%s\n", u.u_class);
-#endif
(void) printf("inactive\t%s\n", (u.u_inactive == NULL) ? UNSET_INACTIVE : u.u_inactive);
(void) printf("expire\t\t%s\n", (u.u_expire == NULL) ? UNSET_EXPIRY : u.u_expire);
-#ifdef EXTENSIONS
for (i = 0 ; i < u.u_rc ; i++) {
(void) printf("range\t\t%d..%d\n", u.u_rv[i].r_from, u.u_rv[i].r_to);
}
-#endif
return EXIT_SUCCESS;
}
argc -= optind;
@@ -1827,12 +1765,6 @@ useradd(int argc, char **argv)
return adduser(*argv, &u) ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#ifdef EXTENSIONS
-#define MOD_OPT_EXTENSIONS "p:vL:"
-#else
-#define MOD_OPT_EXTENSIONS
-#endif
-
int
usermod(int argc, char **argv)
{
@@ -1846,7 +1778,7 @@ usermod(int argc, char **argv)
free(u.u_primgrp);
u.u_primgrp = NULL;
have_new_user = 0;
- while ((c = getopt(argc, argv, "G:S:c:d:e:f:g:l:mos:u:" MOD_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "G:L:S:c:d:e:f:g:l:mop:s:u:v")) != -1) {
switch(c) {
case 'G':
while ((u.u_groupv[u.u_groupc] = strsep(&optarg, ",")) != NULL &&
@@ -1900,25 +1832,21 @@ usermod(int argc, char **argv)
have_new_user = 1;
u.u_flags |= F_USERNAME;
break;
-#ifdef EXTENSIONS
case 'L':
memsave(&u.u_class, optarg, strlen(optarg));
u.u_flags |= F_CLASS;
break;
-#endif
case 'm':
u.u_flags |= F_MKDIR;
break;
case 'o':
u.u_flags |= F_DUPUID;
break;
-#ifdef EXTENSIONS
case 'p':
memsave(&u.u_password, optarg, strlen(optarg));
memset(optarg, 'X', strlen(optarg));
u.u_flags |= F_PASSWORD;
break;
-#endif
case 's':
memsave(&u.u_shell, optarg, strlen(optarg));
u.u_flags |= F_SHELL;
@@ -1930,11 +1858,9 @@ usermod(int argc, char **argv)
u.u_uid = atoi(optarg);
u.u_flags |= F_UID;
break;
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("usermod");
/* NOTREACHED */
@@ -1958,12 +1884,6 @@ usermod(int argc, char **argv)
EXIT_SUCCESS : EXIT_FAILURE;
}
-#ifdef EXTENSIONS
-#define DEL_OPT_EXTENSIONS "Dp:v"
-#else
-#define DEL_OPT_EXTENSIONS
-#endif
-
int
userdel(int argc, char **argv)
{
@@ -1978,35 +1898,28 @@ userdel(int argc, char **argv)
(void) memset(&u, 0, sizeof(u));
read_defaults(&u);
defaultfield = bigD = rmhome = 0;
- while ((c = getopt(argc, argv, "r" DEL_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "Dp:rv")) != -1) {
switch(c) {
-#ifdef EXTENSIONS
case 'D':
bigD = 1;
break;
-#endif
-#ifdef EXTENSIONS
case 'p':
defaultfield = 1;
u.u_preserve = (strcmp(optarg, "true") == 0) ? 1 :
(strcmp(optarg, "yes") == 0) ? 1 :
atoi(optarg);
break;
-#endif
case 'r':
rmhome = 1;
break;
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("userdel");
/* NOTREACHED */
}
}
-#ifdef EXTENSIONS
if (bigD) {
if (defaultfield) {
checkeuid();
@@ -2015,7 +1928,6 @@ userdel(int argc, char **argv)
(void) printf("preserve\t%s\n", (u.u_preserve) ? "true" : "false");
return EXIT_SUCCESS;
}
-#endif
argc -= optind;
argv += optind;
if (argc != 1) {
@@ -2045,12 +1957,6 @@ userdel(int argc, char **argv)
return moduser(*argv, *argv, NULL) ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#ifdef EXTENSIONS
-#define GROUP_ADD_OPT_EXTENSIONS "v"
-#else
-#define GROUP_ADD_OPT_EXTENSIONS
-#endif
-
/* add a group */
int
groupadd(int argc, char **argv)
@@ -2061,7 +1967,7 @@ groupadd(int argc, char **argv)
gid = GID_MAX;
dupgid = 0;
- while ((c = getopt(argc, argv, "g:o" GROUP_ADD_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "g:ov")) != -1) {
switch(c) {
case 'g':
if (!is_number(optarg)) {
@@ -2072,11 +1978,9 @@ groupadd(int argc, char **argv)
case 'o':
dupgid = 1;
break;
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("groupadd");
/* NOTREACHED */
@@ -2105,25 +2009,17 @@ groupadd(int argc, char **argv)
return EXIT_SUCCESS;
}
-#ifdef EXTENSIONS
-#define GROUP_DEL_OPT_EXTENSIONS "v"
-#else
-#define GROUP_DEL_OPT_EXTENSIONS
-#endif
-
/* remove a group */
int
groupdel(int argc, char **argv)
{
int c;
- while ((c = getopt(argc, argv, "" GROUP_DEL_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "v")) != -1) {
switch(c) {
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("groupdel");
/* NOTREACHED */
@@ -2146,12 +2042,6 @@ groupdel(int argc, char **argv)
return EXIT_SUCCESS;
}
-#ifdef EXTENSIONS
-#define GROUP_MOD_OPT_EXTENSIONS "v"
-#else
-#define GROUP_MOD_OPT_EXTENSIONS
-#endif
-
/* modify a group */
int
groupmod(int argc, char **argv)
@@ -2168,7 +2058,7 @@ groupmod(int argc, char **argv)
gid = GID_MAX;
dupgid = 0;
newname = NULL;
- while ((c = getopt(argc, argv, "g:on:" GROUP_MOD_OPT_EXTENSIONS)) != -1) {
+ while ((c = getopt(argc, argv, "g:n:ov")) != -1) {
switch(c) {
case 'g':
if (!is_number(optarg)) {
@@ -2182,11 +2072,9 @@ groupmod(int argc, char **argv)
case 'n':
memsave(&newname, optarg, strlen(optarg));
break;
-#ifdef EXTENSIONS
case 'v':
verbose = 1;
break;
-#endif
default:
usermgmt_usage("groupmod");
/* NOTREACHED */
@@ -2238,7 +2126,6 @@ groupmod(int argc, char **argv)
return EXIT_SUCCESS;
}
-#ifdef EXTENSIONS
/* display user information */
int
userinfo(int argc, char **argv)
@@ -2291,18 +2178,14 @@ userinfo(int argc, char **argv)
}
(void) fputc('\n', stdout);
(void) printf("change\t%s", pwp->pw_change ? ctime(&pwp->pw_change) : "NEVER\n");
-#ifdef EXTENSIONS
(void) printf("class\t%s\n", pwp->pw_class);
-#endif
(void) printf("gecos\t%s\n", pwp->pw_gecos);
(void) printf("dir\t%s\n", pwp->pw_dir);
(void) printf("shell\t%s\n", pwp->pw_shell);
(void) printf("expire\t%s", pwp->pw_expire ? ctime(&pwp->pw_expire) : "NEVER\n");
return EXIT_SUCCESS;
}
-#endif
-#ifdef EXTENSIONS
/* display user information */
int
groupinfo(int argc, char **argv)
@@ -2348,4 +2231,3 @@ groupinfo(int argc, char **argv)
(void) fputc('\n', stdout);
return EXIT_SUCCESS;
}
-#endif
diff --git a/usr.sbin/user/usermgmt.h b/usr.sbin/user/usermgmt.h
index 638534be285..9469cd1e2e8 100644
--- a/usr.sbin/user/usermgmt.h
+++ b/usr.sbin/user/usermgmt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usermgmt.h,v 1.4 2002/02/16 21:28:10 millert Exp $ */
+/* $OpenBSD: usermgmt.h,v 1.5 2011/12/31 14:05:51 ajacoutot Exp $ */
/* $NetBSD: usermgmt.h,v 1.4 1999/12/24 09:08:51 agc Exp $ */
/*
@@ -40,11 +40,8 @@ int userdel(int, char **);
int groupadd(int, char **);
int groupdel(int, char **);
int groupmod(int, char **);
-
-#ifdef EXTENSIONS
int userinfo(int, char **);
int groupinfo(int, char **);
-#endif
__dead void usermgmt_usage(const char *);