mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 17:10:12 +01:00
settings: unify settings-update API (rename and merge)
This commit is contained in:
parent
9a4225ac96
commit
776c5f3893
13 changed files with 97 additions and 123 deletions
|
|
@ -254,12 +254,12 @@ activate:
|
|||
if (need_update) {
|
||||
_LOGD ("rollback: updating connection %s",
|
||||
nm_settings_connection_get_uuid (connection));
|
||||
nm_settings_connection_commit_changes (connection,
|
||||
dev_checkpoint->settings_connection,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"checkpoint-rollback",
|
||||
NULL);
|
||||
nm_settings_connection_update (connection,
|
||||
dev_checkpoint->settings_connection,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"checkpoint-rollback",
|
||||
NULL);
|
||||
}
|
||||
} else {
|
||||
/* The connection was deleted, recreate it */
|
||||
|
|
|
|||
|
|
@ -4022,12 +4022,12 @@ activation_add_done (NMSettings *settings,
|
|||
nm_active_connection_set_settings_connection (active, new_connection);
|
||||
|
||||
if (_internal_activate_generic (self, active, &local)) {
|
||||
nm_settings_connection_commit_changes (new_connection,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED,
|
||||
"add-and-activate",
|
||||
NULL);
|
||||
nm_settings_connection_update (new_connection,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED,
|
||||
"add-and-activate",
|
||||
NULL);
|
||||
g_dbus_method_invocation_return_value (
|
||||
context,
|
||||
g_variant_new ("(oo)",
|
||||
|
|
|
|||
|
|
@ -694,31 +694,12 @@ out:
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_settings_connection_commit_changes (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
{
|
||||
return _update (self,
|
||||
new_connection,
|
||||
persist_mode,
|
||||
commit_reason,
|
||||
log_diff_name,
|
||||
error);
|
||||
}
|
||||
|
||||
/* Update the settings of this connection to match that of 'new_connection',
|
||||
* taking care to make a private copy of secrets.
|
||||
*/
|
||||
gboolean
|
||||
nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
nm_settings_connection_update (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error)
|
||||
{
|
||||
return _update (self,
|
||||
new_connection,
|
||||
|
|
@ -1002,12 +983,12 @@ nm_settings_connection_new_secrets (NMSettingsConnection *self,
|
|||
update_system_secrets_cache (self);
|
||||
update_agent_secrets_cache (self, NULL);
|
||||
|
||||
nm_settings_connection_commit_changes (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"new-secrets",
|
||||
NULL);
|
||||
nm_settings_connection_update (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"new-secrets",
|
||||
NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1121,12 +1102,12 @@ get_secrets_done_cb (NMAgentManager *manager,
|
|||
setting_name,
|
||||
call_id);
|
||||
|
||||
nm_settings_connection_commit_changes (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"get-new-secrets",
|
||||
NULL);
|
||||
nm_settings_connection_update (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"get-new-secrets",
|
||||
NULL);
|
||||
} else {
|
||||
_LOGD ("(%s:%p) new agent secrets processed",
|
||||
setting_name,
|
||||
|
|
@ -2143,12 +2124,12 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
|
|||
nm_connection_get_path (NM_CONNECTION (self)),
|
||||
NM_CONNECTION (self));
|
||||
|
||||
nm_settings_connection_commit_changes (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"clear-secrets",
|
||||
&local);
|
||||
nm_settings_connection_update (self,
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"clear-secrets",
|
||||
&local);
|
||||
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self,
|
||||
!local, NULL, subject, local ? local->message : NULL);
|
||||
|
|
|
|||
|
|
@ -137,19 +137,12 @@ typedef enum {
|
|||
NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY,
|
||||
} NMSettingsConnectionPersistMode;
|
||||
|
||||
gboolean nm_settings_connection_commit_changes (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error);
|
||||
gboolean nm_settings_connection_update (NMSettingsConnection *self,
|
||||
NMConnection *new_connection,
|
||||
NMSettingsConnectionPersistMode persist_mode,
|
||||
NMSettingsConnectionCommitReason commit_reason,
|
||||
const char *log_diff_name,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_settings_connection_delete (NMSettingsConnection *self,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ EXPORT(nm_inotify_helper_add_watch)
|
|||
EXPORT(nm_inotify_helper_remove_watch)
|
||||
|
||||
EXPORT(nm_settings_connection_get_type)
|
||||
EXPORT(nm_settings_connection_replace_settings)
|
||||
EXPORT(nm_settings_connection_update)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ nms_ibft_connection_new (const GPtrArray *block, GError **error)
|
|||
|
||||
object = g_object_new (NMS_TYPE_IBFT_CONNECTION, NULL);
|
||||
/* Update settings with what was read from iscsiadm */
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
source,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error))
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
|
||||
source,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error))
|
||||
g_clear_object (&object);
|
||||
|
||||
return (NMSIbftConnection *) object;
|
||||
|
|
|
|||
|
|
@ -458,14 +458,14 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||
NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec,
|
||||
NULL);
|
||||
/* Update our settings with what was read from the file */
|
||||
if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
full_path
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error))
|
||||
if (nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
full_path
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error))
|
||||
nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object));
|
||||
else
|
||||
g_clear_object (&object);
|
||||
|
|
|
|||
|
|
@ -313,12 +313,12 @@ update_connection (SettingsPluginIfcfg *self,
|
|||
NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, new_unrecognized,
|
||||
NULL);
|
||||
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid),
|
||||
NM_CONNECTION (connection_new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifcfg-update",
|
||||
&local)) {
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
|
||||
NM_CONNECTION (connection_new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifcfg-update",
|
||||
&local)) {
|
||||
/* Shouldn't ever get here as 'connection_new' was verified by the reader already
|
||||
* and the UUID did not change. */
|
||||
g_assert_not_reached ();
|
||||
|
|
|
|||
|
|
@ -186,14 +186,14 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
|
|||
object = (GObject *) g_object_new (NM_TYPE_IFNET_CONNECTION, NULL);
|
||||
|
||||
NM_IFNET_CONNECTION_GET_PRIVATE ((NMIfnetConnection *) object)->conn_name = g_strdup (conn_name);
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
update_unsaved
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
NULL)) {
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
update_unsaved
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
NULL)) {
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,12 +269,12 @@ reload_connections (NMSettingsPlugin *config)
|
|||
}
|
||||
} else {
|
||||
/* Update existing connection with new settings */
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old),
|
||||
NM_CONNECTION (new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifnet-update",
|
||||
&error)) {
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (old),
|
||||
NM_CONNECTION (new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifnet-update",
|
||||
&error)) {
|
||||
/* Shouldn't ever get here as 'new' was verified by the reader already
|
||||
* and the UUID did not change. */
|
||||
g_assert_not_reached ();
|
||||
|
|
|
|||
|
|
@ -139,12 +139,12 @@ bind_device_to_connection (SettingsPluginIfupdown *self,
|
|||
g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL);
|
||||
}
|
||||
|
||||
nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported),
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifupdown-new",
|
||||
NULL);
|
||||
nm_settings_connection_update (NM_SETTINGS_CONNECTION (exported),
|
||||
NULL,
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"ifupdown-new",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -159,14 +159,14 @@ nms_keyfile_connection_new (NMConnection *source,
|
|||
NULL);
|
||||
|
||||
/* Update our settings with what was read from the file */
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
update_unsaved
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error)) {
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
update_unsaved
|
||||
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
|
||||
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
NULL,
|
||||
error)) {
|
||||
g_object_unref (object);
|
||||
object = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,12 +258,12 @@ update_connection (NMSKeyfilePlugin *self,
|
|||
else
|
||||
_LOGI ("update and persist "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new));
|
||||
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid),
|
||||
NM_CONNECTION (connection_new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"keyfile-update",
|
||||
&local)) {
|
||||
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
|
||||
NM_CONNECTION (connection_new),
|
||||
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
|
||||
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
|
||||
"keyfile-update",
|
||||
&local)) {
|
||||
/* Shouldn't ever get here as 'connection_new' was verified by the reader already
|
||||
* and the UUID did not change. */
|
||||
g_assert_not_reached ();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue