From a1c3408d054e8f0c14d90a69ba3e4bd86ade93f3 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 3 Aug 2010 16:17:45 -0700 Subject: [PATCH] ifcfg-rh: ignore BRIDGE and VLAN configs until we support them (rh #619863) --- system-settings/plugins/ifcfg-rh/common.h | 1 + system-settings/plugins/ifcfg-rh/reader.c | 25 +++++- .../tests/network-scripts/Makefile.am | 5 +- .../ifcfg-test-bridge-component | 5 ++ .../network-scripts/ifcfg-test-bridge-main | 7 ++ .../network-scripts/ifcfg-test-vlan-interface | 7 ++ .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 84 +++++++++++++++++++ 7 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-component create mode 100644 system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main create mode 100644 system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-interface diff --git a/system-settings/plugins/ifcfg-rh/common.h b/system-settings/plugins/ifcfg-rh/common.h index f5ab1c896d..9c578db092 100644 --- a/system-settings/plugins/ifcfg-rh/common.h +++ b/system-settings/plugins/ifcfg-rh/common.h @@ -41,6 +41,7 @@ #define TYPE_ETHERNET "Ethernet" #define TYPE_WIRELESS "Wireless" +#define TYPE_BRIDGE "Bridge" GQuark ifcfg_plugin_error_quark (void); diff --git a/system-settings/plugins/ifcfg-rh/reader.c b/system-settings/plugins/ifcfg-rh/reader.c index a5d6c37db7..51a2075a17 100644 --- a/system-settings/plugins/ifcfg-rh/reader.c +++ b/system-settings/plugins/ifcfg-rh/reader.c @@ -3197,7 +3197,7 @@ connection_from_file (const char *filename, { NMConnection *connection = NULL; shvarFile *parsed; - char *type, *nmc = NULL, *bootproto; + char *type, *nmc = NULL, *bootproto, *tmp; NMSetting *s_ip4, *s_ip6; const char *ifcfg_name = NULL; gboolean nm_controlled = TRUE; @@ -3285,11 +3285,32 @@ connection_from_file (const char *filename, g_free (lower); } + /* Ignore BRIDGE= and VLAN= connections for now too (rh #619863) */ + tmp = svGetValue (parsed, "BRIDGE", FALSE); + if (tmp) { + g_set_error (error, ifcfg_plugin_error_quark (), 0, + "Bridge component connections are not yet supported"); + g_free (tmp); + goto done; + } + + tmp = svGetValue (parsed, "VLAN", FALSE); + if (tmp) { + g_set_error (error, ifcfg_plugin_error_quark (), 0, + "VLAN connections are not yet supported"); + g_free (tmp); + goto done; + } + + /* Construct the connection */ if (!strcasecmp (type, TYPE_ETHERNET)) connection = wired_connection_from_ifcfg (filename, parsed, nm_controlled, unmanaged, error); else if (!strcasecmp (type, TYPE_WIRELESS)) connection = wireless_connection_from_ifcfg (filename, parsed, nm_controlled, unmanaged, error); - else { + else if (!strcasecmp (type, TYPE_BRIDGE)) { + g_set_error (error, ifcfg_plugin_error_quark (), 0, + "Bridge connections are not yet supported"); + } else { g_set_error (error, ifcfg_plugin_error_quark (), 0, "Unknown connection type '%s'", type); } diff --git a/system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index fd2629173a..6ca6b6b320 100644 --- a/system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/system-settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -65,7 +65,10 @@ EXTRA_DIST = \ keys-test-wifi-wep-40-ascii \ ifcfg-test-wifi-wep-104-ascii \ keys-test-wifi-wep-104-ascii \ - ifcfg-test-wired-qeth-static + ifcfg-test-wired-qeth-static \ + ifcfg-test-bridge-main \ + ifcfg-test-bridge-component \ + ifcfg-test-vlan-interface check-local: @for f in $(EXTRA_DIST); do \ diff --git a/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-component b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-component new file mode 100644 index 0000000000..f586637ec3 --- /dev/null +++ b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-component @@ -0,0 +1,5 @@ +DEVICE=eth0 +HWADDR=00:22:15:59:62:97 +ONBOOT=no +BRIDGE=br0 + diff --git a/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main new file mode 100644 index 0000000000..c5caf3fc9b --- /dev/null +++ b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main @@ -0,0 +1,7 @@ +DEVICE=br0 +ONBOOT=no +TYPE=Bridge +BOOTPROTO=dhcp +STP=on +DELAY=0 + diff --git a/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-interface b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-interface new file mode 100644 index 0000000000..6c841855ed --- /dev/null +++ b/system-settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-interface @@ -0,0 +1,7 @@ +DEVICE=eth1.43 +VLAN=yes +ONBOOT=yes +BOOTPROTO=none +IPADDR=192.168.43.149 +NETMASK=255.255.255.0 + diff --git a/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 70b58d424c..e19acb1311 100644 --- a/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -9282,6 +9282,87 @@ test_write_mobile_broadband (gboolean gsm) g_object_unref (connection); } +#define TEST_IFCFG_BRIDGE_MAIN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-main" + +static void +test_read_bridge_main (void) +{ + NMConnection *connection; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_BRIDGE_MAIN, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + ASSERT (connection == NULL, + "bridge-main-read", "unexpected success reading %s", TEST_IFCFG_BRIDGE_MAIN); +} + +#define TEST_IFCFG_BRIDGE_COMPONENT TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-component" + +static void +test_read_bridge_component (void) +{ + NMConnection *connection; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_BRIDGE_COMPONENT, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + ASSERT (connection == NULL, + "bridge-component-read", "unexpected success reading %s", TEST_IFCFG_BRIDGE_COMPONENT); +} + +#define TEST_IFCFG_VLAN_INTERFACE TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-interface" + +static void +test_read_vlan_interface (void) +{ + NMConnection *connection; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_VLAN_INTERFACE, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + ASSERT (connection == NULL, + "vlan-interface-read", "unexpected success reading %s", TEST_IFCFG_VLAN_INTERFACE); +} + #define TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_QUOTED TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-quoted" #define TEST_IFCFG_WIFI_OPEN_SSID_LONG_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-long-hex" @@ -9411,6 +9492,9 @@ int main (int argc, char **argv) test_write_vpn (); test_write_mobile_broadband (TRUE); test_write_mobile_broadband (FALSE); + test_read_bridge_main (); + test_read_bridge_component (); + test_read_vlan_interface (); base = g_path_get_basename (argv[0]); fprintf (stdout, "%s: SUCCESS\n", base);