diff options
author | Thomas Haller <thaller@redhat.com> | 2014-07-03 19:49:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-07-27 23:57:36 +0200 |
commit | 8231ed44b4da2bfdf6b261f160beaa11b1ef3a36 (patch) | |
tree | 0104bb360e4764dafc15db842822cd3d2a633346 | |
parent | 2c460ba03f46e71fced2cc80407a8888b197cea1 (diff) | |
download | NetworkManager-8231ed44b4da2bfdf6b261f160beaa11b1ef3a36.tar.gz |
libnm-util: 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-util/nm-connection.c | 32 | ||||
-rw-r--r-- | libnm-util/nm-setting-connection.c | 31 |
2 files changed, 23 insertions, 40 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index bfdd8836a5..c3ee3c00fd 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -736,8 +736,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; @@ -809,36 +807,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-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index f206bbb032..1111c3c071 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -854,14 +854,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 |