From: Thomas Haller Date: Thu, 24 Mar 2016 16:05:39 +0000 (+0100) Subject: platform/tests: fix bug in netns test which can cause mounting tmpfs over /run X-Git-Url: https://iam.tj/gitweb/gitweb.cgi?p=NetworkManager.git;a=commitdiff_plain;h=12e6984b8763418856218ee8b3a8d3498c44f7f5 platform/tests: fix bug in netns test which can cause mounting tmpfs over /run The root-test "/general/netns/bind-to-path" mounts a tmpfs over /var/run for the duration of the test and unmounts it at the end. Due to a bug, we first mount the tmpfs, then switch to another namespace, and finally unmount /var/run on that other namespace. That means, when you run the tests as root, it will bork /run on your system. Fixes: 46f5c07643e6cbf920a44bebe9ac9d3435a5a7b6 --- diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 69627c405..94695edcd 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -2257,9 +2257,6 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data) if (_test_netns_check_skip ()) return; - g_assert_cmpint (mount ("tmpfs", P_VAR_RUN, "tmpfs", MS_NOATIME | MS_NODEV | MS_NOSUID, "mode=0755,size=32K"), ==, 0); - g_assert_cmpint (mkdir (P_VAR_RUN_NETNS, 755), ==, 0); - platforms[0] = platform_0 = g_object_new (NM_TYPE_LINUX_PLATFORM, NM_PLATFORM_NETNS_SUPPORT, TRUE, NULL); platforms[1] = platform_1 = _test_netns_create_platform (); platforms[2] = platform_2 = _test_netns_create_platform (); @@ -2268,6 +2265,9 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data) if (i != 3) g_assert (nm_platform_netns_push (platforms[i], &netns_pop)); + g_assert_cmpint (mount ("tmpfs", P_VAR_RUN, "tmpfs", MS_NOATIME | MS_NODEV | MS_NOSUID, "mode=0755,size=32K"), ==, 0); + g_assert_cmpint (mkdir (P_VAR_RUN_NETNS, 755), ==, 0); + i = (nmtst_get_rand_int () % 2) + 1; netns = nm_platform_netns_get (platforms[i]);