summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1999-09-02 22:04:39 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1999-09-02 22:04:39 +0000
commit86cad8ab7666e32de8094a764e6052bb624b3041 (patch)
tree44bb6cbf7eba404dcf6e50019b2f8cb16f29d038 /usr.sbin
parent974544cb98487b23a72fdab3e567f7a2f0ef0c3a (diff)
Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sysctl/sysctl.86
-rw-r--r--usr.sbin/sysctl/sysctl.c31
2 files changed, 26 insertions, 11 deletions
diff --git a/usr.sbin/sysctl/sysctl.8 b/usr.sbin/sysctl/sysctl.8
index ee6f7de32cd..e5a08731bb9 100644
--- a/usr.sbin/sysctl/sysctl.8
+++ b/usr.sbin/sysctl/sysctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysctl.8,v 1.27 1999/06/29 23:57:56 provos Exp $
+.\" $OpenBSD: sysctl.8,v 1.28 1999/09/02 22:04:37 pjanzen Exp $
.\" $NetBSD: sysctl.8,v 1.4 1995/09/30 07:12:49 thorpej Exp $
.\"
.\" Copyright (c) 1993
@@ -117,7 +117,7 @@ privilege can change the value.
.It kern.securelevel integer raise only
.It kern.hostname string yes
.It kern.domainname string yes
-.It kern.hostid integer yes
+.It kern.hostid u_int yes
.It kern.clockrate struct no
.It kern.posix1version integer no
.It kern.ngroups integer no
@@ -141,7 +141,7 @@ privilege can change the value.
.It kern.sysvmsg integer no
.It kern.sysvsem integer no
.It kern.sysvshm integer no
-.It kern.arandom integer no
+.It kern.arandom u_int no
.It vm.loadavg struct no
.It vm.psstrings struct no
.It fs.posix.setuid integer yes
diff --git a/usr.sbin/sysctl/sysctl.c b/usr.sbin/sysctl/sysctl.c
index 5be2072599f..f032b09d323 100644
--- a/usr.sbin/sysctl/sysctl.c
+++ b/usr.sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.40 1999/07/01 15:45:18 deraadt Exp $ */
+/* $OpenBSD: sysctl.c,v 1.41 1999/09/02 22:04:38 pjanzen Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95";
#else
-static char *rcsid = "$OpenBSD: sysctl.c,v 1.40 1999/07/01 15:45:18 deraadt Exp $";
+static char *rcsid = "$OpenBSD: sysctl.c,v 1.41 1999/09/02 22:04:38 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -139,12 +139,12 @@ int Aflag, aflag, nflag, wflag;
#define BOOTTIME 0x00000002
#define CHRDEV 0x00000004
#define BLKDEV 0x00000008
-#define RNDSTATS 0x00000010
-#define BADDYNAMIC 0x00000020
-#define BIOSGEO 0x00000040
-#define BIOSDEV 0x00000080
+#define RNDSTATS 0x00000010
+#define BADDYNAMIC 0x00000020
+#define BIOSGEO 0x00000040
+#define BIOSDEV 0x00000080
#define MAJ2DEV 0x00000100
-#define UNSIGNED 0x00000200
+#define UNSIGNED 0x00000200
/* prototypes */
void debuginit __P((void));
@@ -329,6 +329,7 @@ parse(string, flags)
case KERN_RND:
special |= RNDSTATS;
break;
+ case KERN_HOSTID:
case KERN_ARND:
special |= UNSIGNED;
break;
@@ -489,7 +490,21 @@ parse(string, flags)
if (newsize > 0) {
switch (type) {
case CTLTYPE_INT:
- intval = atoi(newval);
+ errno = 0;
+ if (special & UNSIGNED)
+ intval = strtoul(newval, &cp, 10);
+ else
+ intval = strtol(newval, &cp, 10);
+ if (*cp != '\0') {
+ warnx("%s: illegal value: %s", string,
+ (char *)newval);
+ return;
+ }
+ if (errno == ERANGE) {
+ warnx("%s: value %s out of range", string,
+ (char *)newval);
+ return;
+ }
newval = &intval;
newsize = sizeof(intval);
break;