platform: relax assert when checking pathnames for accessing sysctl

Asserting against "/.." is wrong, because one could rename a link to
"..em1", which is a valid ifname but would crash NetworkManager.

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller
2014-03-24 12:34:43 +01:00
parent 80d2d0ebe1
commit fe88dcd8fe

View File

@@ -1602,7 +1602,7 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value)
g_assert (g_str_has_prefix (path, "/proc/sys/") g_assert (g_str_has_prefix (path, "/proc/sys/")
|| g_str_has_prefix (path, "/sys/")); || g_str_has_prefix (path, "/sys/"));
/* Don't write to suspicious locations */ /* Don't write to suspicious locations */
g_assert (!strstr (path, "/..")); g_assert (!strstr (path, "/../"));
fd = open (path, O_WRONLY | O_TRUNC); fd = open (path, O_WRONLY | O_TRUNC);
if (fd == -1) { if (fd == -1) {
@@ -1701,7 +1701,7 @@ sysctl_get (NMPlatform *platform, const char *path)
g_assert (g_str_has_prefix (path, "/proc/sys/") g_assert (g_str_has_prefix (path, "/proc/sys/")
|| g_str_has_prefix (path, "/sys/")); || g_str_has_prefix (path, "/sys/"));
/* Don't write to suspicious locations */ /* Don't write to suspicious locations */
g_assert (!strstr (path, "/..")); g_assert (!strstr (path, "/../"));
if (!g_file_get_contents (path, &contents, NULL, &error)) { if (!g_file_get_contents (path, &contents, NULL, &error)) {
/* We assume FAILED means EOPNOTSUP */ /* We assume FAILED means EOPNOTSUP */