diff options
author | Thomas Haller <thaller@redhat.com> | 2015-05-11 19:13:35 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-05-11 19:13:35 +0200 |
commit | 0293132a8414aa4d7b587226aa282c2ce54167f1 (patch) | |
tree | 6eb75466eb05e0aec5db3e7ec0549cfb6cbe8809 | |
parent | 4ff5efff269ff7ac92646e0c79b41623f3857c4b (diff) | |
download | NetworkManager-lr/platform-tests-unshare.tar.gz |
fixup! platform/test: unshare the netns namespace so that root tests don't mess with the systemlr/platform-tests-unshare
-rw-r--r-- | src/platform/tests/test-common.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 8ab7642bbe..bb94debc78 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -283,25 +283,38 @@ main (int argc, char **argv) } if (nmtst_platform_is_root_test () && !g_getenv ("NMTST_NO_UNSHARE")) { - int errsv = errno; - if (unshare (CLONE_NEWNET | CLONE_NEWNS) != 0) + int errsv; + + if (unshare (CLONE_NEWNET | CLONE_NEWNS) != 0) { + errsv = errno; g_error ("unshare(CLONE_NEWNET|CLONE_NEWNS) failed with %s (%d)", strerror (errsv), errsv); + } /* Mount our /sys instance, so that gudev sees only our devices. * Needs to be read-only, because we don't run udev. */ - if (mount (NULL, "/sys", NULL, MS_SLAVE, NULL) != 0) + if (mount (NULL, "/sys", NULL, MS_SLAVE, NULL) != 0) { + errsv = errno; g_error ("mount(\"/\", MS_SLAVE) failed with %s (%d)", strerror (errsv), errsv); - if (mount ("sys", "/sys", "sysfs", MS_RDONLY, NULL) != 0) + } + if (mount ("sys", "/sys", "sysfs", MS_RDONLY, NULL) != 0) { + errsv = errno; g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); + } /* Create a writable /sys/devices tree. This makes it possible to run tests * that modify values via sysfs (such as bridge forward delay). */ - if (mount ("sys", "/sys/devices", "sysfs", 0, NULL) != 0) + if (mount ("sys", "/sys/devices", "sysfs", 0, NULL) != 0) { + errsv = errno; g_error ("mount(\"/sys/devices\") failed with %s (%d)", strerror (errsv), errsv); - if (mount (NULL, "/sys/devices", "sysfs", MS_REMOUNT, NULL) != 0) + } + if (mount (NULL, "/sys/devices", "sysfs", MS_REMOUNT, NULL) != 0) { + errsv = errno; g_error ("remount(\"/sys/devices\") failed with %s (%d)", strerror (errsv), errsv); - if (mount ("/sys/devices/devices", "/sys/devices", NULL, MS_BIND, NULL) != 0) + } + if (mount ("/sys/devices/devices", "/sys/devices", NULL, MS_BIND, NULL) != 0) { + errsv = errno; g_error ("mount(\"/sys\") failed with %s (%d)", strerror (errsv), errsv); + } } SETUP (); |