diff options
| author | Michael Biebl <biebl@debian.org> | 2011-05-04 21:35:57 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2011-05-04 21:35:57 +0200 |
| commit | 3241555aff5c969104e492501097f4cb8837bcca (patch) | |
| tree | 6d15a02d02a9f1bfcda6075ae2b8c71537d8038d /src/settings | |
| parent | e1b66c145e71e7bc6a06845dd17788fb7b8e158e (diff) | |
| parent | 9f806e97a24bba61417ae312fcc0da40914266fb (diff) | |
Merge commit 'upstream/0.8.999' into experimental
Diffstat (limited to 'src/settings')
28 files changed, 1189 insertions, 80 deletions
diff --git a/src/settings/Makefile.in b/src/settings/Makefile.in index 81970334..123132b7 100644 --- a/src/settings/Makefile.in +++ b/src/settings/Makefile.in @@ -172,6 +172,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -289,6 +293,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -310,6 +316,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/nm-default-wired-connection.c b/src/settings/nm-default-wired-connection.c index 035d851c..9cbfc760 100644 --- a/src/settings/nm-default-wired-connection.c +++ b/src/settings/nm-default-wired-connection.c @@ -43,14 +43,6 @@ typedef struct { } NMDefaultWiredConnectionPrivate; enum { - PROP_0, - PROP_MAC, - PROP_DEVICE, - PROP_READ_ONLY, - LAST_PROP -}; - -enum { TRY_UPDATE, DELETED, LAST_SIGNAL @@ -120,7 +112,7 @@ nm_default_wired_connection_new (const GByteArray *mac, self = (NMDefaultWiredConnection *) g_object_new (NM_TYPE_DEFAULT_WIRED_CONNECTION, NULL); if (self) { priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (self); - priv->device = device; + priv->device = g_object_ref (device); priv->mac = g_byte_array_sized_new (ETH_ALEN); g_byte_array_append (priv->mac, mac->data, mac->len); diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index f6dbf5e3..87fa4b6c 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -91,6 +91,11 @@ static gboolean impl_settings_list_connections (NMSettings *self, GPtrArray **connections, GError **error); +static gboolean impl_settings_get_connection_by_uuid (NMSettings *self, + const char *uuid, + char **out_object_path, + GError **error); + static void impl_settings_add_connection (NMSettings *self, GHashTable *settings, DBusGMethodInvocation *context); @@ -222,6 +227,38 @@ impl_settings_list_connections (NMSettings *self, return TRUE; } +static gboolean +impl_settings_get_connection_by_uuid (NMSettings *self, + const char *uuid, + char **out_object_path, + GError **error) +{ + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); + GHashTableIter iter; + NMConnection *candidate = NULL; + gboolean found = FALSE; + + load_connections (self); + + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { + if (g_strcmp0 (uuid, nm_connection_get_uuid (candidate)) == 0) { + *out_object_path = g_strdup (nm_connection_get_path (candidate)); + found = TRUE; + break; + } + } + + if (!found) { + g_set_error_literal (error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "No connection with the UUID was found."); + } + + return found; +} + static int connection_sort (gconstpointer pa, gconstpointer pb) { @@ -1099,19 +1136,19 @@ have_connection_for_device (NMSettings *self, GByteArray *mac) g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, NULL, &data)) { NMConnection *connection = NM_CONNECTION (data); - const char *connection_type; + const char *ctype; - s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); - connection_type = nm_setting_connection_get_connection_type (s_con); + s_con = nm_connection_get_setting_connection (connection); + ctype = nm_setting_connection_get_connection_type (s_con); - if ( strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME) - && strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) + if ( strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) + && strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) continue; - s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED); + s_wired = nm_connection_get_setting_wired (connection); /* No wired setting; therefore the PPPoE connection applies to any device */ - if (!s_wired && !strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) { + if (!s_wired && !strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) { ret = TRUE; break; } diff --git a/src/settings/plugins/Makefile.in b/src/settings/plugins/Makefile.in index d0ade2a1..148e9620 100644 --- a/src/settings/plugins/Makefile.in +++ b/src/settings/plugins/Makefile.in @@ -121,6 +121,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -238,6 +242,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -259,6 +265,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in index dac8fc9e..f02b6431 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/Makefile.in @@ -191,6 +191,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -308,6 +312,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -329,6 +335,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index ae40b90a..7915c467 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -213,7 +213,7 @@ remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection) g_return_if_fail (self != NULL); g_return_if_fail (connection != NULL); - managed = !!nm_ifcfg_connection_get_unmanaged_spec (connection); + managed = !nm_ifcfg_connection_get_unmanaged_spec (connection); path = nm_ifcfg_connection_get_path (connection); g_object_ref (connection); diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index c366dd40..a6f9ca85 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -150,6 +150,7 @@ make_connection_setting (const char *file, } } g_free (value); + g_strfreev (items); } return NM_SETTING (s_con); @@ -294,7 +295,7 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg, /* Record is good; fill IP4 config with its info */ if (!method) { g_warning ("%s: malformed iscsiadm record: missing BOOTPROTO.", __func__); - return FALSE; + goto done; } g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, method, NULL); @@ -305,7 +306,7 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg, if (!ipaddr.s_addr || !prefix) { g_warning ("%s: malformed iscsiadm record: BOOTPROTO=static " "but missing IP address or prefix.", __func__); - return FALSE; + goto done; } addr = nm_ip4_address_new (); @@ -322,7 +323,8 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg, // FIXME: DNS search domains? } - return TRUE; + success = TRUE; + goto done; } skip = FALSE; hwaddr_matched = FALSE; @@ -494,7 +496,7 @@ parse_ip6_address (const char *value, static NMIP4Address * read_full_ip4_address (shvarFile *ifcfg, const char *network_file, - guint32 which, + gint32 which, GError **error) { NMIP4Address *addr; @@ -504,12 +506,12 @@ read_full_ip4_address (shvarFile *ifcfg, shvarFile *network_ifcfg; char *value; - g_return_val_if_fail (which > 0, NULL); + g_return_val_if_fail (which >= -1, NULL); g_return_val_if_fail (ifcfg != NULL, NULL); g_return_val_if_fail (network_file != NULL, NULL); addr = nm_ip4_address_new (); - if (which == 1) { + if (which == -1) { ip_tag = g_strdup ("IPADDR"); prefix_tag = g_strdup ("PREFIX"); netmask_tag = g_strdup ("NETMASK"); @@ -768,7 +770,6 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError } } dest = g_match_info_fetch (match_info, 1); - g_match_info_free (match_info); if (!strcmp (dest, "default")) strcpy (dest, "0.0.0.0"); if (inet_pton (AF_INET, dest, &ip4_addr) != 1) { @@ -782,6 +783,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError /* Prefix - is optional; 32 if missing */ prefix = g_match_info_fetch (match_info, 2); + g_match_info_free (match_info); prefix_int = 32; if (prefix) { errno = 0; @@ -793,7 +795,6 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError goto error; } } - nm_ip4_route_set_prefix (route, (guint32) prefix_int); g_free (prefix); @@ -1022,7 +1023,6 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro } } dest = g_match_info_fetch (match_info, 1); - g_match_info_free (match_info); if (!strcmp (dest, "default")) strcpy (dest, "::"); if (inet_pton (AF_INET6, dest, &ip6_addr) != 1) { @@ -1036,6 +1036,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro /* Prefix - is optional; 128 if missing */ prefix = g_match_info_fetch (match_info, 2); + g_match_info_free (match_info); prefix_int = 128; if (prefix) { errno = 0; @@ -1047,7 +1048,6 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro goto error; } } - nm_ip6_route_set_prefix (route, (guint32) prefix_int); g_free (prefix); @@ -1120,7 +1120,7 @@ make_ip4_setting (shvarFile *ifcfg, char *value = NULL; char *route_path = NULL; char *method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - guint32 i; + gint32 i; shvarFile *network_ifcfg; shvarFile *route_ifcfg; gboolean never_default = FALSE, tmp_success; @@ -1164,6 +1164,7 @@ make_ip4_setting (shvarFile *ifcfg, if (!g_ascii_strcasecmp (value, "bootp") || !g_ascii_strcasecmp (value, "dhcp")) method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; else if (!g_ascii_strcasecmp (value, "ibft")) { + g_free (value); g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, NULL); /* iSCSI Boot Firmware Table: need to read values from the iSCSI * firmware for this device and create the IP4 setting using those. @@ -1197,6 +1198,9 @@ make_ip4_setting (shvarFile *ifcfg, g_free (value); } else { char *tmp_ip4, *tmp_prefix, *tmp_netmask; + char *tmp_ip4_0, *tmp_prefix_0, *tmp_netmask_0; + char *tmp_ip4_1, *tmp_prefix_1, *tmp_netmask_1; + char *tmp_ip4_2, *tmp_prefix_2, *tmp_netmask_2; /* If there is no BOOTPROTO, no IPADDR, no PREFIX, no NETMASK, but * valid IPv6 configuration, assume that IPv4 is disabled. Otherwise, @@ -1211,7 +1215,19 @@ make_ip4_setting (shvarFile *ifcfg, tmp_ip4 = svGetValue (ifcfg, "IPADDR", FALSE); tmp_prefix = svGetValue (ifcfg, "PREFIX", FALSE); tmp_netmask = svGetValue (ifcfg, "NETMASK", FALSE); - if (!tmp_ip4 && !tmp_prefix && !tmp_netmask) { + tmp_ip4_0 = svGetValue (ifcfg, "IPADDR0", FALSE); + tmp_prefix_0 = svGetValue (ifcfg, "PREFIX0", FALSE); + tmp_netmask_0 = svGetValue (ifcfg, "NETMASK0", FALSE); + tmp_ip4_1 = svGetValue (ifcfg, "IPADDR1", FALSE); + tmp_prefix_1 = svGetValue (ifcfg, "PREFIX1", FALSE); + tmp_netmask_1 = svGetValue (ifcfg, "NETMASK1", FALSE); + tmp_ip4_2 = svGetValue (ifcfg, "IPADDR2", FALSE); + tmp_prefix_2 = svGetValue (ifcfg, "PREFIX2", FALSE); + tmp_netmask_2 = svGetValue (ifcfg, "NETMASK2", FALSE); + if ( !tmp_ip4 && !tmp_prefix && !tmp_netmask + && !tmp_ip4_0 && !tmp_prefix_0 && !tmp_netmask_0 + && !tmp_ip4_1 && !tmp_prefix_1 && !tmp_netmask_1 + && !tmp_ip4_2 && !tmp_prefix_2 && !tmp_netmask_2) { if (valid_ip6_config) { /* Nope, no IPv4 */ g_object_set (s_ip4, @@ -1225,6 +1241,15 @@ make_ip4_setting (shvarFile *ifcfg, g_free (tmp_ip4); g_free (tmp_prefix); g_free (tmp_netmask); + g_free (tmp_ip4_0); + g_free (tmp_prefix_0); + g_free (tmp_netmask_0); + g_free (tmp_ip4_1); + g_free (tmp_prefix_1); + g_free (tmp_netmask_1); + g_free (tmp_ip4_2); + g_free (tmp_prefix_2); + g_free (tmp_netmask_2); } g_object_set (s_ip4, @@ -1239,12 +1264,17 @@ make_ip4_setting (shvarFile *ifcfg, if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { NMIP4Address *addr; - for (i = 1; i < 256; i++) { + for (i = -1; i < 256; i++) { addr = read_full_ip4_address (ifcfg, network_file, i, error); if (error && *error) goto done; - if (!addr) - break; + if (!addr) { + /* The first mandatory variable is 2-indexed (IPADDR2) + * Variables IPADDR, IPADDR0 and IPADDR1 are optional */ + if (i > 1) + break; + continue; + } if (!nm_setting_ip4_config_add_address (s_ip4, addr)) PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: duplicate IP4 address"); @@ -1650,6 +1680,7 @@ add_one_wep_key (shvarFile *ifcfg, if (key) { nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, key); + g_free (key); success = TRUE; } else g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid WEP key length."); @@ -2782,6 +2813,7 @@ make_wireless_setting (shvarFile *ifcfg, ssid_len = (value_len - 2) / 2; memcpy (buf, tmp, ssid_len); p = &buf[0]; + g_free (tmp); } if (ssid_len > 32 || ssid_len == 0) { @@ -2841,6 +2873,7 @@ make_wireless_setting (shvarFile *ifcfg, if (!eth) { g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid BSSID '%s'", value); + g_free (value); goto error; } @@ -2848,6 +2881,7 @@ make_wireless_setting (shvarFile *ifcfg, g_byte_array_append (bssid, eth->ether_addr_octet, ETH_ALEN); g_object_set (s_wireless, NM_SETTING_WIRELESS_BSSID, bssid, NULL); g_byte_array_free (bssid, TRUE); + g_free (value); } value = svGetValue (ifcfg, "CHANNEL", FALSE); @@ -2867,6 +2901,7 @@ make_wireless_setting (shvarFile *ifcfg, g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "a", NULL); else g_object_set (s_wireless, NM_SETTING_WIRELESS_BAND, "bg", NULL); + g_free (value); } value = svGetValue (ifcfg, "MTU", FALSE); @@ -2882,6 +2917,7 @@ make_wireless_setting (shvarFile *ifcfg, goto error; } g_object_set (s_wireless, NM_SETTING_WIRELESS_MTU, (guint32) mtu, NULL); + g_free (value); } done: @@ -2944,6 +2980,7 @@ wireless_connection_from_ifcfg (const char *file, /* Wireless security */ security_setting = make_wireless_security_setting (ifcfg, file, ssid, adhoc, &s_8021x, error); if (*error) { + g_free (printable_ssid); g_object_unref (connection); return NULL; } @@ -3077,6 +3114,11 @@ make_wired_setting (shvarFile *ifcfg, } g_free (value); + value = svGetValue (ifcfg, "CTCPROT", FALSE); + if (value && strlen (value)) + nm_setting_wired_add_s390_option (s_wired, "ctcprot", value); + g_free (value); + nettype = svGetValue (ifcfg, "NETTYPE", FALSE); if (nettype && strlen (nettype)) { if (!strcmp (nettype, "qeth") || !strcmp (nettype, "lcs") || !strcmp (nettype, "ctc")) @@ -3084,6 +3126,7 @@ make_wired_setting (shvarFile *ifcfg, else PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: unknown s390 NETTYPE '%s'", nettype); } + g_free (nettype); value = svGetValue (ifcfg, "OPTIONS", FALSE); if (value && strlen (value)) { @@ -3106,8 +3149,6 @@ make_wired_setting (shvarFile *ifcfg, } g_free (value); - g_free (nettype); - if (!nm_controlled && !*unmanaged) { /* If NM_CONTROLLED=no but there wasn't a MAC address or z/VM * subchannels, notify the user that the device cannot be unmanaged. @@ -3332,6 +3373,12 @@ connection_from_file (const char *filename, } g_free (device); + } else { + /* Check for IBM s390 CTC devices and call them Ethernet */ + if (g_strcmp0 (type, "CTC") == 0) { + g_free (type); + type = g_strdup (TYPE_ETHERNET); + } } nmc = svGetValue (parsed, "NM_CONTROLLED", FALSE); @@ -3439,6 +3486,7 @@ connection_from_file (const char *filename, g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_READ_ONLY, TRUE, NULL); } + g_free (bootproto); if (!nm_connection_verify (connection, &error)) { g_object_unref (connection); diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 0481e1f6..db084969 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -296,14 +296,14 @@ svSetValue(shvarFile *s, const char *key, const char *value, gboolean verbatim) if (s->current) s->current->data = keyValue; else s->lineList = g_list_append(s->lineList, keyValue); s->modified = 1; + goto end; } else if (val1) { /* delete line */ s->lineList = g_list_remove_link(s->lineList, s->current); g_list_free_1(s->current); s->modified = 1; - goto bail; /* do not need keyValue */ } - goto end; + goto bail; /* do not need keyValue */ } if (!val1) { diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in index 171cd5e5..cd37d0a7 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in @@ -152,6 +152,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -269,6 +273,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -290,6 +296,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ 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 22d1b4a7..935d0ec4 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -58,6 +58,10 @@ EXTRA_DIST = \ route-test-wired-static-routes \ ifcfg-test-wired-static-routes-legacy \ route-test-wired-static-routes-legacy \ + ifcfg-test-wired-ipv4-manual-1 \ + ifcfg-test-wired-ipv4-manual-2 \ + ifcfg-test-wired-ipv4-manual-3 \ + ifcfg-test-wired-ipv4-manual-4 \ ifcfg-test-wired-ipv6-manual \ route6-test-wired-ipv6-manual \ ifcfg-test-wired-static-no-prefix-8 \ @@ -71,6 +75,7 @@ EXTRA_DIST = \ ifcfg-test-wifi-wep-104-ascii \ keys-test-wifi-wep-104-ascii \ ifcfg-test-wired-qeth-static \ + ifcfg-test-wired-ctc-static \ ifcfg-test-bridge-main \ ifcfg-test-bridge-component \ ifcfg-test-vlan-interface \ 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 4f95948f..a10cbb86 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -76,6 +76,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -193,6 +197,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -214,6 +220,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -321,6 +328,10 @@ EXTRA_DIST = \ route-test-wired-static-routes \ ifcfg-test-wired-static-routes-legacy \ route-test-wired-static-routes-legacy \ + ifcfg-test-wired-ipv4-manual-1 \ + ifcfg-test-wired-ipv4-manual-2 \ + ifcfg-test-wired-ipv4-manual-3 \ + ifcfg-test-wired-ipv4-manual-4 \ ifcfg-test-wired-ipv6-manual \ route6-test-wired-ipv6-manual \ ifcfg-test-wired-static-no-prefix-8 \ @@ -334,6 +345,7 @@ EXTRA_DIST = \ ifcfg-test-wifi-wep-104-ascii \ keys-test-wifi-wep-104-ascii \ ifcfg-test-wired-qeth-static \ + ifcfg-test-wired-ctc-static \ ifcfg-test-bridge-main \ ifcfg-test-bridge-component \ ifcfg-test-vlan-interface \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static new file mode 100644 index 00000000..61f8f423 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ctc-static @@ -0,0 +1,12 @@ +# IBM CTC +DEVICE=ctc0 +TYPE=CTC +BOOTPROTO=static +IPADDR=192.168.70.87 +GATEWAY=192.168.70.136 +NETMASK=255.255.255.0 +ONBOOT=yes +SUBCHANNELS=0.0.1b00,0.0.1b01 +NETTYPE=ctc +CTCPROT=0 + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1 new file mode 100644 index 00000000..cad0f6cf --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-1 @@ -0,0 +1,12 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +IPADDR0=1.2.3.4 +PREFIX0=24 +GATEWAY0=1.1.1.1 +IPADDR1=9.8.7.6 +PREFIX1=16 +IPADDR2=3.3.3.3 +PREFIX2=8 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2 new file mode 100644 index 00000000..ad9290a4 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-2 @@ -0,0 +1,14 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +IPADDR=1.2.3.4 +PREFIX=24 +GATEWAY=1.1.1.1 +IPADDR2=9.8.7.6 +PREFIX2=16 +GATEWAY2=5.5.5.5 +IPADDR3=3.3.3.3 +PREFIX3=8 +GATEWAY3=7.7.7.7 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-3 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-3 new file mode 100644 index 00000000..f2457bd2 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-3 @@ -0,0 +1,11 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +IPADDR2=1.2.3.4 +PREFIX2=24 +IPADDR3=9.8.7.6 +PREFIX3=16 +IPADDR4=3.3.3.3 +PREFIX4=8 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-4 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-4 new file mode 100644 index 00000000..e6b77141 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv4-manual-4 @@ -0,0 +1,11 @@ +# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=none +IPADDR=1.2.3.4 +PREFIX=24 +IPADDR1=9.8.7.6 +PREFIX1=16 +IPADDR2=3.3.3.3 +PREFIX2=8 diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c index a6c54fd3..e32ad789 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2008 - 2009 Red Hat, Inc. + * Copyright (C) 2008 - 2011 Red Hat, Inc. */ #include <stdio.h> @@ -53,7 +53,7 @@ test_get_ifcfg_path (const char *desc, const char *path, const char *expected) { - const char *result; + char *result; result = utils_get_ifcfg_path (path); if (expected == NULL) { @@ -64,6 +64,7 @@ test_get_ifcfg_path (const char *desc, ASSERT (strcmp (result, expected) == 0, desc, "unexpected ifcfg name '%s' created for '%s'", result, path); } + g_free (result); } static void @@ -71,7 +72,7 @@ test_get_keys_path (const char *desc, const char *path, const char *expected) { - const char *result; + char *result; result = utils_get_keys_path (path); if (expected == NULL) { @@ -82,6 +83,7 @@ test_get_keys_path (const char *desc, ASSERT (strcmp (result, expected) == 0, desc, "unexpected extra path '%s' created for '%s'", result, path); } + g_free (result); } static void @@ -89,7 +91,7 @@ test_get_route_path (const char *desc, const char *path, const char *expected) { - const char *result; + char *result; result = utils_get_route_path (path); if (expected == NULL) { @@ -100,6 +102,7 @@ test_get_route_path (const char *desc, ASSERT (strcmp (result, expected) == 0, desc, "unexpected extra path '%s' created for '%s'", result, path); } + g_free (result); } static void 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 ebe9e47f..e6013f8d 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -327,6 +327,10 @@ test_read_minimal (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -445,6 +449,7 @@ test_read_unmanaged (void) TEST_IFCFG_UNMANAGED, NM_SETTING_IP4_CONFIG_SETTING_NAME); + g_free (unmanaged); g_object_unref (connection); } @@ -456,7 +461,7 @@ test_read_wired_static (const char *file, const char *expected_id) NMSettingWired *s_wired; NMSettingIP4Config *s_ip4; NMSettingIP6Config *s_ip6; - char *unmanaged = FALSE; + char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; char *route6file = NULL; @@ -494,7 +499,7 @@ test_read_wired_static (const char *file, const char *expected_id) ASSERT (nm_connection_verify (connection, &error), "wired-static-verify", "failed to verify %s: %s", file, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-static-verify", "failed to verify %s: unexpected unmanaged value", file); /* ===== CONNECTION SETTING ===== */ @@ -748,6 +753,10 @@ test_read_wired_static (const char *file, const char *expected_id) file); } + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -759,7 +768,7 @@ test_read_wired_static_no_prefix (guint32 expected_prefix) NMConnection *connection; NMSettingConnection *s_con; NMSettingIP4Config *s_ip4; - char *unmanaged = FALSE; + char *unmanaged = NULL; char *keyfile = NULL; char *routefile = NULL; char *route6file = NULL; @@ -793,7 +802,7 @@ test_read_wired_static_no_prefix (guint32 expected_prefix) ASSERT (nm_connection_verify (connection, &error), "wired-static-no-prefix-verify", "failed to verify %s: %s", file, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-static-no-prefix-verify", "failed to verify %s: unexpected unmanaged value", file); /* ===== CONNECTION SETTING ===== */ @@ -855,6 +864,10 @@ test_read_wired_static_no_prefix (guint32 expected_prefix) NM_SETTING_IP4_CONFIG_ADDRESSES); g_free (file); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -898,7 +911,7 @@ test_read_wired_dhcp (void) ASSERT (nm_connection_verify (connection, &error), "wired-dhcp-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_DHCP, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-dhcp-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_DHCP); /* ===== CONNECTION SETTING ===== */ @@ -1025,7 +1038,10 @@ test_read_wired_dhcp (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); - + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -1068,7 +1084,7 @@ test_read_wired_global_gateway (void) ASSERT (nm_connection_verify (connection, &error), "wired-global-gateway-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_GLOBAL_GATEWAY, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-global-gateway-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_GLOBAL_GATEWAY); /* ===== CONNECTION SETTING ===== */ @@ -1152,6 +1168,10 @@ test_read_wired_global_gateway (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -1191,7 +1211,7 @@ test_read_wired_never_default (void) ASSERT (nm_connection_verify (connection, &error), "wired-never-default-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_NEVER_DEFAULT, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-never-default-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_NEVER_DEFAULT); /* ===== CONNECTION SETTING ===== */ @@ -1274,6 +1294,10 @@ test_read_wired_never_default (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -1312,7 +1336,7 @@ test_read_wired_defroute_no (void) ASSERT (nm_connection_verify (connection, &error), "wired-defroute-no-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_DEFROUTE_NO, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-defroute-no-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_DEFROUTE_NO); /* ===== CONNECTION SETTING ===== */ @@ -1388,6 +1412,10 @@ test_read_wired_defroute_no (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -1433,7 +1461,7 @@ test_read_wired_defroute_no_gatewaydev_yes (void) TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-defroute-no-gatewaydev-yes-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_DEFROUTE_NO_GATEWAYDEV_YES); @@ -1511,6 +1539,10 @@ test_read_wired_defroute_no_gatewaydev_yes (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -1672,6 +1704,7 @@ test_read_wired_static_routes (void) "wired-static-routes-verify-ip4", "failed to verify %s: unexpected route metric #2", TEST_IFCFG_WIRED_STATIC_ROUTES); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -1877,6 +1910,159 @@ test_read_wired_static_routes_legacy (void) "wired-static-routes-legacy-verify-ip4", "failed to verify %s: unexpected destination route #3 metric", TEST_IFCFG_WIRED_STATIC_ROUTES_LEGACY); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); + g_object_unref (connection); +} + +static void +test_read_wired_ipv4_manual (const char *file, const char *expected_id) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + const char *tmp; + const char *expected_address1 = "1.2.3.4"; + const char *expected_address2 = "9.8.7.6"; + const char *expected_address3 = "3.3.3.3"; + guint32 expected_prefix1 = 24; + guint32 expected_prefix2 = 16; + guint32 expected_prefix3 = 8; + NMIP4Address *ip4_addr; + struct in_addr addr; + + connection = connection_from_file (file, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + ASSERT (connection != NULL, + "wired-ipv4-manual-read", "failed to read %s: %s", file, error->message); + + ASSERT (nm_connection_verify (connection, &error), + "wired-ipv4-manual-verify", "failed to verify %s: %s", file, error->message); + + ASSERT (unmanaged == NULL, + "wired-ipv4-manual-verify", "failed to verify %s: unexpected unmanaged value", file); + + /* ===== CONNECTION SETTING ===== */ + + s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); + ASSERT (s_con != NULL, + "wired-ipv4-manual-verify-connection", "failed to verify %s: missing %s setting", + file, + NM_SETTING_CONNECTION_SETTING_NAME); + + /* ID */ + tmp = nm_setting_connection_get_id (s_con); + ASSERT (tmp != NULL, + "wired-ipv4-manual-verify-connection", "failed to verify %s: missing %s / %s key", + file, + NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_ID); + ASSERT (strcmp (tmp, expected_id) == 0, + "wired-ipv4-manual-verify-connection", "failed to verify %s: unexpected %s / %s key value", + file, + NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_ID); + + /* ===== WIRED SETTING ===== */ + + s_wired = NM_SETTING_WIRED (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED)); + ASSERT (s_wired != NULL, + "wired-ipv4-manual-verify-wired", "failed to verify %s: missing %s setting", + file, + NM_SETTING_WIRED_SETTING_NAME); + + /* ===== IPv4 SETTING ===== */ + + s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG)); + ASSERT (s_ip4 != NULL, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing %s setting", + file, + NM_SETTING_IP4_CONFIG_SETTING_NAME); + + /* Method */ + tmp = nm_setting_ip4_config_get_method (s_ip4); + ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", + file, + NM_SETTING_IP4_CONFIG_SETTING_NAME, + NM_SETTING_IP4_CONFIG_METHOD); + + /* IP addresses */ + ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 3, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected %s / %s key value", + file, + NM_SETTING_IP4_CONFIG_SETTING_NAME, + NM_SETTING_IP4_CONFIG_ADDRESSES); + + /* Address #1 */ + ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); + ASSERT (ip4_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #1", + file); + + ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix1, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #1 prefix", + file); + + ASSERT (inet_pton (AF_INET, expected_address1, &addr) > 0, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #1", + file); + ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #1", + file); + + /* Address #2 */ + ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 1); + ASSERT (ip4_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #2", + file); + + ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix2, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #2 prefix", + file); + + ASSERT (inet_pton (AF_INET, expected_address2, &addr) > 0, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #2", + file); + ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #2", + file); + + /* Address #3 */ + ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 2); + ASSERT (ip4_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: missing IP4 address #3", + file); + + ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix3, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #3 prefix", + file); + + ASSERT (inet_pton (AF_INET, expected_address3, &addr) > 0, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: couldn't convert IP address #3", + file); + ASSERT (nm_ip4_address_get_address (ip4_addr) == addr.s_addr, + "wired-ipv4-manual-verify-ip4", "failed to verify %s: unexpected IP4 address #3", + file); + + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -1933,7 +2119,7 @@ test_read_wired_ipv6_manual (void) ASSERT (nm_connection_verify (connection, &error), "wired-ipv6-manual-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_IPV6_MANUAL, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-ipv6-manual-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_IPV6_MANUAL); /* ===== CONNECTION SETTING ===== */ @@ -2176,6 +2362,7 @@ test_read_wired_ipv6_manual (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -2223,7 +2410,7 @@ test_read_wired_ipv6_only (void) ASSERT (nm_connection_verify (connection, &error), "wired-ipv6-only-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-ipv6-only-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_IPV6_MANUAL); /* ===== CONNECTION SETTING ===== */ @@ -2333,6 +2520,7 @@ test_read_wired_ipv6_only (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -2375,7 +2563,7 @@ test_read_wired_dhcp6_only (void) ASSERT (nm_connection_verify (connection, &error), "wired-dhcp6-only-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_DHCP6_ONLY, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-dhcp6-only-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_DHCP6_ONLY); /* ===== CONNECTION SETTING ===== */ @@ -2438,6 +2626,7 @@ test_read_wired_dhcp6_only (void) NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_METHOD); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -2474,7 +2663,7 @@ test_read_onboot_no (void) ASSERT (nm_connection_verify (connection, &error), "onboot-no-verify", "failed to verify %s: %s", TEST_IFCFG_ONBOOT_NO, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "onboot-no-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_ONBOOT_NO); /* ===== CONNECTION SETTING ===== */ @@ -2492,6 +2681,10 @@ test_read_onboot_no (void) NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_AUTOCONNECT); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -2535,7 +2728,7 @@ test_read_wired_8021x_peap_mschapv2 (void) ASSERT (nm_connection_verify (connection, &error), "wired-8021x-peap-mschapv2-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-8021x-peap-mschapv2-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2); /* ===== WIRED SETTING ===== */ @@ -2678,6 +2871,10 @@ test_read_wired_8021x_peap_mschapv2 (void) g_object_unref (tmp_8021x); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -2741,6 +2938,10 @@ test_read_wired_8021x_tls_secret_flags (const char *ifcfg, NMSettingSecretFlags g_free (dirname); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -2919,6 +3120,10 @@ test_read_wifi_open (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -2997,6 +3202,10 @@ test_read_wifi_open_auto (void) NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MODE); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3081,7 +3290,11 @@ test_read_wifi_open_ssid_hex (void) TEST_IFCFG_WIFI_OPEN_SSID_HEX, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3108,6 +3321,11 @@ test_read_wifi_open_ssid_bad (const char *file, const char *test) &ignore_error); ASSERT (connection == NULL, test, "unexpected success reading %s", file); g_clear_error (&error); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); } #define TEST_IFCFG_WIFI_OPEN_SSID_QUOTED TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-quoted" @@ -3191,7 +3409,11 @@ test_read_wifi_open_ssid_quoted (void) TEST_IFCFG_WIFI_OPEN_SSID_QUOTED, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID); - + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3465,6 +3687,10 @@ test_read_wifi_wep (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3729,6 +3955,10 @@ test_read_wifi_wep_adhoc (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3865,6 +4095,10 @@ test_read_wifi_wep_passphrase (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -3998,6 +4232,10 @@ test_read_wifi_wep_40_ascii (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4131,6 +4369,10 @@ test_read_wifi_wep_104_ascii (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4267,6 +4509,10 @@ test_read_wifi_leap (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4322,6 +4568,10 @@ test_read_wifi_leap_secret_flags (const char *file, NMSettingSecretFlags expecte g_assert (nm_setting_wireless_security_get_leap_password_flags (s_wsec) == expected_flags); g_assert (nm_setting_wireless_security_get_leap_password (s_wsec) == NULL); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4637,6 +4887,10 @@ test_read_wifi_wpa_psk (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4738,6 +4992,10 @@ test_read_wifi_wpa_psk_unquoted (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PSK); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -4771,6 +5029,11 @@ test_read_wifi_wpa_psk_unquoted2 (void) ASSERT (connection == NULL, "wifi-wpa-psk-unquoted-read", "unexpected success reading %s", TEST_IFCFG_WIFI_WPA_PSK_UNQUOTED2); g_clear_error (&error); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); } #define TEST_IFCFG_WIFI_WPA_PSK_ADHOC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-wpa-psk-adhoc" @@ -4958,6 +5221,10 @@ test_read_wifi_wpa_psk_adhoc (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5110,6 +5377,10 @@ test_read_wifi_wpa_psk_hex (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5151,7 +5422,7 @@ test_read_wifi_wpa_eap_tls (void) ASSERT (nm_connection_verify (connection, &error), "wifi-wpa-eap-tls-verify", "failed to verify %s: %s", TEST_IFCFG_WIFI_WPA_EAP_TLS, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wifi-wpa-eap-tls-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIFI_WPA_EAP_TLS); /* ===== WIRELESS SETTING ===== */ @@ -5257,6 +5528,10 @@ test_read_wifi_wpa_eap_tls (void) "wifi-wpa-eap-tls-verify-8021x", NM_SETTING_802_1X_PRIVATE_KEY); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5297,7 +5572,7 @@ test_read_wifi_wpa_eap_ttls_tls (void) ASSERT (nm_connection_verify (connection, &error), "wifi-wpa-eap-ttls-tls-verify", "failed to verify %s: %s", TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wifi-wpa-eap-ttls-tls-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIFI_WPA_EAP_TTLS_TLS); /* ===== WIRELESS SETTING ===== */ @@ -5425,6 +5700,10 @@ test_read_wifi_wpa_eap_ttls_tls (void) NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_IDENTITY); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5496,6 +5775,10 @@ test_read_wifi_dynamic_wep_leap (void) g_assert_cmpstr (nm_setting_802_1x_get_identity (s_8021x), ==, "bill smith"); g_assert_cmpstr (nm_setting_802_1x_get_password (s_8021x), ==, "foobar baz"); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5537,7 +5820,7 @@ test_read_wifi_wep_eap_ttls_chap (void) ASSERT (nm_connection_verify (connection, &error), "wifi-wep-eap-ttls-chap-verify", "failed to verify %s: %s", TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wifi-wep-eap-ttls-chap-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIFI_WEP_EAP_TTLS_CHAP); /* ===== WIRELESS SETTING ===== */ @@ -5657,6 +5940,10 @@ test_read_wifi_wep_eap_ttls_chap (void) NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PASSWORD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5699,7 +5986,7 @@ test_read_wired_qeth_static (void) ASSERT (nm_connection_verify (connection, &error), "wired-qeth-static-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_QETH_STATIC, error->message); - ASSERT (unmanaged == FALSE, + ASSERT (unmanaged == NULL, "wired-qeth-static-verify", "failed to verify %s: unexpected unmanaged value", TEST_IFCFG_WIRED_QETH_STATIC); /* ===== CONNECTION SETTING ===== */ @@ -5829,6 +6116,83 @@ test_read_wired_qeth_static (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); + g_object_unref (connection); +} + +#define TEST_IFCFG_WIRED_CTC_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ctc-static" + +static void +test_read_wired_ctc_static (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GError *error = NULL; + const char *tmp; + const char *expected_id = "System test-wired-ctc-static"; + const char *expected_channel0 = "0.0.1b00"; + const char *expected_channel1 = "0.0.1b01"; + const GPtrArray *subchannels; + gboolean success; + + connection = connection_from_file (TEST_IFCFG_WIRED_CTC_STATIC, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (unmanaged == NULL); + + /* ===== CONNECTION SETTING ===== */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con != NULL); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id); + + /* ===== WIRED SETTING ===== */ + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired != NULL); + + g_assert (nm_setting_wired_get_mac_address (s_wired) == NULL); + + /* Subchannels */ + subchannels = nm_setting_wired_get_s390_subchannels (s_wired); + g_assert (subchannels != NULL); + g_assert_cmpint (subchannels->len, ==, 2); + + g_assert_cmpstr (g_ptr_array_index (subchannels, 0), ==, expected_channel0); + g_assert_cmpstr (g_ptr_array_index (subchannels, 1), ==, expected_channel1); + + /* Nettype */ + g_assert_cmpstr (nm_setting_wired_get_s390_nettype (s_wired), ==, "ctc"); + + /* port name */ + tmp = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); + g_assert (tmp != NULL); + g_assert_cmpstr (tmp, ==, "0"); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -5952,6 +6316,10 @@ test_read_wifi_wep_no_keys (void) NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -6022,6 +6390,10 @@ test_read_permissions (void) ASSERT (strcmp (tmp, "johnny5") == 0, "permissions-verify-permissions", "unexpected permission #3"); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -6086,6 +6458,10 @@ test_read_wifi_wep_agent_keys (void) flags = nm_setting_wireless_security_get_wep_key_flags (s_wsec); g_assert (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -6316,6 +6692,7 @@ test_write_wired_static (void) unlink (route6file); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -6434,6 +6811,10 @@ test_write_wired_dhcp (void) "wired-dhcp-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -6571,6 +6952,7 @@ test_write_wired_static_ip6_only (void) unlink (route6file); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -6715,6 +7097,7 @@ test_read_write_static_routes_legacy (void) "read-write-static-routes-legacy-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (keyfile2); g_free (routefile); @@ -6896,6 +7279,7 @@ test_write_wired_static_routes (void) "wired-static-routes-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -7037,6 +7421,10 @@ test_write_wired_dhcp_8021x_peap_mschapv2 (void) "wired-dhcp-8021x-peap-mschapv2write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7265,6 +7653,10 @@ test_write_wired_8021x_tls (NMSetting8021xCKScheme scheme, g_free (tmp); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7403,6 +7795,7 @@ test_write_wifi_open (void) ASSERT (strncmp (tmp, "\"\"", 2) != 0, "wifi-open-write-reread", "unexpected ESSID double-quote in %s", testfile); + g_free (tmp); svCloseFile (ifcfg); unlink (testfile); @@ -7417,6 +7810,10 @@ test_write_wifi_open (void) "wifi-open-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7536,6 +7933,10 @@ test_write_wifi_open_hex_ssid (void) "wifi-open-hex-ssid-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7687,6 +8088,10 @@ test_write_wifi_wep (void) "wifi-wep-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7846,6 +8251,10 @@ test_write_wifi_wep_adhoc (void) "wifi-wep-adhoc-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -7995,6 +8404,10 @@ test_write_wifi_wep_passphrase (void) "wifi-wep-passphrase-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8146,6 +8559,10 @@ test_write_wifi_wep_40_ascii (void) "wifi-wep-40-ascii-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8297,6 +8714,10 @@ test_write_wifi_wep_104_ascii (void) "wifi-wep-104-ascii-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8445,6 +8866,10 @@ test_write_wifi_leap (void) "wifi-leap-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8571,6 +8996,10 @@ test_write_wifi_leap_secret_flags (NMSettingSecretFlags flags) g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8732,6 +9161,10 @@ test_write_wifi_wpa_psk (const char *name, test_name, "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -8889,6 +9322,10 @@ test_write_wifi_wpa_psk_adhoc (void) "wifi-wpa-psk-adhoc-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9066,6 +9503,10 @@ test_write_wifi_wpa_eap_tls (void) "wifi-wpa-eap-tls-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9261,6 +9702,10 @@ test_write_wifi_wpa_eap_ttls_tls (void) "wifi-wpa-eap-ttls-tls-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9428,11 +9873,203 @@ test_write_wifi_wpa_eap_ttls_mschapv2 (void) "wifi-wpa-eap-ttls-mschapv2-write", "written and re-read connection weren't the same."); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } static void +test_write_wifi_wpa_then_open (void) +{ + NMConnection *connection; + NMConnection *reread; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + NMSettingIP4Config *s_ip4; + NMSettingIP6Config *s_ip6; + char *uuid; + gboolean success; + GError *error = NULL; + char *testfile = NULL; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + GByteArray *ssid; + const unsigned char ssid_data[] = "blahblah"; + + /* Test that writing out a WPA config then changing that to an open + * config doesn't leave various WPA-related keys lying around in the ifcfg. + */ + + connection = nm_connection_new (); + g_assert (connection); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + g_assert (s_con); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "random wifi connection", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + g_assert (s_wifi); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_byte_array_sized_new (sizeof (ssid_data)); + g_byte_array_append (ssid, ssid_data, sizeof (ssid_data)); + + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, + NULL); + + g_byte_array_free (ssid, TRUE); + + /* Wireless security setting */ + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + g_assert (s_wsec); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", + NM_SETTING_WIRELESS_SECURITY_PSK, "some cool PSK", + NULL); + + nm_setting_wireless_security_add_proto (s_wsec, "wpa"); + nm_setting_wireless_security_add_pairwise (s_wsec, "tkip"); + nm_setting_wireless_security_add_group (s_wsec, "tkip"); + + nm_setting_wireless_security_add_proto (s_wsec, "rsn"); + nm_setting_wireless_security_add_pairwise (s_wsec, "ccmp"); + nm_setting_wireless_security_add_group (s_wsec, "ccmp"); + + /* IP4 setting */ + s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + g_assert (s_ip4); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + /* IP6 setting */ + s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + g_assert (s_ip6); + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + g_assert (testfile); + + /* re-read the connection for comparison */ + reread = connection_from_file (testfile, + NULL, + TYPE_WIRELESS, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + g_assert_no_error (error); + g_assert (reread); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + + success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (success); + + g_free (unmanaged); + unmanaged = NULL; + g_free (routefile); + routefile = NULL; + g_free (route6file); + route6file = NULL; + g_object_unref (reread); + + /* Now change the connection to open and recheck */ + s_wifi = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS); + g_assert (s_wifi); + g_object_set (s_wifi, NM_SETTING_WIRELESS_SEC, NULL, NULL); + nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); + + /* Write it back out */ + success = writer_update_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + testfile, + keyfile, + &error); + g_assert_no_error (error); + g_assert (success); + + unlink (keyfile); + g_free (keyfile); + keyfile = NULL; + + /* re-read it for comparison */ + reread = connection_from_file (testfile, + NULL, + TYPE_WIRELESS, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + unlink (testfile); + g_assert_no_error (error); + + g_assert (reread); + + /* No keyfile since it's an open connection this time */ + g_assert (keyfile); + g_assert (g_file_test (keyfile, G_FILE_TEST_EXISTS) == FALSE); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + + success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (success); + + unlink (testfile); + g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); + g_object_unref (reread); + + g_object_unref (connection); +} + +static void test_write_wifi_dynamic_wep_leap (void) { NMConnection *connection; @@ -9568,11 +10205,16 @@ test_write_wifi_dynamic_wep_leap (void) tmp = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE); g_assert_cmpstr (tmp, ==, "LEAP"); + g_free (tmp); svCloseFile (ifcfg); unlink (testfile); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9709,6 +10351,10 @@ test_read_ibft_dhcp (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_METHOD); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -9921,6 +10567,10 @@ test_read_ibft_static (void) NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ADDRESSES); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); g_object_unref (connection); } @@ -9949,6 +10599,11 @@ test_read_ibft_malformed (const char *name, const char *iscsiadm_path) &ignore_error); ASSERT (connection == NULL, name, "unexpectedly able to read %s", TEST_IFCFG_IBFT_STATIC); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); } static void @@ -10078,6 +10733,135 @@ test_write_wired_qeth_dhcp (void) unlink (route6file); g_free (testfile); + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); + g_object_unref (connection); + g_object_unref (reread); +} + +static void +test_write_wired_ctc_dhcp (void) +{ + NMConnection *connection; + NMConnection *reread; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + NMSettingIP6Config *s_ip6; + char *uuid; + GPtrArray *subchans; + gboolean success; + GError *error = NULL; + char *testfile = NULL; + char *unmanaged = NULL; + char *keyfile = NULL; + char *routefile = NULL; + char *route6file = NULL; + gboolean ignore_error = FALSE; + shvarFile *ifcfg; + char *tmp; + + connection = nm_connection_new (); + g_assert (connection); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + g_assert (s_con); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Wired ctc Static", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + g_assert (s_wired); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + subchans = g_ptr_array_sized_new (2); + g_ptr_array_add (subchans, "0.0.600"); + g_ptr_array_add (subchans, "0.0.601"); + g_object_set (s_wired, + NM_SETTING_WIRED_S390_SUBCHANNELS, subchans, + NM_SETTING_WIRED_S390_NETTYPE, "ctc", + NULL); + g_ptr_array_free (subchans, TRUE); + nm_setting_wired_add_s390_option (s_wired, "ctcprot", "0"); + + /* IP4 setting */ + s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); + g_assert (s_ip4); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + + /* IP6 setting */ + s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new (); + g_assert (s_ip6); + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + + /* Verify */ + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + g_assert (testfile != NULL); + + /* Ensure the CTCPROT item gets written out as it's own option */ + ifcfg = svNewFile (testfile); + g_assert (ifcfg); + + tmp = svGetValue (ifcfg, "CTCPROT", TRUE); + g_assert (tmp); + g_assert_cmpstr (tmp, ==, "0"); + g_free (tmp); + + /* And that it's not in the generic OPTIONS string */ + tmp = svGetValue (ifcfg, "OPTIONS", TRUE); + g_assert (tmp == NULL); + g_free (tmp); + + svCloseFile (ifcfg); + + /* re-read the connection for comparison */ + reread = connection_from_file (testfile, + NULL, + TYPE_ETHERNET, + NULL, + &unmanaged, + &keyfile, + &routefile, + &route6file, + &error, + &ignore_error); + unlink (testfile); + + g_assert (reread); + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (success); + + if (route6file) + unlink (route6file); + + g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -10200,6 +10984,7 @@ test_write_permissions (void) unlink (route6file); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -10330,6 +11115,7 @@ test_write_wifi_wep_agent_keys (void) unlink (route6file); g_free (testfile); + g_free (unmanaged); g_free (keyfile); g_free (routefile); g_free (route6file); @@ -10624,6 +11410,11 @@ test_read_bridge_main (void) &ignore_error); ASSERT (connection == NULL, "bridge-main-read", "unexpected success reading %s", TEST_IFCFG_BRIDGE_MAIN); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); } #define TEST_IFCFG_BRIDGE_COMPONENT TEST_IFCFG_DIR"/network-scripts/ifcfg-test-bridge-component" @@ -10658,8 +11449,11 @@ test_read_bridge_component (void) ASSERT (g_strcmp0 (unmanaged, "mac:00:22:15:59:62:97") == 0, "bridge-component-read", "unexpected unmanaged spec from %s", TEST_IFCFG_BRIDGE_COMPONENT); - g_object_unref (connection); g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); + g_object_unref (connection); } #define TEST_IFCFG_VLAN_INTERFACE TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-interface" @@ -10687,6 +11481,11 @@ test_read_vlan_interface (void) &ignore_error); ASSERT (connection == NULL, "vlan-interface-read", "unexpected success reading %s", TEST_IFCFG_VLAN_INTERFACE); + + g_free (unmanaged); + g_free (keyfile); + g_free (routefile); + g_free (route6file); } #define TEST_IFCFG_WIFI_OPEN_SSID_BAD_HEX TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open-ssid-bad-hex" @@ -10697,6 +11496,11 @@ test_read_vlan_interface (void) #define TEST_IFCFG_WIRED_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static" #define TEST_IFCFG_WIRED_STATIC_BOOTPROTO TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-static-bootproto" +#define TEST_IFCFG_WIRED_IPV4_MANUAL_1 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv4-manual-1" +#define TEST_IFCFG_WIRED_IPV4_MANUAL_2 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv4-manual-2" +#define TEST_IFCFG_WIRED_IPV4_MANUAL_3 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv4-manual-3" +#define TEST_IFCFG_WIRED_IPV4_MANUAL_4 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv4-manual-4" + #define DEFAULT_HEX_PSK "7d308b11df1b4243b0f78e5f3fc68cdbb9a264ed0edf4c188edf329ff5b467f0" int main (int argc, char **argv) @@ -10724,6 +11528,10 @@ int main (int argc, char **argv) test_read_wired_defroute_no_gatewaydev_yes (); test_read_wired_static_routes (); test_read_wired_static_routes_legacy (); + test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_1, "System test-wired-ipv4-manual-1"); + test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_2, "System test-wired-ipv4-manual-2"); + test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_3, "System test-wired-ipv4-manual-3"); + test_read_wired_ipv4_manual (TEST_IFCFG_WIRED_IPV4_MANUAL_4, "System test-wired-ipv4-manual-4"); test_read_wired_ipv6_manual (); test_read_wired_ipv6_only (); test_read_wired_dhcp6_only (); @@ -10758,6 +11566,7 @@ int main (int argc, char **argv) test_read_wifi_wpa_eap_ttls_tls (); test_read_wifi_wep_eap_ttls_chap (); test_read_wired_qeth_static (); + test_read_wired_ctc_static (); test_read_wifi_wep_no_keys (); test_read_permissions (); test_read_wifi_wep_agent_keys (); @@ -10818,7 +11627,9 @@ int main (int argc, char **argv) test_write_wifi_wpa_eap_ttls_tls (); test_write_wifi_wpa_eap_ttls_mschapv2 (); test_write_wifi_dynamic_wep_leap (); + test_write_wifi_wpa_then_open (); test_write_wired_qeth_dhcp (); + test_write_wired_ctc_dhcp (); test_write_permissions (); test_write_wifi_wep_agent_keys (); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 6924262f..6b66b232 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -354,6 +354,7 @@ write_object (NMSetting8021x *s_8021x, success = write_secret_file (new_file, (const char *) blob->data, blob->len, &write_error); if (success) { svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE); + g_free (new_file); return TRUE; } else { g_set_error (error, IFCFG_PLUGIN_ERROR, 0, @@ -884,6 +885,38 @@ write_wireless_setting (NMConnection *connection, if (nm_setting_wireless_get_security (s_wireless)) { if (!write_wireless_security_setting (connection, ifcfg, adhoc, no_8021x, error)) return FALSE; + } else { + char *keys_path; + + /* Clear out wifi security keys */ + svSetValue (ifcfg, "KEY_MGMT", NULL, FALSE); + svSetValue (ifcfg, "IEEE_8021X_IDENTITY", NULL, FALSE); + set_secret (ifcfg, "IEEE_8021X_PASSWORD", NULL, "IEEE_8021X_PASSWORD_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + svSetValue (ifcfg, "SECURITYMODE", NULL, FALSE); + + /* Clear existing keys */ + set_secret (ifcfg, "KEY", NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + for (i = 0; i < 4; i++) { + tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + g_free (tmp); + + tmp = g_strdup_printf ("KEY%d", i + 1); + set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + g_free (tmp); + } + + svSetValue (ifcfg, "DEFAULTKEY", NULL, FALSE); + svSetValue (ifcfg, "WPA_ALLOW_WPA", NULL, FALSE); + svSetValue (ifcfg, "WPA_ALLOW_WPA2", NULL, FALSE); + svSetValue (ifcfg, "CIPHER_PAIRWISE", NULL, FALSE); + svSetValue (ifcfg, "CIPHER_GROUP", NULL, FALSE); + set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); + + /* Kill any old keys file */ + keys_path = utils_get_keys_path (ifcfg->fileName); + (void) unlink (keys_path); + g_free (keys_path); } svSetValue (ifcfg, "TYPE", TYPE_WIRELESS, FALSE); @@ -897,7 +930,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) NMSettingWired *s_wired; const GByteArray *device_mac, *cloned_mac; char *tmp; - const char *nettype, *portname, *s390_key, *s390_val; + const char *nettype, *portname, *ctcprot, *s390_key, *s390_val; guint32 mtu, num_opts, i; const GPtrArray *s390_subchannels; GString *str; @@ -964,6 +997,11 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) if (portname) svSetValue (ifcfg, "PORTNAME", portname, FALSE); + svSetValue (ifcfg, "CTCPROT", NULL, FALSE); + ctcprot = nm_setting_wired_get_s390_option_by_key (s_wired, "ctcprot"); + if (ctcprot) + svSetValue (ifcfg, "CTCPROT", ctcprot, FALSE); + svSetValue (ifcfg, "OPTIONS", NULL, FALSE); num_opts = nm_setting_wired_get_num_s390_options (s_wired); if (s390_subchannels && num_opts) { @@ -972,7 +1010,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) nm_setting_wired_get_s390_option (s_wired, i, &s390_key, &s390_val); /* portname is handled separately */ - if (!strcmp (s390_key, "portname")) + if (!strcmp (s390_key, "portname") || !strcmp (s390_key, "ctcprot")) continue; if (str->len) @@ -1090,6 +1128,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) const char *value; char *addr_key, *prefix_key, *netmask_key, *gw_key, *metric_key, *tmp; char *route_path = NULL; + gint32 j; guint32 i, num; GString *searches; gboolean success = FALSE; @@ -1109,20 +1148,28 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) /* IPv4 disabled, clear IPv4 related parameters */ svSetValue (ifcfg, "BOOTPROTO", NULL, FALSE); - for (i = 0; i < 254; i++) { - if (i == 0) { + for (j = -1; j < 256; j++) { + if (j == -1) { addr_key = g_strdup ("IPADDR"); prefix_key = g_strdup ("PREFIX"); + netmask_key = g_strdup ("NETMASK"); gw_key = g_strdup ("GATEWAY"); } else { - addr_key = g_strdup_printf ("IPADDR%d", i + 1); - prefix_key = g_strdup_printf ("PREFIX%d", i + 1); - gw_key = g_strdup_printf ("GATEWAY%d", i + 1); + addr_key = g_strdup_printf ("IPADDR%d", j); + prefix_key = g_strdup_printf ("PREFIX%d", j); + netmask_key = g_strdup_printf ("NETMASK%d", j); + gw_key = g_strdup_printf ("GATEWAY%d", j); } svSetValue (ifcfg, addr_key, NULL, FALSE); svSetValue (ifcfg, prefix_key, NULL, FALSE); + svSetValue (ifcfg, netmask_key, NULL, FALSE); svSetValue (ifcfg, gw_key, NULL, FALSE); + + g_free (addr_key); + g_free (prefix_key); + g_free (netmask_key); + g_free (gw_key); } route_path = utils_get_route_path (ifcfg->fileName); @@ -1146,25 +1193,27 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) svSetValue (ifcfg, "BOOTPROTO", "shared", FALSE); + /* Write out IPADDR0 .. IPADDR255, PREFIX0 .. PREFIX255, GATEWAY0 .. GATEWAY255 + * Possible NETMASK<n> is removed only (it's obsolete) */ num = nm_setting_ip4_config_get_num_addresses (s_ip4); - for (i = 0; i < 254; i++) { - char buf[INET_ADDRSTRLEN + 1]; + svSetValue (ifcfg, "IPADDR", NULL, FALSE); + svSetValue (ifcfg, "PREFIX", NULL, FALSE); + svSetValue (ifcfg, "NETMASK", NULL, FALSE); + svSetValue (ifcfg, "GATEWAY", NULL, FALSE); + for (i = 0; i < 256; i++) { + char buf[INET_ADDRSTRLEN]; NMIP4Address *addr; guint32 ip; - if (i == 0) { - addr_key = g_strdup ("IPADDR"); - prefix_key = g_strdup ("PREFIX"); - gw_key = g_strdup ("GATEWAY"); - } else { - addr_key = g_strdup_printf ("IPADDR%d", i + 1); - prefix_key = g_strdup_printf ("PREFIX%d", i + 1); - gw_key = g_strdup_printf ("GATEWAY%d", i + 1); - } + addr_key = g_strdup_printf ("IPADDR%d", i); + prefix_key = g_strdup_printf ("PREFIX%d", i); + netmask_key = g_strdup_printf ("NETMASK%d", i); + gw_key = g_strdup_printf ("GATEWAY%d", i); if (i >= num) { svSetValue (ifcfg, addr_key, NULL, FALSE); svSetValue (ifcfg, prefix_key, NULL, FALSE); + svSetValue (ifcfg, netmask_key, NULL, FALSE); svSetValue (ifcfg, gw_key, NULL, FALSE); } else { addr = nm_setting_ip4_config_get_address (s_ip4, i); @@ -1189,6 +1238,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_free (addr_key); g_free (prefix_key); + g_free (netmask_key); g_free (gw_key); } diff --git a/src/settings/plugins/ifcfg-suse/Makefile.in b/src/settings/plugins/ifcfg-suse/Makefile.in index 2a8a1639..02e2247a 100644 --- a/src/settings/plugins/ifcfg-suse/Makefile.in +++ b/src/settings/plugins/ifcfg-suse/Makefile.in @@ -139,6 +139,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -256,6 +260,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -277,6 +283,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in index 793258f7..2bc7bc32 100644 --- a/src/settings/plugins/ifnet/Makefile.in +++ b/src/settings/plugins/ifnet/Makefile.in @@ -187,6 +187,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -304,6 +308,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -325,6 +331,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in index adb1816c..17b80c36 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ b/src/settings/plugins/ifnet/tests/Makefile.in @@ -110,6 +110,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -227,6 +231,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -248,6 +254,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in index af545df7..5f5a456b 100644 --- a/src/settings/plugins/ifupdown/Makefile.in +++ b/src/settings/plugins/ifupdown/Makefile.in @@ -186,6 +186,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -303,6 +307,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -324,6 +330,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in index 8bd83a15..7412e65d 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ b/src/settings/plugins/ifupdown/tests/Makefile.in @@ -110,6 +110,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -227,6 +231,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -248,6 +254,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/keyfile/Makefile.in b/src/settings/plugins/keyfile/Makefile.in index 409499d7..a2a7d231 100644 --- a/src/settings/plugins/keyfile/Makefile.in +++ b/src/settings/plugins/keyfile/Makefile.in @@ -162,6 +162,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -279,6 +283,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -300,6 +306,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in index 733b4916..05ed3a61 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ b/src/settings/plugins/keyfile/tests/Makefile.in @@ -148,6 +148,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -265,6 +269,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -286,6 +292,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in index 0b0b3551..2c3c1630 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in @@ -76,6 +76,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -193,6 +197,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -214,6 +220,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/src/settings/tests/Makefile.in b/src/settings/tests/Makefile.in index 70e6b17e..33c4bd38 100644 --- a/src/settings/tests/Makefile.in +++ b/src/settings/tests/Makefile.in @@ -112,6 +112,10 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ @@ -229,6 +233,8 @@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ RESOLVCONF_PATH = @RESOLVCONF_PATH@ SED = @SED@ @@ -250,6 +256,7 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ |