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.
This commit is contained in:
parent
c4f3a35a54
commit
d9fcd86c3a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179965
@ -18,7 +18,10 @@ stop_cmd=":"
|
|||||||
auto_linklocal_start()
|
auto_linklocal_start()
|
||||||
{
|
{
|
||||||
if ! checkyesno ipv6_enable && ${SYSCTL} net.inet6 > /dev/null 2>&1; then
|
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`
|
laddr=`network6_getladdr lo0`
|
||||||
if [ -z "${laddr}" ]; then
|
if [ -z "${laddr}" ]; then
|
||||||
ifconfig lo0 inet6 fe80::1 prefixlen 64
|
ifconfig lo0 inet6 fe80::1 prefixlen 64
|
||||||
|
@ -50,7 +50,11 @@ sysctl_set ()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Set the desired value
|
# 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
|
if [ $# -ne 1 ]; then
|
||||||
|
@ -36,7 +36,9 @@ sysctl_start()
|
|||||||
${val})
|
${val})
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
sysctl "${var}"
|
if ! sysctl "${var}" >/dev/null 2>&1; then
|
||||||
|
warn "unable to set ${var}"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ "$1" = "last" ]; then
|
elif [ "$1" = "last" ]; then
|
||||||
|
@ -59,7 +59,7 @@ static const char rcsid[] =
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag;
|
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 int oidfmt(int *, int, char *, u_int *);
|
||||||
static void parse(char *);
|
static void parse(char *);
|
||||||
@ -146,9 +146,11 @@ main(int argc, char **argv)
|
|||||||
exit(sysctl_all(0, 0));
|
exit(sysctl_all(0, 0));
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
warncount = 0;
|
||||||
while (argc-- > 0)
|
while (argc-- > 0)
|
||||||
parse(*argv++);
|
parse(*argv++);
|
||||||
exit(0);
|
exit(warncount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -304,6 +306,7 @@ parse(char *string)
|
|||||||
string);
|
string);
|
||||||
default:
|
default:
|
||||||
warn("%s", string);
|
warn("%s", string);
|
||||||
|
warncount++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user