test: skip some spawn test cases on IBMi

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é <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
Xu Meng 2020-02-06 07:55:40 -06:00 committed by cjihrig
parent a9a371e4cf
commit 2abfa11a2c
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
2 changed files with 23 additions and 3 deletions

View File

@ -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;
}

View File

@ -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);