diff options
Diffstat (limited to 'src/settings/plugins/ifcfg-rh')
9 files changed, 130 insertions, 39 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml index 1f308dd4..c2a6cb34 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml @@ -2,28 +2,28 @@ <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> <interface name="com.redhat.ifcfgrh1"> - <tp:docstring> + <annotation name="org.gtk.GDBus.DocString" value=" Utility methods for handling NM integration with standard Red Hat ifcfg files. - </tp:docstring> + " /> <method name="GetIfcfgDetails"> - <tp:docstring> + <annotation name="org.gtk.GDBus.DocString" value=" Given an ifcfg file, return various internal information about it. - </tp:docstring> + " /> <arg name="ifcfg" type="s" direction="in"> - <tp:docstring> + <annotation name="org.gtk.GDBus.DocString" value=" The full path to an ifcfg file. - </tp:docstring> + " /> </arg> <arg name="uuid" type="s" direction="out"> - <tp:docstring> + <annotation name="org.gtk.GDBus.DocString" value=" The UUID of the NM connection backed by this ifcfg file. If the ifcfg file does not contain a UUID tag, this UUID is generated by NM, otherwise the UUID from the ifcfg file is used. - </tp:docstring> + " /> </arg> <arg name="path" type="o" direction="out"> - <tp:docstring> + <annotation name="org.gtk.GDBus.DocString" value=" The object path of the NM connected backed by this ifcfg file. - </tp:docstring> + " /> </arg> </method> </interface> diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index d28e3bf6..1fb6b789 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -207,8 +207,10 @@ update_connection (SettingsPluginIfcfg *self, && !protect_existing_connection && (!protected_connections || !g_hash_table_contains (protected_connections, connection))) remove_connection (self, connection); - if (!source && !ignore_error) - _LOGW ("loading \"%s\" fails: %s", full_path, local ? local->message : "(unknown reason)"); + if (!source) { + _NMLOG (ignore_error ? LOGL_DEBUG : LOGL_WARN, + "loading \"%s\" fails: %s", full_path, local ? local->message : "(unknown reason)"); + } g_propagate_error (error, local); return NULL; } diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index ca512fc6..41ffa27d 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -3076,6 +3076,13 @@ fill_8021x (shvarFile *ifcfg, read_8021x_list_value (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", s_8021x, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES); + value = svGetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", FALSE); + g_object_set (s_8021x, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, value, NULL); + g_free (value); + value = svGetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", FALSE); + g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, value, NULL); + g_free (value); + if (list) g_strfreev (list); if (keys) @@ -4993,14 +5000,24 @@ connection_from_file_full (const char *filename, type = svGetValue (parsed, "TYPE", FALSE); if (!type) { + gs_free char *tmp = NULL; char *device; + if ((tmp = svGetValue (parsed, "IPV6TUNNELIPV4", FALSE))) { + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignoring unsupported connection due to IPV6TUNNELIPV4"); + goto done; + } + device = svGetValue (parsed, "DEVICE", FALSE); if (!device) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "File '%s' had neither TYPE nor DEVICE keys.", filename); goto done; } + g_assert (device[0]); if (!strcmp (device, "lo")) { if (out_ignore_error) @@ -5018,8 +5035,51 @@ connection_from_file_full (const char *filename, type = g_strdup (TYPE_VLAN); else if (is_wifi_device (device, parsed)) type = g_strdup (TYPE_WIRELESS); - else - type = g_strdup (TYPE_ETHERNET); + else { + gs_free char *p_path = NULL; + char *p_device; + gsize i; + + /* network-functions detects DEVICETYPE based on the ifcfg-* name and the existence + * of a ifup script: + * [ -z "$DEVICETYPE" ] && DEVICETYPE=$(echo ${DEVICE} | sed "s/[0-9]*$//") + * later... + * OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" + * */ +#define IFUP_PATH_PREFIX "/etc/sysconfig/network-scripts/ifup-" + i = strlen (device); + p_path = g_malloc (NM_STRLEN (IFUP_PATH_PREFIX) + i + 1); + p_device = &p_path[NM_STRLEN (IFUP_PATH_PREFIX)]; + memcpy (p_device, device, i + 1); + + /* strip trailing numbers */ + while (i >= 1) { + i--; + if (p_device[i] < '0' || p_device[i] > '9') + break; + p_device[i] = '\0'; + } + + if (nm_streq (p_device, "eth")) + type = g_strdup (TYPE_ETHERNET); + else if (nm_streq (p_device, "wireless")) + type = g_strdup (TYPE_WIRELESS); + else if (p_device[0]) { + memcpy (p_path, IFUP_PATH_PREFIX, NM_STRLEN (IFUP_PATH_PREFIX)); + if (access (p_path, X_OK) == 0) { + /* for all other types, this is not something we want to handle. */ + if (out_ignore_error) + *out_ignore_error = TRUE; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Ignore script for unknown device type which has a matching %s script", + p_path); + goto done; + } + } + + if (!type) + type = g_strdup (TYPE_ETHERNET); + } } else { /* For the unit tests, there won't necessarily be any * adapters of the connection's type in the system so the diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index 36e52af4..fc759e6d 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -77,6 +77,7 @@ EXTRA_DIST = \ ifcfg-test-ibft \ ifcfg-test-static-routes-legacy \ route-test-static-routes-legacy \ + ifcfg-test-sit-ignore \ ifcfg-test-wired-static-routes \ route-test-wired-static-routes \ ifcfg-test-wired-static-routes-legacy \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in index 2152961c..e98ea93c 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -473,6 +473,7 @@ EXTRA_DIST = \ ifcfg-test-ibft \ ifcfg-test-static-routes-legacy \ route-test-static-routes-legacy \ + ifcfg-test-sit-ignore \ ifcfg-test-wired-static-routes \ route-test-wired-static-routes \ ifcfg-test-wired-static-routes-legacy \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sit-ignore b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sit-ignore new file mode 100644 index 00000000..a2581db6 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sit-ignore @@ -0,0 +1,12 @@ +# this ifcfg-file represents a "sit" type without explicit TYPE. +# Such connection types are not supported by NetworkManager and +# the connection should be ignored based on the presence of +# IPV6TUNNELIPV4. + +DEVICE=sit1 +BOOTPROTO=none +ONBOOT=yes +IPV6INIT=yes +IPV6TUNNELIPV4=5.4.3.6 +IPV6TUNNELIPV4LOCAL=172.17.1.9 +IPV6ADDR=2001:470:2:3:4::2/64 diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 8ca5c8bb..5ed25fda 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -310,7 +310,7 @@ test_read_miscellaneous_variables (void) int mac_blacklist_num, i; guint64 expected_timestamp = 0; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*"); connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-misc-variables", NULL, TYPE_ETHERNET, NULL); @@ -563,7 +563,7 @@ test_read_wired_static_no_prefix (gconstpointer user_data) file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wired-static-no-prefix-%u", expected_prefix); expected_id = g_strdup_printf ("System test-wired-static-no-prefix-%u", expected_prefix); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing PREFIX, assuming*"); connection = _connection_from_file (file, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages (); @@ -785,7 +785,7 @@ test_read_wired_global_gateway_ignore (void) NMSettingIPConfig *s_ip4; char *unmanaged = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection has no static addresses"); connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway-ignore", TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway-ignore", @@ -1120,7 +1120,7 @@ test_read_wired_ipv6_manual (void) NMIPAddress *ip6_addr; NMIPRoute *ip6_route; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*ignoring manual default route*"); connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-manual", NULL, TYPE_ETHERNET, &unmanaged); @@ -1492,7 +1492,7 @@ test_read_write_802_1X_subj_matches (void) NMSetting8021x *s_8021x; char *written = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1X-subj-matches", NULL, TYPE_ETHERNET, NULL); @@ -1518,7 +1518,7 @@ test_read_write_802_1X_subj_matches (void) TEST_SCRATCH_DIR "/network-scripts/", &written); - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*missing IEEE_8021X_CA_CERT*peap*"); reread = _connection_from_file (written, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages (); @@ -1683,7 +1683,7 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id) static void test_read_wired_aliases_bad_1 (void) { - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*aliasem1:1*has no DEVICE*"); test_read_wired_aliases_bad (TEST_IFCFG_DIR "/network-scripts/ifcfg-aliasem1", "System aliasem1"); } @@ -1691,7 +1691,7 @@ test_read_wired_aliases_bad_1 (void) static void test_read_wired_aliases_bad_2 (void) { - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*aliasem2:1*has invalid DEVICE*"); test_read_wired_aliases_bad (TEST_IFCFG_DIR "/network-scripts/ifcfg-aliasem2", "System aliasem2"); } @@ -3560,9 +3560,6 @@ test_write_wired_static (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile); - /* reread will be normalized, so we must normalize connection too. */ - nm_connection_normalize (connection, NULL, NULL, NULL); - reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL); unlink (testfile); @@ -7329,7 +7326,7 @@ test_read_vlan_reorder_hdr_1 (void) NMConnection *connection; NMSettingVlan *s_vlan; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*REORDER_HDR key is deprecated, use VLAN_FLAGS*"); connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-reorder-hdr-1", NULL, TYPE_ETHERNET, NULL); @@ -8167,7 +8164,7 @@ test_read_dcb_bad_booleans (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*invalid DCB_PG_STRICT value*not all 0s and 1s*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans", NULL, TYPE_ETHERNET, &error); @@ -8182,7 +8179,7 @@ test_read_dcb_short_booleans (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*DCB_PG_STRICT value*8 characters*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans", NULL, TYPE_ETHERNET, &error); @@ -8197,7 +8194,7 @@ test_read_dcb_bad_uints (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*invalid DCB_PG_UP2TC value*not 0 - 7*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints", NULL, TYPE_ETHERNET, &error); @@ -8212,7 +8209,7 @@ test_read_dcb_short_uints (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*DCB_PG_UP2TC value*8 characters*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints", NULL, TYPE_ETHERNET, &error); @@ -8227,7 +8224,7 @@ test_read_dcb_bad_percent (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*invalid DCB_PG_PCT percentage value*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent", NULL, TYPE_ETHERNET, &error); @@ -8242,7 +8239,7 @@ test_read_dcb_short_percent (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*invalid DCB_PG_PCT percentage list value*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent", NULL, TYPE_ETHERNET, &error); @@ -8257,7 +8254,7 @@ test_read_dcb_pgpct_not_100 (void) { gs_free_error GError *error = NULL; - g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*DCB_PG_PCT percentages do not equal 100*"); _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100", NULL, TYPE_ETHERNET, &error); @@ -8738,6 +8735,20 @@ test_read_vlan_trailing_spaces (void) g_object_unref (connection); } +/*****************************************************************************/ + +static void +test_sit_read_ignore (void) +{ + gs_free_error GError *error = NULL; + + _connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-sit-ignore", + NULL, TYPE_ETHERNET, &error); + nmtst_assert_error (error, 0, 0, "*Ignoring unsupported connection due to IPV6TUNNELIPV4*"); +} + +/*****************************************************************************/ + #define TPATH "/settings/plugins/ifcfg-rh/" @@ -8937,10 +8948,8 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wired/write-missing-ipv6", test_write_ethernet_missing_ipv6); g_test_add_func (TPATH "write-dns-options", test_write_dns_options); - /* iSCSI / ibft */ g_test_add_func (TPATH "ibft/ignored", test_read_ibft_ignored); - /* Data Center Bridging (DCB) */ g_test_add_func (TPATH "dcb/read-basic", test_read_dcb_basic); g_test_add_func (TPATH "dcb/write-basic", test_write_dcb_basic); g_test_add_func (TPATH "dcb/default-app-priorities", test_read_dcb_default_app_priorities); @@ -8956,7 +8965,6 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "fcoe/write-fabric", (gpointer) NM_SETTING_DCB_FCOE_MODE_FABRIC, test_write_fcoe_mode); g_test_add_data_func (TPATH "fcoe/write-vn2vn", (gpointer) NM_SETTING_DCB_FCOE_MODE_VN2VN, test_write_fcoe_mode); - /* bonding */ g_test_add_func (TPATH "bond/read-master", test_read_bond_main); g_test_add_func (TPATH "bond/read-slave", test_read_bond_slave); g_test_add_func (TPATH "bond/read-slave-ib", test_read_bond_slave_ib); @@ -8965,20 +8973,20 @@ int main (int argc, char **argv) g_test_add_func (TPATH "bond/write-slave-ib", test_write_bond_slave_ib); g_test_add_func (TPATH "bond/bonding-opts-numeric-mode", test_read_bond_opts_mode_numeric); - /* bridging */ g_test_add_func (TPATH "bridge/read-master", test_read_bridge_main); g_test_add_func (TPATH "bridge/write-master", test_write_bridge_main); g_test_add_func (TPATH "bridge/read-component", test_read_bridge_component); g_test_add_func (TPATH "bridge/write-component", test_write_bridge_component); g_test_add_func (TPATH "bridge/read-missing-stp", test_read_bridge_missing_stp); - /* Team */ g_test_add_func (TPATH "team/read-master", test_read_team_master); g_test_add_func (TPATH "team/write-master", test_write_team_master); g_test_add_func (TPATH "team/read-port", test_read_team_port); g_test_add_func (TPATH "team/write-port", test_write_team_port); g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config); + g_test_add_func (TPATH "sit/read/ignore", test_sit_read_ignore); + /* Stuff we expect to fail for now */ g_test_add_func (TPATH "pppoe/write-wired", test_write_wired_pppoe); g_test_add_func (TPATH "vpn/write", test_write_vpn); diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h index 329f4547..752d08a6 100644 --- a/src/settings/plugins/ifcfg-rh/utils.h +++ b/src/settings/plugins/ifcfg-rh/utils.h @@ -26,7 +26,7 @@ #include "shvar.h" #include "common.h" -#define NM_IFCFG_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory") +#define NM_IFCFG_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") #define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")" #define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) #define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index e7d64379..c17824d6 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -582,6 +582,13 @@ write_8021x_setting (NMConnection *connection, svSetValue (ifcfg, "IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES", str->str, FALSE); g_string_free (str, TRUE); + svSetValue (ifcfg, "IEEE_8021X_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_domain_suffix_match (s_8021x), + FALSE); + svSetValue (ifcfg, "IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH", + nm_setting_802_1x_get_phase2_domain_suffix_match (s_8021x), + FALSE); + success = write_8021x_certs (s_8021x, FALSE, ifcfg, error); if (success) { /* phase2/inner certs */ |