diff options
| author | Michael Biebl <biebl@debian.org> | 2015-11-24 00:06:32 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-11-24 00:06:32 +0100 |
| commit | a6ece1a2aa19a6268335c87d4fdef20123dd04a5 (patch) | |
| tree | 87f1961faacdfafb1c4fee5f2feb6bcb5c06813b /src/settings | |
| parent | 81836c2d44802b4cca833d7775dd627e0797a7e2 (diff) | |
Imported Upstream version 1.0.8 upstream/1.0.8
Diffstat (limited to 'src/settings')
40 files changed, 429 insertions, 87 deletions
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 8dcda06d..c694ad6f 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -421,6 +421,8 @@ struct _Request { */ GSList *asked; + NMAuthChain *chain; + guint32 idle_id; RequestAddAgentFunc add_agent_callback; @@ -475,6 +477,9 @@ request_free (Request *req) if (!req->completed && req->cancel_callback) req->cancel_callback (req); + if (req->chain) + nm_auth_chain_unref (req->chain); + g_object_unref (req->subject); g_free (req->detail); @@ -640,6 +645,13 @@ request_remove_agent (Request *req, NMSecretAgent *agent, GSList **pending_reqs) if (agent == req->current) { nm_log_dbg (LOGD_AGENTS, "(%s) current agent removed from secrets request %p/%s", nm_secret_agent_get_description (agent), req, req->detail); + + if (req->chain) { + /* This cancels the pending authorization requests. */ + nm_auth_chain_unref (req->chain); + req->chain = NULL; + } + *pending_reqs = g_slist_prepend (*pending_reqs, req); } else { nm_log_dbg (LOGD_AGENTS, "(%s) agent removed from secrets request %p/%s", @@ -675,8 +687,6 @@ typedef struct { gpointer other_data2; gpointer other_data3; - NMAuthChain *chain; - /* Whether the agent currently being asked for secrets * has the system.modify privilege. */ @@ -693,8 +703,6 @@ connection_request_free (gpointer data) g_strfreev (req->hints); if (req->existing_secrets) g_hash_table_unref (req->existing_secrets); - if (req->chain) - nm_auth_chain_unref (req->chain); } static gboolean @@ -816,6 +824,11 @@ get_done_cb (NMSecretAgent *agent, req_complete_error (parent, error); g_error_free (error); } else { + if (parent->current_call_id) { + /* Tell the failed agent we're no longer interested. */ + nm_secret_agent_cancel_secrets (parent->current, parent->current_call_id); + } + /* Try the next agent */ request_next_agent (parent); } @@ -941,7 +954,7 @@ get_agent_modify_auth_cb (NMAuthChain *chain, ConnectionRequest *req = user_data; const char *perm; - req->chain = NULL; + parent->chain = NULL; if (error) { nm_log_dbg (LOGD_AGENTS, "(%s) agent %p/%s/%s MODIFY check error: (%d) %s", @@ -1036,11 +1049,11 @@ get_next_cb (Request *parent) nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) request has system secrets; checking agent %s for MODIFY", req, parent->detail, req->setting_name, agent_dbus_owner); - req->chain = nm_auth_chain_new_subject (nm_secret_agent_get_subject (parent->current), - NULL, - get_agent_modify_auth_cb, - req); - g_assert (req->chain); + parent->chain = nm_auth_chain_new_subject (nm_secret_agent_get_subject (parent->current), + NULL, + get_agent_modify_auth_cb, + req); + g_assert (parent->chain); /* If the caller is the only user in the connection's permissions, then * we use the 'modify.own' permission instead of 'modify.system'. If the @@ -1052,9 +1065,9 @@ get_next_cb (Request *parent) perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN; else perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM; - nm_auth_chain_set_data (req->chain, "perm", (gpointer) perm, NULL); + nm_auth_chain_set_data (parent->chain, "perm", (gpointer) perm, NULL); - nm_auth_chain_add_call (req->chain, perm, TRUE); + nm_auth_chain_add_call (parent->chain, perm, TRUE); } else { nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) requesting user-owned secrets from agent %s", req, parent->detail, req->setting_name, agent_dbus_owner); diff --git a/src/settings/plugins/Makefile.in b/src/settings/plugins/Makefile.in index d7b7ab14..c706214b 100644 --- a/src/settings/plugins/Makefile.in +++ b/src/settings/plugins/Makefile.in @@ -318,6 +318,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am index b98f66ef..7ce8eaea 100644 --- a/src/settings/plugins/example/Makefile.am +++ b/src/settings/plugins/example/Makefile.am @@ -2,6 +2,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ diff --git a/src/settings/plugins/example/Makefile.in b/src/settings/plugins/example/Makefile.in index 3b7a1551..5f16d186 100644 --- a/src/settings/plugins/example/Makefile.in +++ b/src/settings/plugins/example/Makefile.in @@ -309,6 +309,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -453,6 +454,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am index 00a5d175..6bc9d05d 100644 --- a/src/settings/plugins/ibft/Makefile.am +++ b/src/settings/plugins/ibft/Makefile.am @@ -15,6 +15,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DNETWORKMANAGER_COMPILATION \ diff --git a/src/settings/plugins/ibft/Makefile.in b/src/settings/plugins/ibft/Makefile.in index de9be286..1f5b8eb4 100644 --- a/src/settings/plugins/ibft/Makefile.in +++ b/src/settings/plugins/ibft/Makefile.in @@ -384,6 +384,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -536,6 +537,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DNETWORKMANAGER_COMPILATION \ diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am index 3c7c94ac..9901119e 100644 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ b/src/settings/plugins/ibft/tests/Makefile.am @@ -6,6 +6,7 @@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ diff --git a/src/settings/plugins/ibft/tests/Makefile.in b/src/settings/plugins/ibft/tests/Makefile.in index 266497b6..30bd78df 100644 --- a/src/settings/plugins/ibft/tests/Makefile.in +++ b/src/settings/plugins/ibft/tests/Makefile.in @@ -512,6 +512,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -656,6 +657,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am index 4989f4ba..08ffa0ec 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/Makefile.am @@ -28,6 +28,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DNETWORKMANAGER_COMPILATION \ diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in index 0cd26960..eaa456bb 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/Makefile.in @@ -387,6 +387,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -549,6 +550,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DNETWORKMANAGER_COMPILATION \ diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 72123e66..271b7bb1 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -346,7 +346,6 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx) /* Returns TRUE on missing address or valid address */ static gboolean read_full_ip4_address (shvarFile *ifcfg, - const char *network_file, gint32 which, NMIPAddress *base_addr, NMIPAddress **out_address, @@ -362,7 +361,6 @@ read_full_ip4_address (shvarFile *ifcfg, g_return_val_if_fail (which >= -1, FALSE); g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (network_file != NULL, FALSE); g_return_val_if_fail (out_address != NULL, FALSE); g_return_val_if_fail (*out_address == NULL, FALSE); if (error) @@ -452,7 +450,6 @@ done: /* Returns TRUE on missing route or valid route */ static gboolean read_one_ip4_route (shvarFile *ifcfg, - const char *network_file, guint32 which, NMIPRoute **out_route, GError **error) @@ -463,7 +460,6 @@ read_one_ip4_route (shvarFile *ifcfg, gboolean success = FALSE; g_return_val_if_fail (ifcfg != NULL, FALSE); - g_return_val_if_fail (network_file != NULL, FALSE); g_return_val_if_fail (out_route != NULL, FALSE); g_return_val_if_fail (*out_route == NULL, FALSE); if (error) @@ -684,7 +680,6 @@ error: static gboolean parse_full_ip6_address (shvarFile *ifcfg, - const char *network_file, const char *addr_str, int i, NMIPAddress **out_address, @@ -942,7 +937,10 @@ make_ip4_setting (shvarFile *ifcfg, } else if (!g_ascii_strcasecmp (value, "bootp") || !g_ascii_strcasecmp (value, "dhcp")) { method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; } else if (!g_ascii_strcasecmp (value, "static")) { - method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + if (is_any_ip4_address_defined (ifcfg, NULL)) + method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + else + method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; } else if (!g_ascii_strcasecmp (value, "autoip")) { g_free (value); g_object_set (s_ip4, @@ -962,7 +960,7 @@ make_ip4_setting (shvarFile *ifcfg, if (is_any_ip4_address_defined (ifcfg, &idx)) { NMIPAddress *addr = NULL; - if (!read_full_ip4_address (ifcfg, network_file, idx, NULL, &addr, NULL, error)) + if (!read_full_ip4_address (ifcfg, idx, NULL, &addr, NULL, error)) goto done; if (!read_ip4_address (ifcfg, "GATEWAY", &gateway, error)) goto done; @@ -1020,7 +1018,7 @@ make_ip4_setting (shvarFile *ifcfg, /* gateway will only be set if still unset. Hence, we don't leak gateway * here by calling read_full_ip4_address() repeatedly */ - if (!read_full_ip4_address (ifcfg, network_file, i, NULL, &addr, &gateway, error)) + if (!read_full_ip4_address (ifcfg, i, NULL, &addr, &gateway, error)) goto done; if (!addr) { @@ -1046,6 +1044,13 @@ make_ip4_setting (shvarFile *ifcfg, svCloseFile (network_ifcfg); if (!read_success) goto done; + + if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) { + gs_free char *f = g_path_get_basename (ifcfg->fileName); + PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s " + "because the connection has no static addresses", f); + g_clear_pointer (&gateway, g_free); + } } } g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway, NULL); @@ -1108,7 +1113,7 @@ make_ip4_setting (shvarFile *ifcfg, for (i = 0; i < 256; i++) { NMIPRoute *route = NULL; - if (!read_one_ip4_route (route_ifcfg, network_file, i, &route, error)) { + if (!read_one_ip4_route (route_ifcfg, i, &route, error)) { svCloseFile (route_ifcfg); goto done; } @@ -1158,7 +1163,7 @@ done: } static void -read_aliases (NMSettingIPConfig *s_ip4, const char *filename, const char *network_file) +read_aliases (NMSettingIPConfig *s_ip4, const char *filename) { GDir *dir; char *dirname, *base; @@ -1230,7 +1235,7 @@ read_aliases (NMSettingIPConfig *s_ip4, const char *filename, const char *networ } addr = NULL; - ok = read_full_ip4_address (parsed, network_file, -1, base_addr, &addr, NULL, &err); + ok = read_full_ip4_address (parsed, -1, base_addr, &addr, NULL, &err); svCloseFile (parsed); if (ok) { nm_ip_address_set_attribute (addr, "label", g_variant_new_string (device)); @@ -1417,7 +1422,7 @@ make_ip6_setting (shvarFile *ifcfg, for (iter = list, i = 0; iter && *iter; iter++, i++) { NMIPAddress *addr = NULL; - if (!parse_full_ip6_address (ifcfg, network_file, *iter, i, &addr, error)) { + if (!parse_full_ip6_address (ifcfg, *iter, i, &addr, error)) { g_strfreev (list); goto error; } @@ -3502,21 +3507,46 @@ wireless_connection_from_ifcfg (const char *file, } static void -parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value) +parse_ethtool_option (const char *value, NMSettingWiredWakeOnLan *out_flags, char **out_password) { - NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - gboolean use_password = FALSE; - char **words, **iter, *flag; + gs_strfreev char **words = NULL; + const char **iter = NULL, *flag; if (!value || !value[0]) return; - words = g_strsplit_set (value, " ", 0); - iter = words; + words = g_strsplit_set (value, "\t ", 0); + iter = (const char **) words; while (iter[0]) { - if (g_str_equal (iter[0], "wol") && iter[1] && *iter[1]) { - for (flag = iter[1]; *flag; flag++) { + gboolean is_wol; + + if (g_str_equal (iter[0], "wol")) + is_wol = TRUE; + else if (g_str_equal (iter[0], "sopass")) + is_wol = FALSE; + else { + /* Silently skip unknown options */ + iter++; + continue; + } + + iter++; + + /* g_strsplit_set() returns empty tokens, meaning that we must skip over repeated + * space characters like to parse "wol d". */ + while (iter[0] && !*iter[0]) + iter++; + + if (is_wol) { + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; + + if (!iter[0]) { + PARSE_WARNING ("Wake-on-LAN options missing"); + break; + } + + for (flag = iter[0]; *flag; flag++) { switch (*flag) { case 'p': wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY; @@ -3537,42 +3567,62 @@ parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, char *value) wol_flags |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; break; case 's': - use_password = TRUE; break; case 'd': wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_NONE; - use_password = FALSE; break; default: PARSE_WARNING ("unrecognized Wake-on-LAN option '%c'", *flag); } } - if (!NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) - use_password = FALSE; + *out_flags = wol_flags; + } else { + if (!iter[0]) { + PARSE_WARNING ("Wake-on-LAN password missing"); + break; + } - g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, NULL); - iter += 2; - continue; + g_clear_pointer (out_password, g_free); + if (nm_utils_hwaddr_valid (iter[0], ETH_ALEN)) + *out_password = g_strdup (iter[0]); + else + PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[0]); } + iter++; + } +} - if (g_str_equal (iter[0], "sopass") && iter[1] && *iter[1]) { - if (use_password) { - if (nm_utils_hwaddr_valid (iter[1], ETH_ALEN)) - g_object_set (s_wired, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, iter[1], NULL); - else - PARSE_WARNING ("Wake-on-LAN password '%s' is invalid", iter[1]); - } else - PARSE_WARNING ("Wake-on-LAN password not expected"); - iter += 2; - continue; - } +static void +parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *value) +{ + NMSettingWiredWakeOnLan wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; + gs_free char *wol_password = NULL; + gboolean ignore_wol_password = FALSE; - /* Silently skip unknown options */ - iter++; + if (value) { + gs_strfreev char **opts = NULL; + const char **iter; + + wol_flags = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE; + + opts = g_strsplit_set (value, ";", 0); + for (iter = (const char **) opts; iter[0]; iter++) { + /* in case of repeated wol_passwords, parse_ethtool_option() + * will do the right thing and clear wol_password before resetting. */ + parse_ethtool_option (iter[0], &wol_flags, &wol_password); + } } - g_strfreev (words); + if ( wol_password + && !NM_FLAGS_HAS (wol_flags, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { + PARSE_WARNING ("Wake-on-LAN password not expected"); + ignore_wol_password = TRUE; + } + g_object_set (s_wired, + NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password, + NULL); } static NMSetting * @@ -3710,7 +3760,7 @@ make_wired_setting (shvarFile *ifcfg, g_free (value); } - value = svGetValue (ifcfg, "ETHTOOL_OPTS", FALSE); + value = svGetValueFull (ifcfg, "ETHTOOL_OPTS", FALSE); parse_ethtool_options (ifcfg, s_wired, value); g_free (value); @@ -4884,7 +4934,7 @@ connection_from_file_full (const char *filename, connection = NULL; goto done; } else { - read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename, network_file); + read_aliases (NM_SETTING_IP_CONFIG (s_ip4), filename); nm_connection_add_setting (connection, s_ip4); } diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 283aa826..5fd7755f 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -299,8 +299,8 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) return value; } -/* return TRUE if <key> resolves to any truth value (e.g. "yes", "y", "true") - * return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false") +/* return TRUE if <key> resolves to any truth value (e.g. "yes", "true", "y", "t", "1") + * return FALSE if <key> resolves to any non-truth value (e.g. "no", "false", "n", "f", "0") * return <default> otherwise */ gint @@ -316,12 +316,14 @@ svTrueValue (shvarFile *s, const char *key, gint def) if ( !g_ascii_strcasecmp ("yes", tmp) || !g_ascii_strcasecmp ("true", tmp) || !g_ascii_strcasecmp ("t", tmp) - || !g_ascii_strcasecmp ("y", tmp)) + || !g_ascii_strcasecmp ("y", tmp) + || !g_ascii_strcasecmp ("1", tmp)) returnValue = TRUE; else if ( !g_ascii_strcasecmp ("no", tmp) || !g_ascii_strcasecmp ("false", tmp) || !g_ascii_strcasecmp ("f", tmp) - || !g_ascii_strcasecmp ("n", tmp)) + || !g_ascii_strcasecmp ("n", tmp) + || !g_ascii_strcasecmp ("0", tmp)) returnValue = FALSE; g_free (tmp); diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am index a3f6a052..73f3b5d8 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am @@ -8,6 +8,7 @@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in index d0832e47..da25c8b9 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in @@ -566,6 +566,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -711,6 +712,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ 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 7b5aaf17..c3fde548 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -14,6 +14,8 @@ EXTRA_DIST = \ ifcfg-test-wired-dhcp6-only \ ifcfg-test-wired-global-gateway \ network-test-wired-global-gateway \ + ifcfg-test-wired-global-gateway-ignore \ + network-test-wired-global-gateway-ignore \ ifcfg-test-wired-obsolete-gateway-n \ ifcfg-test-wired-never-default \ network-test-wired-never-default \ @@ -99,6 +101,7 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-vlanid \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ + ifcfg-test-vlan-reorder-hdr-1 \ ifcfg-test-wifi-wep-no-keys \ ifcfg-test-permissions \ ifcfg-test-wifi-wep-agent-keys \ @@ -124,7 +127,8 @@ EXTRA_DIST = \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-wired-wake-on-lan + ifcfg-test-wired-wake-on-lan \ + ifcfg-test-wired-ipv6-only-1 # make target dependencies can't have colons in their names, which ends up # meaning that we can't add the alias files to EXTRA_DIST 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 2435434d..4add27b7 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -253,6 +253,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -409,6 +410,8 @@ EXTRA_DIST = \ ifcfg-test-wired-dhcp6-only \ ifcfg-test-wired-global-gateway \ network-test-wired-global-gateway \ + ifcfg-test-wired-global-gateway-ignore \ + network-test-wired-global-gateway-ignore \ ifcfg-test-wired-obsolete-gateway-n \ ifcfg-test-wired-never-default \ network-test-wired-never-default \ @@ -494,6 +497,7 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-vlanid \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ + ifcfg-test-vlan-reorder-hdr-1 \ ifcfg-test-wifi-wep-no-keys \ ifcfg-test-permissions \ ifcfg-test-wifi-wep-agent-keys \ @@ -519,7 +523,8 @@ EXTRA_DIST = \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ ifcfg-test-vlan-trailing-spaces \ - ifcfg-test-wired-wake-on-lan + ifcfg-test-wired-wake-on-lan \ + ifcfg-test-wired-ipv6-only-1 # make target dependencies can't have colons in their names, which ends up diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-reorder-hdr-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-reorder-hdr-1 new file mode 100644 index 00000000..ca38f839 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-reorder-hdr-1 @@ -0,0 +1,7 @@ +VLAN=yes +TYPE=Vlan +DEVICE=vlan0.3 +PHYSDEV=eth0 +VLAN_ID=3 +REORDER_HDR=1 + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore new file mode 100644 index 00000000..bb81399e --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-global-gateway-ignore @@ -0,0 +1,8 @@ +TYPE=Ethernet +DEVICE=eth0 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +USERCTL=yes +IPV6INIT=no + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1 new file mode 100644 index 00000000..95f8a8ed --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-ipv6-only-1 @@ -0,0 +1,16 @@ +IPADDR= +GATEWAY= +NETMASK= +BOOTPROTO=static +TYPE=Ethernet +DEVICE=eth2 +HWADDR=00:11:22:33:44:ee +ONBOOT=yes +USERCTL=yes +NM_CONTROLLED=yes +PEERDNS=yes +DNS1=1:2:3:4::a +DOMAIN="lorem.com ipsum.org dolor.edu" +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR="1001:abba::1234/56" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore b/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore new file mode 100644 index 00000000..7987d105 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/network-test-wired-global-gateway-ignore @@ -0,0 +1 @@ +GATEWAY=192.168.1.2 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 f2f85d3c..cd2d0417 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -868,6 +868,48 @@ test_read_wired_global_gateway (void) g_object_unref (connection); } +/* Ignore GATEWAY from /etc/sysconfig/network for automatic connections */ +static void +test_read_wired_global_gateway_ignore (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + GError *error = NULL; + char *unmanaged = NULL; + + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection has no static addresses"); + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway-ignore", + TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway-ignore", + TYPE_ETHERNET, &unmanaged, &error); + nmtst_assert_connection_verifies_without_normalization (connection); + g_assert (unmanaged == NULL); + + /* ===== CONNECTION SETTING ===== */ + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System test-wired-global-gateway-ignore"); + + /* ===== WIRED SETTING ===== */ + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + /* ===== IPv4 SETTING ===== */ + s_ip4 = nm_connection_get_setting_ip4_config (connection); + g_assert (s_ip4); + g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); + + /* Addresses */ + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 0); + + /* Gateway */ + g_assert_cmpstr (nm_setting_ip_config_get_gateway (s_ip4), ==, NULL); + + g_object_unref (connection); +} + static void test_read_wired_obsolete_gateway_n (void) { @@ -1633,9 +1675,10 @@ test_read_wired_ipv6_manual (void) } #define TEST_IFCFG_WIRED_IPV6_ONLY TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-only" +#define TEST_IFCFG_WIRED_IPV6_ONLY_1 TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-only-1" static void -test_read_wired_ipv6_only (void) +test_read_wired_ipv6_only (const char *file, const char *expected_id) { NMConnection *connection; NMSettingConnection *s_con; @@ -1645,17 +1688,16 @@ test_read_wired_ipv6_only (void) char *unmanaged = NULL; GError *error = NULL; const char *tmp; - const char *expected_id = "System test-wired-ipv6-only"; NMIPAddress *ip6_addr; const char *method; - connection = connection_from_file_test (TEST_IFCFG_WIRED_IPV6_ONLY, + connection = connection_from_file_test (file, NULL, TYPE_ETHERNET, &unmanaged, &error); ASSERT (connection != NULL, - "wired-ipv6-only-read", "failed to read %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message); + "wired-ipv6-only-read", "failed to read %s: %s", file, error->message); ASSERT (nm_connection_verify (connection, &error), "wired-ipv6-only-verify", "failed to verify %s: %s", TEST_IFCFG_WIRED_IPV6_ONLY, error->message); @@ -6080,8 +6122,7 @@ test_write_wired_static (void) g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip4), ==, 204); g_assert_cmpint (nm_setting_ip_config_get_route_metric (reread_s_ip6), ==, 206); - ASSERT (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT) == TRUE, - "wired-static-write", "written and re-read connection weren't the same."); + nmtst_assert_connection_equals (connection, FALSE, reread, FALSE); route6file = utils_get_route6_path (testfile); unlink (route6file); @@ -10847,6 +10888,8 @@ test_read_vlan_only_vlan_id (void) g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 43); + /* Ensure that flags are 0 if both REORDER_HDR and VLAN_FLAGS are missing */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 0); g_object_unref (connection); } @@ -10906,6 +10949,33 @@ test_read_vlan_physdev (void) } static void +test_read_vlan_reorder_hdr_1 (void) +{ + NMConnection *connection; + GError *error = NULL; + NMSettingVlan *s_vlan; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-reorder-hdr-1", + NULL, TYPE_ETHERNET, NULL, + &error); + g_assert_no_error (error); + g_assert (connection); + g_assert (nm_connection_verify (connection, &error)); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan0.3"); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth0"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 3); + /* Check correct read of REORDER_HDR=1 */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 1); + + g_object_unref (connection); +} + +static void test_write_vlan (void) { NMConnection *connection; @@ -10981,6 +11051,77 @@ test_write_vlan_only_vlanid (void) } static void +test_write_vlan_reorder_hdr (void) +{ + NMConnection *connection, *reread; + NMSettingConnection *s_con; + NMSettingVlan *s_vlan; + NMSettingWired *s_wired; + char *uuid; + GError *error = NULL; + gboolean success; + char *testfile = NULL; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + 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 VLAN reorder_hdr", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_VLAN_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + /* VLAN setting */ + s_vlan = (NMSettingVlan *) nm_setting_vlan_new (); + nm_connection_add_setting (connection, NM_SETTING (s_vlan)); + + g_object_set (s_vlan, + NM_SETTING_VLAN_PARENT, "eth0", + NM_SETTING_VLAN_ID, 444, + NM_SETTING_VLAN_FLAGS, 1, + NULL); + + /* 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); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, + NULL, + TYPE_ETHERNET, + NULL, + &error); + unlink (testfile); + + g_assert_no_error (error); + g_assert (reread); + g_assert (nm_connection_verify (reread, &error)); + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_object_unref (connection); + g_object_unref (reread); + g_free (testfile); +} + +static void test_write_ethernet_missing_ipv6 (void) { NMConnection *connection; @@ -12604,12 +12745,13 @@ int main (int argc, char **argv) test_read_wired_static (TEST_IFCFG_WIRED_STATIC, "System test-wired-static", TRUE); test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE); test_read_wired_dhcp (); - g_test_add_func (TPATH "dhcp-plus-ip", test_read_wired_dhcp_plus_ip); - g_test_add_func (TPATH "shared-plus-ip", test_read_wired_shared_plus_ip); - g_test_add_func (TPATH "dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname); - g_test_add_func (TPATH "global-gateway", test_read_wired_global_gateway); - g_test_add_func (TPATH "obsolete-gateway-n", test_read_wired_obsolete_gateway_n); - g_test_add_func (TPATH "never-default", test_read_wired_never_default); + g_test_add_func (TPATH "read-dhcp-plus-ip", test_read_wired_dhcp_plus_ip); + g_test_add_func (TPATH "read-shared-plus-ip", test_read_wired_shared_plus_ip); + g_test_add_func (TPATH "read-dhcp-send-hostname", test_read_write_wired_dhcp_send_hostname); + g_test_add_func (TPATH "read-global-gateway", test_read_wired_global_gateway); + g_test_add_func (TPATH "read-global-gateway-ignore", test_read_wired_global_gateway_ignore); + g_test_add_func (TPATH "read-obsolete-gateway-n", test_read_wired_obsolete_gateway_n); + g_test_add_func (TPATH "read-never-default", test_read_wired_never_default); test_read_wired_defroute_no (); test_read_wired_defroute_no_gatewaydev_yes (); g_test_add_func (TPATH "routes/read-static", test_read_wired_static_routes); @@ -12619,7 +12761,8 @@ int main (int argc, char **argv) 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_ipv6_only (TEST_IFCFG_WIRED_IPV6_ONLY, "System test-wired-ipv6-only"); + test_read_wired_ipv6_only (TEST_IFCFG_WIRED_IPV6_ONLY_1, "System test-wired-ipv6-only-1"); test_read_wired_dhcp6_only (); test_read_onboot_no (); test_read_noip (); @@ -12672,6 +12815,7 @@ int main (int argc, char **argv) test_read_vlan_only_vlan_id (); test_read_vlan_only_device (); g_test_add_func (TPATH "vlan/physdev", test_read_vlan_physdev); + g_test_add_func (TPATH "vlan/reorder-hdr-1", test_read_vlan_reorder_hdr_1); g_test_add_func (TPATH "wired/read-wake-on-lan", test_read_wired_wake_on_lan); test_write_wired_static (); @@ -12679,7 +12823,7 @@ int main (int argc, char **argv) test_write_wired_static_routes (); test_read_write_static_routes_legacy (); test_write_wired_dhcp (); - g_test_add_func (TPATH "dhcp-plus-ip", test_write_wired_dhcp_plus_ip); + g_test_add_func (TPATH "wired/write-dhcp-plus-ip", test_write_wired_dhcp_plus_ip); test_write_wired_dhcp_8021x_peap_mschapv2 (); test_write_wired_8021x_tls (NM_SETTING_802_1X_CK_SCHEME_PATH, NM_SETTING_SECRET_FLAG_AGENT_OWNED); test_write_wired_8021x_tls (NM_SETTING_802_1X_CK_SCHEME_PATH, NM_SETTING_SECRET_FLAG_NOT_SAVED); @@ -12751,6 +12895,7 @@ int main (int argc, char **argv) test_write_infiniband (); test_write_vlan (); test_write_vlan_only_vlanid (); + g_test_add_func (TPATH "vlan/write-vlan-reorder-hdr", test_write_vlan_reorder_hdr); test_write_ethernet_missing_ipv6 (); /* iSCSI / ibft */ diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 69b7d64a..3640a104 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -714,15 +714,19 @@ write_wireless_security_setting (NMConnection *connection, ascii_key = g_strdup_printf ("s:%s", key); key = ascii_key; } - } else - key = NULL; - - set_secret (ifcfg, - tmp, - key, - "WEP_KEY_FLAGS", - nm_setting_wireless_security_get_wep_key_flags (s_wsec), - FALSE); + } else { + nm_log_warn (LOGD_SETTINGS, " invalid WEP key '%s'", key); + tmp = NULL; + } + + if (tmp) { + set_secret (ifcfg, + tmp, + key, + "WEP_KEY_FLAGS", + nm_setting_wireless_security_get_wep_key_flags (s_wsec), + FALSE); + } g_free (tmp); g_free (ascii_key); } @@ -1137,7 +1141,9 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) wol = nm_setting_wired_get_wake_on_lan (s_wired); wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired); - if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) + if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE) + svSetValueFull (ifcfg, "ETHTOOL_OPTS", "", FALSE); + else if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) svSetValue (ifcfg, "ETHTOOL_OPTS", NULL, FALSE); else { str = g_string_sized_new (30); @@ -1258,9 +1264,9 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, vlan_flags = nm_setting_vlan_get_flags (s_vlan); if (vlan_flags & NM_VLAN_FLAG_REORDER_HEADERS) - svSetValue (ifcfg, "REORDER_HDR", "1", FALSE); + svSetValue (ifcfg, "REORDER_HDR", "yes", FALSE); else - svSetValue (ifcfg, "REORDER_HDR", "0", FALSE); + svSetValue (ifcfg, "REORDER_HDR", "no", FALSE); svSetValue (ifcfg, "VLAN_FLAGS", NULL, FALSE); if (vlan_flags & NM_VLAN_FLAG_GVRP) { diff --git a/src/settings/plugins/ifcfg-suse/Makefile.am b/src/settings/plugins/ifcfg-suse/Makefile.am index 46204d7d..55494536 100644 --- a/src/settings/plugins/ifcfg-suse/Makefile.am +++ b/src/settings/plugins/ifcfg-suse/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = \ -I${top_srcdir}/src \ -I${top_srcdir}/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ diff --git a/src/settings/plugins/ifcfg-suse/Makefile.in b/src/settings/plugins/ifcfg-suse/Makefile.in index 3d7df19e..fa51b0aa 100644 --- a/src/settings/plugins/ifcfg-suse/Makefile.in +++ b/src/settings/plugins/ifcfg-suse/Makefile.in @@ -337,6 +337,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -482,6 +483,7 @@ AM_CPPFLAGS = \ -I${top_srcdir}/src \ -I${top_srcdir}/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index b0cfd9a1..84e2e697 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -7,6 +7,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in index 4832249a..589f1f22 100644 --- a/src/settings/plugins/ifnet/Makefile.in +++ b/src/settings/plugins/ifnet/Makefile.in @@ -385,6 +385,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -531,6 +532,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index 66409a54..754bb182 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -5,6 +5,7 @@ if ENABLE_TESTS AM_CPPFLAGS= \ -I$(srcdir)/../ \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in index b94a46fc..d331ecee 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ b/src/settings/plugins/ifnet/tests/Makefile.in @@ -313,6 +313,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -456,6 +457,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am index 0ca543e3..e1f2b339 100644 --- a/src/settings/plugins/ifupdown/Makefile.am +++ b/src/settings/plugins/ifupdown/Makefile.am @@ -6,6 +6,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in index 7cd1ef4e..3bd19afc 100644 --- a/src/settings/plugins/ifupdown/Makefile.in +++ b/src/settings/plugins/ifupdown/Makefile.in @@ -384,6 +384,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -529,6 +530,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.am b/src/settings/plugins/ifupdown/tests/Makefile.am index 2e927db9..4ae44a0b 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ b/src/settings/plugins/ifupdown/tests/Makefile.am @@ -2,6 +2,7 @@ if ENABLE_TESTS AM_CPPFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in index a1c029c3..2387a257 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ b/src/settings/plugins/ifupdown/tests/Makefile.in @@ -513,6 +513,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -655,6 +656,7 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am index 079c45c3..919b0805 100644 --- a/src/settings/plugins/keyfile/Makefile.am +++ b/src/settings/plugins/keyfile/Makefile.am @@ -6,6 +6,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ diff --git a/src/settings/plugins/keyfile/Makefile.in b/src/settings/plugins/keyfile/Makefile.in index c409d481..1514768b 100644 --- a/src/settings/plugins/keyfile/Makefile.in +++ b/src/settings/plugins/keyfile/Makefile.in @@ -353,6 +353,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -498,6 +499,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am index a79e20b5..cbe3f73b 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ b/src/settings/plugins/keyfile/tests/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS=keyfiles AM_CPPFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in index a65110f6..6dfaf110 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ b/src/settings/plugins/keyfile/tests/Makefile.in @@ -557,6 +557,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -700,6 +701,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@SUBDIRS = keyfiles @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am index 4ca4c3fa..be431067 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am @@ -28,6 +28,7 @@ KEYFILES = \ Test_minimal_slave_3 \ Test_minimal_slave_4 \ Test_Missing_Vlan_Setting \ + Test_Missing_Vlan_Flags \ Test_Missing_ID_UUID \ Test_Enum_Property \ Test_Flags_Property diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in index de7af82b..33d0e0c5 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in @@ -253,6 +253,7 @@ LOG_DRIVER = @LOG_DRIVER@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ @@ -423,6 +424,7 @@ KEYFILES = \ Test_minimal_slave_3 \ Test_minimal_slave_4 \ Test_Missing_Vlan_Setting \ + Test_Missing_Vlan_Flags \ Test_Missing_ID_UUID \ Test_Enum_Property \ Test_Flags_Property diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_Missing_Vlan_Flags b/src/settings/plugins/keyfile/tests/keyfiles/Test_Missing_Vlan_Flags new file mode 100644 index 00000000..330adda0 --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_Missing_Vlan_Flags @@ -0,0 +1,15 @@ +# VLAN setting with missing 'flags' key +# vlan.flags will be set to 0 (even if the default 'flags' property value is 1) + +[connection] +id=Test Missing Vlan Flags +uuid=803ebe47-8c31-401d-b47b-03fc0d34eb11 +type=vlan +autoconnect=true + +[802-3-ethernet] +mac-address=00:11:22:33:44:55 + +[vlan] +id=444 +parent=em1 diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 4fc44c7b..785ad4cb 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -3292,6 +3292,35 @@ test_read_missing_vlan_setting (void) s_vlan = nm_connection_get_setting_vlan (connection); g_assert (s_vlan); g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 0); + /* Ensure the VLAN flags are not set (0) */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 0); + + g_object_unref (connection); +} + +static void +test_read_missing_vlan_flags (void) +{ + NMConnection *connection; + NMSettingVlan *s_vlan; + GError *error = NULL; + gboolean success; + + connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error); + g_assert_no_error (error); + g_assert (connection); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Ensure the VLAN setting exists */ + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 444); + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "em1"); + /* Ensure the VLAN flags are not set (0) */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 0); g_object_unref (connection); } @@ -3688,6 +3717,7 @@ int main (int argc, char **argv) g_test_add_func ("/keyfile/test_write_new_wireless_group_names ", test_write_new_wireless_group_names); g_test_add_func ("/keyfile/test_read_missing_vlan_setting ", test_read_missing_vlan_setting); + g_test_add_func ("/keyfile/test_read_missing_vlan_flags ", test_read_missing_vlan_flags); g_test_add_func ("/keyfile/test_read_missing_id_uuid ", test_read_missing_id_uuid); g_test_add_func ("/keyfile/test_read_minimal", test_read_minimal); |