From 2abfa11a2cbee02281b5eed1a19c32e7f4bcc3f6 Mon Sep 17 00:00:00 2001 From: Xu Meng Date: Thu, 6 Feb 2020 07:55:40 -0600 Subject: [PATCH] test: skip some spawn test cases on IBMi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On IBMi PASE, there is no root user or nobody user. User may grant root-like privileges, including setting uid/gid to 0. PR-URL: https://github.com/libuv/libuv/pull/2676 Reviewed-By: Saúl Ibarra Corretgé Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau --- test/run-tests.c | 4 ++++ test/test-spawn.c | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/test/run-tests.c b/test/run-tests.c index 6c92c2b7..3a6452ff 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -211,7 +211,11 @@ static int maybe_run_test(int argc, char **argv) { notify_parent_process(); ASSERT(sizeof(fd) == read(0, &fd, sizeof(fd))); ASSERT(fd > 2); +# if defined(__PASE__) /* On IBMi PASE, write() returns 1 */ + ASSERT(1 == write(fd, "x", 1)); +# else ASSERT(-1 == write(fd, "x", 1)); +# endif /* !__PASE__ */ return 1; } diff --git a/test/test-spawn.c b/test/test-spawn.c index be9e2539..2b7f5d56 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -1420,6 +1420,8 @@ TEST_IMPL(spawn_setuid_fails) { int r; /* if root, become nobody. */ + /* On IBMi PASE, there is no nobody user. */ +#ifndef __PASE__ uv_uid_t uid = getuid(); if (uid == 0) { struct passwd* pw; @@ -1428,11 +1430,19 @@ TEST_IMPL(spawn_setuid_fails) { ASSERT(0 == setgid(pw->pw_gid)); ASSERT(0 == setuid(pw->pw_uid)); } +#endif /* !__PASE__ */ init_process_options("spawn_helper1", fail_cb); options.flags |= UV_PROCESS_SETUID; + /* On IBMi PASE, there is no root user. User may grant + * root-like privileges, including setting uid to 0. + */ +#if defined(__PASE__) + options.uid = -1; +#else options.uid = 0; +#endif /* These flags should be ignored on Unices. */ options.flags |= UV_PROCESS_WINDOWS_HIDE; @@ -1441,7 +1451,7 @@ TEST_IMPL(spawn_setuid_fails) { options.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS; r = uv_spawn(uv_default_loop(), &process, &options); -#if defined(__CYGWIN__) +#if defined(__CYGWIN__) || defined(__PASE__) ASSERT(r == UV_EINVAL); #else ASSERT(r == UV_EPERM); @@ -1461,6 +1471,8 @@ TEST_IMPL(spawn_setgid_fails) { int r; /* if root, become nobody. */ + /* On IBMi PASE, there is no nobody user. */ +#ifndef __PASE__ uv_uid_t uid = getuid(); if (uid == 0) { struct passwd* pw; @@ -1469,18 +1481,22 @@ TEST_IMPL(spawn_setgid_fails) { ASSERT(0 == setgid(pw->pw_gid)); ASSERT(0 == setuid(pw->pw_uid)); } +#endif /* !__PASE__ */ init_process_options("spawn_helper1", fail_cb); options.flags |= UV_PROCESS_SETGID; -#if defined(__MVS__) + /* On IBMi PASE, there is no root user. User may grant + * root-like privileges, including setting gid to 0. + */ +#if defined(__MVS__) || defined(__PASE__) options.gid = -1; #else options.gid = 0; #endif r = uv_spawn(uv_default_loop(), &process, &options); -#if defined(__CYGWIN__) || defined(__MVS__) +#if defined(__CYGWIN__) || defined(__MVS__) || defined(__PASE__) ASSERT(r == UV_EINVAL); #else ASSERT(r == UV_EPERM);