From af45b6ba2f2c506ae18dd24481e24db17b8269e7 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 23 Dec 2019 10:18:02 -0500 Subject: [PATCH] test: disallow running the test suite as root The test suite is known to have issues when run as root. This commit prevents the test suite from running when the euid is 0. Fixes: https://github.com/libuv/libuv/issues/2549 PR-URL: https://github.com/libuv/libuv/pull/2585 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau --- test/run-tests.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/run-tests.c b/test/run-tests.c index 55cf412827d..2aad6a522ff 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -51,6 +51,13 @@ static int maybe_run_test(int argc, char **argv); int main(int argc, char **argv) { +#ifndef _WIN32 + if (0 == geteuid() && NULL == getenv("UV_RUN_AS_ROOT")) { + fprintf(stderr, "The libuv test suite cannot be run as root.\n"); + return EXIT_FAILURE; + } +#endif + if (platform_init(argc, argv)) return EXIT_FAILURE;