summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormestre <mestre@openbsd.org>2016-03-29 13:32:54 +0000
committermestre <mestre@openbsd.org>2016-03-29 13:32:54 +0000
commitefe89df20150cfed694ba4c459fc24c4314f9f12 (patch)
tree61ee7c57ba838501f13657f13e4c08c2c578f507
parentRemove dead assignments and now unused variables. (diff)
downloadwireguard-openbsd-efe89df20150cfed694ba4c459fc24c4314f9f12.tar.xz
wireguard-openbsd-efe89df20150cfed694ba4c459fc24c4314f9f12.zip
-Remove function #defines from defs.h and use the actual code accordingly in
user.c -Remove MIN and MAX #defines which are not being in use since the last 16 years -Move last #define to user.c and remove file defs.h -Remove lint comments OK natano@ after his suggestions and also OK jung@ on an earlier version
-rw-r--r--usr.sbin/user/defs.h67
-rw-r--r--usr.sbin/user/main.c3
-rw-r--r--usr.sbin/user/user.c33
3 files changed, 15 insertions, 88 deletions
diff --git a/usr.sbin/user/defs.h b/usr.sbin/user/defs.h
deleted file mode 100644
index 029e49ac222..00000000000
--- a/usr.sbin/user/defs.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* $OpenBSD: defs.h,v 1.7 2016/03/28 19:09:08 mestre Exp $ */
-/* $NetBSD: defs.h,v 1.5 1999/12/24 09:08:49 agc Exp $ */
-
-/*
- * Copyright (c) 1999 Alistair G. Crooks. All rights reserved.
- *
- * 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 Alistair G. Crooks.
- * 4. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- */
-#ifndef DEFS_H_
-#define DEFS_H_
-
-#define NEWARRAY(type,ptr,size,action) do { \
- if ((ptr = calloc((size), \
- sizeof(type))) == (type *) NULL) { \
- warn("can't allocate %ld bytes", \
- (long)((size) * sizeof(type))); \
- action; \
- } \
-} while( /* CONSTCOND */ 0)
-
-#define RENEW(type,ptr,size,action) do { \
- if ((ptr = reallocarray(ptr, \
- (size), sizeof(type))) == (type *) NULL) { \
- warn("can't realloc %ld bytes", \
- (long)((size) * sizeof(type))); \
- action; \
- } \
-} while( /* CONSTCOND */ 0)
-
-#define NEW(type, ptr, action) NEWARRAY(type, ptr, 1, action)
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#define _PATH_NONEXISTENT "/nonexistent"
-
-#endif /* !DEFS_H_ */
diff --git a/usr.sbin/user/main.c b/usr.sbin/user/main.c
index e99db49e961..9966ac56378 100644
--- a/usr.sbin/user/main.c
+++ b/usr.sbin/user/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.9 2015/11/30 22:22:27 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.10 2016/03/29 13:32:54 mestre Exp $ */
/* $NetBSD: main.c,v 1.3 2002/07/09 10:34:16 tron Exp $ */
/*
@@ -95,5 +95,4 @@ main(int argc, char **argv)
argv + (matched - 1));
}
usermgmt_usage(__progname);
- /* NOTREACHED */
}
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index f2103cc6721..20e982115f7 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.106 2016/03/28 19:42:51 mestre Exp $ */
+/* $OpenBSD: user.c,v 1.107 2016/03/29 13:32:54 mestre Exp $ */
/* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */
/*
@@ -54,7 +54,6 @@
#include <limits.h>
#include <util.h>
-#include "defs.h"
#include "usermgmt.h"
@@ -107,7 +106,8 @@ enum {
F_ACCTUNLOCK = 0x10000
};
-#define CONFFILE "/etc/usermgmt.conf"
+#define CONFFILE "/etc/usermgmt.conf"
+#define _PATH_NONEXISTENT "/nonexistent"
#ifndef DEF_GROUP
#define DEF_GROUP "=uid"
@@ -193,7 +193,8 @@ static void
memsave(char **cpp, const char *s, size_t n)
{
free(*cpp);
- NEWARRAY(char, *cpp, n + 1, exit(1));
+ if ((*cpp = calloc (n + 1, sizeof(char))) == NULL)
+ err(1, NULL);
(void) memcpy(*cpp, s, n);
(*cpp)[n] = '\0';
}
@@ -667,12 +668,14 @@ save_range(user_t *up, char *cp)
uid_t to;
int i;
- if (up->u_rsize == 0) {
- up->u_rsize = 32;
- NEWARRAY(range_t, up->u_rv, up->u_rsize, return(0));
- } else if (up->u_rc == up->u_rsize) {
+ if (up->u_rc == up->u_rsize) {
up->u_rsize *= 2;
- RENEW(range_t, up->u_rv, up->u_rsize, return(0));
+ if ((up->u_rv = reallocarray(up->u_rv, up->u_rsize,
+ sizeof(range_t))) == NULL) {
+ warn("can't realloc %ld bytes",
+ (long)(up->u_rsize * sizeof(range_t)));
+ return 0;
+ }
}
if (up->u_rv && sscanf(cp, "%u..%u", &from, &to) == 2) {
for (i = up->u_defrc ; i < up->u_rc ; i++) {
@@ -758,7 +761,8 @@ read_defaults(user_t *up)
memsave(&up->u_class, DEF_CLASS, strlen(DEF_CLASS));
up->u_rsize = 16;
up->u_defrc = 0;
- NEWARRAY(range_t, up->u_rv, up->u_rsize, exit(1));
+ if ((up->u_rv = calloc(up->u_rsize, sizeof(range_t))) == NULL)
+ err(1, NULL);
up->u_inactive = DEF_INACTIVE;
up->u_expire = DEF_EXPIRE;
if ((fp = fopen(CONFFILE, "r")) == NULL) {
@@ -1750,7 +1754,6 @@ usermgmt_usage(const char *prog)
(void) fprintf(stderr, "This program must be called as {user,group}{add,del,mod,info},\n%s is not an understood name.\n", prog);
}
exit(EXIT_FAILURE);
- /* NOTREACHED */
}
int
@@ -1843,7 +1846,6 @@ useradd(int argc, char **argv)
break;
default:
usermgmt_usage("useradd");
- /* NOTREACHED */
}
}
if (bigD) {
@@ -1978,7 +1980,6 @@ usermod(int argc, char **argv)
break;
default:
usermgmt_usage("usermod");
- /* NOTREACHED */
}
}
if ((u.u_flags & F_MKDIR) && !(u.u_flags & F_HOMEDIR) &&
@@ -2036,7 +2037,6 @@ userdel(int argc, char **argv)
break;
default:
usermgmt_usage("userdel");
- /* NOTREACHED */
}
}
if (bigD) {
@@ -2103,7 +2103,6 @@ groupadd(int argc, char **argv)
break;
default:
usermgmt_usage("groupadd");
- /* NOTREACHED */
}
}
argc -= optind;
@@ -2142,7 +2141,6 @@ groupdel(int argc, char **argv)
break;
default:
usermgmt_usage("groupdel");
- /* NOTREACHED */
}
}
argc -= optind;
@@ -2198,7 +2196,6 @@ groupmod(int argc, char **argv)
break;
default:
usermgmt_usage("groupmod");
- /* NOTREACHED */
}
}
argc -= optind;
@@ -2268,7 +2265,6 @@ userinfo(int argc, char **argv)
break;
default:
usermgmt_usage("userinfo");
- /* NOTREACHED */
}
}
argc -= optind;
@@ -2327,7 +2323,6 @@ groupinfo(int argc, char **argv)
break;
default:
usermgmt_usage("groupinfo");
- /* NOTREACHED */
}
}
argc -= optind;