diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2018-07-08 20:10:27 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2018-07-08 20:10:27 +0000 |
commit | 65828a3255baeea529031e67fd83d80d615928ac (patch) | |
tree | 5c6ae386c9cb1b94890b6e4c85b324d86e438e7b | |
parent | 1ca6bfc055074c5a57f0469cce355e4f74d225a8 (diff) |
netstart is used during system start, but also interactively.
Show proper error message if a regular user executes netstart.
Only do the privilege check if the id binary is available,
which might not be the case during diskless system startup.
ok deraadt, jasper, jca, krw, rpe (who wrote the same diff), sthen
-rw-r--r-- | etc/netstart | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/etc/netstart b/etc/netstart index 6e3fb80848d..4010a25f81f 100644 --- a/etc/netstart +++ b/etc/netstart @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: netstart,v 1.198 2018/04/28 22:38:32 rpe Exp $ +# $OpenBSD: netstart,v 1.199 2018/07/08 20:10:26 tb Exp $ # Turn off Strict Bourne shell mode. set +o sh @@ -201,6 +201,13 @@ defaultroute() { done } +# Make sure the invoking user has the right privileges. Check for presence of +# id(1) to avoid problems with diskless setups. +if [[ -x /usr/bin/id ]] && (($(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 |