diff options
author | Thomas Haller <thaller@redhat.com> | 2014-07-03 19:49:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-08-22 15:24:30 +0200 |
commit | 651daee516443b2523be63046fe0b6f439770659 (patch) | |
tree | 0f90863b0450e7e654181a3983db18e763030ea5 | |
parent | dfba4ce1e1c5bd0c1ae798bc538b5fab3e3faded (diff) | |
download | NetworkManager-651daee516443b2523be63046fe0b6f439770659.tar.gz |
libnm-core: move validation of NMSettingConnection:type to NMSettingConnection:verify()
Partly it was already there. This makes NMSettingConnection:verify() stricter
then before, but validates the same as of NMConnection:_nm_connection_verify().
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | libnm-core/nm-connection.c | 32 | ||||
-rw-r--r-- | libnm-core/nm-setting-connection.c | 31 |
2 files changed, 23 insertions, 40 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index ea90329971..549dc6527d 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -677,8 +677,6 @@ _nm_connection_verify (NMConnection *connection, GError **error) gpointer value; GSList *all_settings = NULL, *setting_i; NMSettingVerifyResult success = NM_SETTING_VERIFY_ERROR; - NMSetting *base; - const char *ctype; GError *normalizable_error = NULL; NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS; @@ -750,36 +748,6 @@ _nm_connection_verify (NMConnection *connection, GError **error) } g_slist_free (all_settings); - /* Now make sure the given 'type' setting can actually be the base setting - * of the connection. Can't have type=ppp for example. - */ - ctype = nm_setting_connection_get_connection_type (s_con); - if (!ctype) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, - "connection type missing"); - goto EXIT; - } - - base = nm_connection_get_setting_by_name (connection, ctype); - if (!base) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, - "base setting GType not found"); - goto EXIT; - } - - if (!_nm_setting_is_base_type (base)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, - "connection type '%s' is not a base type", - ctype); - goto EXIT; - } - s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip6 = nm_connection_get_setting_ip6_config (connection); diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 2205bff199..c359298250 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -837,14 +837,29 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } /* Make sure the corresponding 'type' item is present */ - if (all_settings && !nm_setting_find_in_list (all_settings, priv->type)) { - g_set_error (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, - _("requires presence of '%s' setting in the connection"), - priv->type); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); - return FALSE; + if (all_settings) { + NMSetting *s_base; + + s_base = nm_setting_find_in_list (all_settings, priv->type); + if (!s_base) { + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND, + _("requires presence of '%s' setting in the connection"), + priv->type); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); + return FALSE; + } + + if (!_nm_setting_is_base_type (s_base)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, + _("connection type '%s' is not a base type"), + priv->type); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); + return FALSE; + } } is_slave = ( priv->slave_type |