mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-18 14:20:42 +02:00
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>
This commit is contained in:
parent
dfba4ce1e1
commit
651daee516
2 changed files with 23 additions and 40 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue