From ce3e7d728535db38a29e801c58a051333510eed1 Mon Sep 17 00:00:00 2001 From: jasper <> Date: Fri, 9 Sep 2016 19:48:16 +0000 Subject: [PATCH] print a clear error message when not ran as root instead of just falling through and try whatever it can do with the invoking user's perms feedback/ok aja@ rpe@ --- src/etc/netstart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/etc/netstart b/src/etc/netstart index 62b9ed13..60b0dea7 100644 --- a/src/etc/netstart +++ b/src/etc/netstart @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: netstart,v 1.169 2016/07/19 08:03:01 mpi Exp $ +# $OpenBSD: netstart,v 1.170 2016/09/09 19:48:16 jasper Exp $ # Turn off Strict Bourne shell mode. set +o sh @@ -167,6 +167,12 @@ ifv6autoconf() { done } +# Make sure the invoking user has the right privileges. +if (($(id -u) != 0)); then + echo "${0##*/}: need root privileges" + exit 1 +fi + # Get network related vars from rc.conf using the parsing routine from rc.subr. FUNCS_ONLY=1 . /etc/rc.d/rc.subr _rc_parse_conf