]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/monitor: Print error "this requires root" and exit
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Mon, 6 Nov 2017 15:34:05 +0000 (21:04 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 6 Nov 2017 15:42:34 +0000 (16:42 +0100)
If executed without root privileges, print error "this requires root!"
and exit.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/monitor/run-tests.sh

index 23d4e21288e27a1904e3dc10aa9c912635e7dba6..1adabda1939492fbf3a5e3c1b5f2d3eb1c4af2c2 100755 (executable)
@@ -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