diff options
| author | Aron Xu <aron@debian.org> | 2016-12-20 20:06:37 +0800 |
|---|---|---|
| committer | Aron Xu <aron@debian.org> | 2016-12-20 20:06:37 +0800 |
| commit | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (patch) | |
| tree | 795f8d6a3aa1145e4ba8fa1564f39425ea0c6ed9 /src/platform/tests/test-common.c | |
| parent | 270c4830551c9810ad4e83f9a1db2b1cb946208c (diff) | |
Imported Upstream version 1.4.4 upstream/1.4.4
Diffstat (limited to 'src/platform/tests/test-common.c')
| -rw-r--r-- | src/platform/tests/test-common.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index b1947a6d..d636ebeb 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -1398,7 +1398,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) int pipefd_p2c[2]; ssize_t r; - e = pipe (pipefd_c2p); + e = pipe2 (pipefd_c2p, O_CLOEXEC); if (e != 0) { errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, @@ -1406,7 +1406,7 @@ nmtstp_namespace_create (int unshare_flags, GError **error) return FALSE; } - e = pipe (pipefd_p2c); + e = pipe2 (pipefd_p2c, O_CLOEXEC); if (e != 0) { errsv = errno; g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, @@ -1540,7 +1540,7 @@ nmtstp_namespace_get_fd_for_process (pid_t pid, const char *ns_name) nm_sprintf_buf (p, "/proc/%lu/ns/%s", (long unsigned) pid, ns_name); - return open(p, O_RDONLY); + return open(p, O_RDONLY | O_CLOEXEC); } /*****************************************************************************/ @@ -1564,21 +1564,21 @@ unshare_user (void) /* Since Linux 3.19 we have to disable setgroups() in order to map users. * Just proceed if the file is not there. */ - f = fopen ("/proc/self/setgroups", "w"); + f = fopen ("/proc/self/setgroups", "we"); if (f) { fprintf (f, "deny"); fclose (f); } /* Map current UID to root in NS to be created. */ - f = fopen ("/proc/self/uid_map", "w"); + f = fopen ("/proc/self/uid_map", "we"); if (!f) return FALSE; fprintf (f, "0 %d 1", uid); fclose (f); /* Map current GID to root in NS to be created. */ - f = fopen ("/proc/self/gid_map", "w"); + f = fopen ("/proc/self/gid_map", "we"); if (!f) return FALSE; fprintf (f, "0 %d 1", gid); |