diff options
author | Thomas Haller <thaller@redhat.com> | 2023-03-14 09:00:14 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-03-27 11:22:46 +0200 |
commit | 9ccb4a83ecc7344c1a933dd86b3e24c6785be0ce (patch) | |
tree | ff7b33fa44321aea273dbefc31baa569c60906fa | |
parent | 8ecd5a675a3ff16e54adc2a8117f620a5ed56488 (diff) |
libnm: normalize "connection.read-only" to FALSE
-rw-r--r-- | src/libnm-core-impl/nm-connection.c | 15 | ||||
-rw-r--r-- | src/libnm-core-impl/nm-setting-connection.c | 12 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index 8b4144addb..f0583e6746 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -883,6 +883,20 @@ _normalize_connection_uuid(NMConnection *self) return TRUE; } +static gboolean +_normalize_connection(NMConnection *self) +{ + NMSettingConnection *s_con = nm_connection_get_setting_connection(self); + gboolean changed = FALSE; + + if (nm_setting_connection_get_read_only(s_con)) { + g_object_set(s_con, NM_SETTING_CONNECTION_READ_ONLY, FALSE, NULL); + changed = TRUE; + } + + return changed; +} + gboolean _nm_setting_connection_verify_secondaries(GArray *secondaries, GError **error) { @@ -2005,6 +2019,7 @@ _connection_normalize(NMConnection *connection, was_modified |= _normalize_connection_type(connection); was_modified |= _normalize_connection_slave_type(connection); was_modified |= _normalize_connection_secondaries(connection); + was_modified |= _normalize_connection(connection); was_modified |= _normalize_required_settings(connection); was_modified |= _normalize_invalid_slave_port_settings(connection); was_modified |= _normalize_ip_config(connection, parameters); diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c index db734a2ed0..fe373c2c09 100644 --- a/src/libnm-core-impl/nm-setting-connection.c +++ b/src/libnm-core-impl/nm-setting-connection.c @@ -1610,6 +1610,18 @@ after_interface_name: if (!_nm_setting_connection_verify_secondaries(priv->secondaries.arr, error)) return NM_SETTING_VERIFY_NORMALIZABLE; + if (priv->read_only) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("read-only is deprecated and not settable for the user")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_READ_ONLY); + return NM_SETTING_VERIFY_NORMALIZABLE; + } + return TRUE; } |