diff mbox series

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

Message ID 20171106153405.6294-1-harshasharmaiitr@gmail.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series tests/monitor: Print error "this requires root" and exit | expand

Commit Message

Harsha Sharma Nov. 6, 2017, 3:34 p.m. UTC
If executed without root privileges, print error "this requires root!"
and exit.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
 tests/monitor/run-tests.sh | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pablo Neira Ayuso Nov. 6, 2017, 3:42 p.m. UTC | #1
On Mon, Nov 06, 2017 at 09:04:05PM +0530, Harsha Sharma wrote:
> If executed without root privileges, print error "this requires root!"
> and exit.

Applied, thanks Harsha.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/tests/monitor/run-tests.sh b/tests/monitor/run-tests.sh
index 23d4e21..1adabda 100755
--- a/tests/monitor/run-tests.sh
+++ b/tests/monitor/run-tests.sh
@@ -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