summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-13 02:38:09 +0200
committerThomas Haller <thaller@redhat.com>2014-08-22 15:24:31 +0200
commit4f8b45e802e49f5fe88ca99e2f5fe72e85287893 (patch)
tree8c91c95c748349c7e6576b8f81c4604dac3f6a9d
parent66d88dc00fe710790e2e41dc201f97ca542a1244 (diff)
libnm-core: allow nm_setting_verify() to succeed individually without @all_settings
When calling nm_setting_verify() without providing any settings in @all_settings, we assume that the setting on its own might be valid. Only when checked together with all settings, we want to consider the setting in the full context. nm_connection_verify() ensures to pass on a list of settings. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-core/nm-setting-vlan.c3
-rw-r--r--libnm-core/nm-setting.c16
2 files changed, 18 insertions, 1 deletions
diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c
index 0cb1374719..22fb2d7403 100644
--- a/libnm-core/nm-setting-vlan.c
+++ b/libnm-core/nm-setting-vlan.c
@@ -566,7 +566,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
/* If parent is NULL, the parent must be specified via
* NMSettingWired:mac-address.
*/
- if (!s_wired || !nm_setting_wired_get_mac_address (s_wired)) {
+ if ( all_settings
+ && (!s_wired || !nm_setting_wired_get_mac_address (s_wired))) {
g_set_error (error,
NM_SETTING_VLAN_ERROR,
NM_SETTING_VLAN_ERROR_MISSING_PROPERTY,
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 61cbdc3ede..e6305f6ecb 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -1413,6 +1413,22 @@ _nm_setting_verify_deprecated_virtual_iface_name (const char *interface_name,
NMSettingConnection *s_con;
const char *con_name;
+ if (!all_settings) {
+ /* nm_setting_verify() was called without passing on any other settings.
+ * Perform a relaxed verification, the setting might be valid when checked
+ * together with a NMSettingConnection as part of a NMConnection. */
+ if (interface_name && !nm_utils_iface_valid_name (interface_name)) {
+ /* Only if the interace name is invalid, there is an normalizable warning */
+ g_set_error_literal (error,
+ error_quark,
+ e_invalid_property,
+ _("property is invalid"));
+ g_prefix_error (error, "%s.%s: ", setting_name, setting_property);
+ return NM_SETTING_VERIFY_NORMALIZABLE;
+ }
+ return NM_SETTING_VERIFY_SUCCESS;
+ }
+
s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME));
con_name = s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
if (!interface_name && !con_name) {