summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2008-06-23 22:06:28 +0000
committermtm <mtm@FreeBSD.org>2008-06-23 22:06:28 +0000
commit5b37d9eba744dee55431a0426bafd09eef483fea (patch)
tree143050b4a26dfcca36087688ac911ef3e62dfd91
parent437891381c13fcfea1097ae4d151f60dbcd8f601 (diff)
downloadFreeBSD-src-5b37d9eba744dee55431a0426bafd09eef483fea.zip
FreeBSD-src-5b37d9eba744dee55431a0426bafd09eef483fea.tar.gz
The sysctl(8) program exits on some errors and only emits warnings on
others. In the case where it displayed warnings it would still return succesfully. Modify it so that it returns the number of sysctls that it was not able to set. Make use of this in rc.d to display only *unsuccessfull* attempts to set sysctls.
-rw-r--r--etc/rc.d/auto_linklocal5
-rw-r--r--etc/rc.d/power_profile6
-rw-r--r--etc/rc.d/sysctl4
-rw-r--r--sbin/sysctl/sysctl.c7
4 files changed, 17 insertions, 5 deletions
diff --git a/etc/rc.d/auto_linklocal b/etc/rc.d/auto_linklocal
index 8278696..28d03c0 100644
--- a/etc/rc.d/auto_linklocal
+++ b/etc/rc.d/auto_linklocal
@@ -18,7 +18,10 @@ stop_cmd=":"
auto_linklocal_start()
{
if ! checkyesno ipv6_enable && ${SYSCTL} net.inet6 > /dev/null 2>&1; then
- ${SYSCTL_W} net.inet6.ip6.auto_linklocal=0
+ if ! ${SYSCTL_W} net.inet6.ip6.auto_linklocal=0 >/dev/null 2>&1; then
+ warn "failed to set sysctl(8)"
+ return 1
+ fi
laddr=`network6_getladdr lo0`
if [ -z "${laddr}" ]; then
ifconfig lo0 inet6 fe80::1 prefixlen 64
diff --git a/etc/rc.d/power_profile b/etc/rc.d/power_profile
index 7f64b72..03d36be 100644
--- a/etc/rc.d/power_profile
+++ b/etc/rc.d/power_profile
@@ -50,7 +50,11 @@ sysctl_set ()
esac
# Set the desired value
- [ -n "${value}" ] && sysctl ${node}=${value}
+ if [ -n "${value}" ]; then
+ if ! sysctl ${node}=${value} > /dev/null 2>&1; then
+ warn "unable to set ${node}=${value}"
+ fi
+ fi
}
if [ $# -ne 1 ]; then
diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl
index f83d7f8..c55cc84 100644
--- a/etc/rc.d/sysctl
+++ b/etc/rc.d/sysctl
@@ -36,7 +36,9 @@ sysctl_start()
${val})
;;
*)
- sysctl "${var}"
+ if ! sysctl "${var}" >/dev/null 2>&1; then
+ warn "unable to set ${var}"
+ fi
;;
esac
elif [ "$1" = "last" ]; then
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 9dcfcb0..bcb5a11 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -59,7 +59,7 @@ static const char rcsid[] =
#include <unistd.h>
static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag;
-static int qflag, xflag;
+static int qflag, xflag, warncount;
static int oidfmt(int *, int, char *, u_int *);
static void parse(char *);
@@ -146,9 +146,11 @@ main(int argc, char **argv)
exit(sysctl_all(0, 0));
if (argc == 0)
usage();
+
+ warncount = 0;
while (argc-- > 0)
parse(*argv++);
- exit(0);
+ exit(warncount);
}
/*
@@ -304,6 +306,7 @@ parse(char *string)
string);
default:
warn("%s", string);
+ warncount++;
return;
}
}
OpenPOWER on IntegriCloud