Skip to contentSkip to conversation

tests/monitor: Print error "this requires root" and exit

PATCH Applied Harsha Sharma 2 participants 2 messages Nov 6, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/monitor: Print error "this requires root" and exit

If executed without root privileges, print error "this requires root!" and exit.

---
 tests/monitor/run-tests.sh | 5 +++++
 1 file changed, 5 insertions(+)
tests/monitor/run-tests.sh +5 -0
index 23d4e21..1adabda 100755
@@ -8,6 +8,11 @@ mydiff() {
 	diff -w -I '^# ' "$@"
 }
 
+if [ "$(id -u)" != "0" ] ; then
+	echo "this requires root!"
+	exit 1
+fi
+
 testdir=$(mktemp -d)
 if [ ! -d $testdir ]; then
 	echo "Failed to create test directory" >&2
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw
Quoted 2 lines · Harsha Sharma

If executed without root privileges, print error "this requires root!" and exit.

Applied, thanks Harsha.