mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 15:50:07 +01:00
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>
This commit is contained in:
parent
66d88dc00f
commit
4f8b45e802
2 changed files with 18 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue