From 0a7e36dcf1fa3d8669556eb0d88577116c9330d2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 10 Nov 2012 18:50:57 +0100 Subject: [PATCH] test: add UV_RUN_AS_ROOT check --- test/runner-unix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/runner-unix.c b/test/runner-unix.c index 1a54a1ad..77c68dcd 100644 --- a/test/runner-unix.c +++ b/test/runner-unix.c @@ -40,11 +40,14 @@ /* Do platform-specific initialization. */ void platform_init(int argc, char **argv) { + const char* var = getenv("UV_RUN_AS_ROOT"); + /* Running the tests as root is not smart - don't do it. */ - if (getuid() == 0) { + if (getuid() == 0 && (var == NULL || atoi(var) <= 0)) { fprintf(stderr, "Running the tests as root is not safe.\n"); exit(1); } + /* Disable stdio output buffering. */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);