diff options
author | Antonio Cardace <acardace@redhat.com> | 2020-02-18 12:16:02 +0100 |
---|---|---|
committer | Antonio Cardace <acardace@redhat.com> | 2020-02-18 13:11:21 +0100 |
commit | ed5a647ad17833a10c325661d28af41a07995c3c (patch) | |
tree | b3e699de1686ff75fa178295a9f2cf3c29ca504c | |
parent | 82697358e348274ebdbf42bbc526e753c1ae36e5 (diff) | |
download | NetworkManager-ed5a647ad17833a10c325661d28af41a07995c3c.tar.gz |
nm-shared-utils: relax ovs ifname check to accept any (non-space) ASCII printable char
quoting 'man ovs-vswitchd.conf.db':
"The name must be alphanumeric and must not contain forward or backward
slashes."
OVS actually accepts a wider range of chars (all printable UTF-8 chars),
NetworkManager restricts this to ASCII char as it's a safer option for
now since OVS is not well documented on this matter.
https://bugzilla.redhat.com/show_bug.cgi?id=1788432
Fixes: e7d72a14f6 ('libnm-core: use different ifname validation function for OVS bridges, ports and interfaces')
-rw-r--r-- | libnm-core/tests/test-general.c | 20 | ||||
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.c | 7 |
2 files changed, 10 insertions, 17 deletions
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index d928d855bb..88ca93f95d 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -8503,21 +8503,6 @@ test_connection_ovs_ifname (gconstpointer test_data) nmtst_assert_connection_unnormalizable (con, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY); - - /* wrong: contains non-alphanumerical char */ - g_object_set (s_con, - NM_SETTING_CONNECTION_INTERFACE_NAME, "ovs-0", - NULL); - nmtst_assert_connection_unnormalizable (con, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY); - - g_object_set (s_con, - NM_SETTING_CONNECTION_INTERFACE_NAME, "ovs@0", - NULL); - nmtst_assert_connection_unnormalizable (con, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY); } /* wrong: contains space */ @@ -8534,6 +8519,11 @@ test_connection_ovs_ifname (gconstpointer test_data) NULL); nmtst_assert_connection_verifies (con); + g_object_set (s_con, + NM_SETTING_CONNECTION_INTERFACE_NAME, "ovs-br0", + NULL); + nmtst_assert_connection_verifies (con); + /* good if bridge, port, or patch interface */ g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "ovs123123123123130123123", diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 89ee66f7e0..b6f260f527 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -4097,11 +4097,14 @@ _nm_utils_ifname_valid_ovs (const char* name, GError **error) { const char *ch; + /* OVS actually accepts a wider range of chars (all printable UTF-8 chars), + NetworkManager restricts this to ASCII char as it's a safer option for + now since OVS is not well documented on this matter. + */ for (ch = name; *ch; ++ch) { if ( *ch == '\\' || *ch == '/' - || g_ascii_isspace (*ch) - || !g_ascii_isalnum (*ch)) { + || !g_ascii_isgraph (*ch)) { g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, _("interface name must be alphanumerical with " "no forward or backward slashes")); |