Commit d35d3c46 authored by Thomas Haller's avatar Thomas Haller

settings: rework tracking settings connections and settings plugins

Completely rework how settings plugin handle connections and how
NMSettings tracks the list of connections.

Previously, settings plugins would return objects of (a subtype of) type
NMSettingsConnection. The NMSettingsConnection was tightly coupled with
the settings plugin. That has a lot of downsides.

Change that. When changing this basic relation how settings connections
are tracked, everything falls appart. That's why this is a huge change.
Also, since I have to largely rewrite the settings plugins, I also
added support for multiple keyfile directories, handle in-memory
connections only by keyfile plugin and (partly) use copy-on-write NMConnection
instances. I don't want to spend effort rewriting large parts while
preserving the old way, that anyway should change. E.g. while rewriting ifcfg-rh,
I don't want to let it handle in-memory connections because that's not right


If the settings plugins themself create subtypes of NMSettingsConnection
instances, then a lot of knowledge about tracking connections moves
to the plugins.
Just try to follow the code what happend during nm_settings_add_connection().
Note how the logic is spread out:
 - nm_settings_add_connection() calls plugin's add_connection()
 - add_connection() creates a NMSettingsConnection subtype
 - the plugin has to know that it's called during add-connection and
 - NMSettings calls claim_connection() which hocks up the new
   NMSettingsConnection instance and configures the instance
   (like calling nm_settings_connection_added()).
This summary does not sound like a lot, but try to follow that code. The logic
is all over the place.

Instead, settings plugins should have a very simple API for adding, modifying,
deleting, loading and reloading connections. All the plugin does is to return a
NMSettingsStorage handle. The storage instance is a handle to identify a profile
in storage (e.g. a particular file). The settings plugin is free to subtype
NMSettingsStorage, but it's not necessary.
There are no more events raised, and the settings plugin implements the small
API in a straightforward manner.
NMSettings now drives all of this. Even NMSettingsConnection has now
very little concern about how it's tracked and delegates only to NMSettings.

This should make settings plugins simpler. Currently settings plugins
are so cumbersome to implement, that we avoid having them. It should not be
like that and it should be easy, beneficial and lightweight to create a new
settings plugin.

Note also how the settings plugins no longer care about duplicate UUIDs.
Duplicated UUIDs are a fact of life and NMSettings must handle them. No
need to overly concern settings plugins with that.


NMSettingsConnection is exposed directly on D-Bus (being a subtype of
NMDBusObject) but it was also a GObject type provided by the settings
plugin. Hence, it was not possible to migrate a profile from one plugin to
However that would be useful when one profile does not support a
connection type (like ifcfg-rh not supporting VPN). Currently such
migration is not implemented except for migrating them to/from keyfile's
run directory. The problem is that migrating profiles in general is
complicated but in some cases it is important to do.

For example checkpoint rollback should recreate the profile in the right
settings plugin, not just add it to persistent storage. This is not yet
properly implemented.


Previously, both keyfile and ifcfg-rh plugin implemented in-memory (unsaved)
profiles, while ifupdown plugin cannot handle them. That meant duplication of code
and a ifupdown profile could not be modified or made unsaved.
This is now unified and only keyfile plugin handles in-memory profiles (bgo #744711).
Also, NMSettings is aware of such profiles and treats them specially.
In particular, NMSettings drives the migration between persistent and non-persistent

Note that a settings plugins may create truly generated, in-memory profiles.
The settings plugin is free to generate and persist the profiles in any way it
wishes. But the concept of "unsaved" profiles is now something explicitly handled
by keyfile plugin. Also, these "unsaved" keyfile profiles are persisted to file system
too, to the /run directory. This is great for two reasons: first of all, all
profiles from keyfile storage in fact have a backing file -- even the
unsaved ones. It also means you can create "unsaved" profiles in /run
and load them with `nmcli connection load`, meaning there is a file
based API for creating unsaved profiles.
The other advantage is that these profiles now survive restarting
NetworkManager. It's paramount that restarting the daemon is as
non-disruptive as possible. Persisting unsaved files to /run improves
here significantly.


In the past, NMSettingsConnection also implemented NMConnection interface.
That was already changed a while ago and instead users call now
nm_settings_connection_get_connection() to delegate to a
NMSimpleConnection. What however still happened was that the NMConnection
instance gets never swapped but instead the instance was modified with
nm_connection_replace_settings_from_connection(), clear-secrets, etc.
Change that and treat the NMConnection instance immutable. Instead of modifying
it, reference/clone a new instance. This changes that previously when somebody
wanted to keep a reference to an NMConnection, then the profile would be cloned.
Now, it is supposed to be safe to reference the instance directly and everybody
must ensure not to modify the instance. nmtst_connection_assert_unchanging()
should help with that.
The point is that the settings plugins may keep references to the
NMConnection instance, and so does the NMSettingsConnection. We want
to avoid cloning the instances as long as they are the same.
Likewise, the device's applied connection can now also be referenced
instead of cloning it. This is not yet done, and possibly there are
further improvements possible.


Also implement multiple keyfile directores /usr/lib, /etc, /run (rh #1674545,
bgo #772414).

It was always the case that multiple files could provide the same UUID
(both in case of keyfile and ifcfg-rh). For keyfile plugin, if a profile in
read-only storage in /usr/lib gets modified, then it gets actually stored in
/etc (or /run, if the profile is unsaved).


While at it, make /etc/network/interfaces profiles for ifupdown plugin reloadable.

parent 0631129c
......@@ -2094,13 +2094,17 @@ src_libNetworkManager_la_SOURCES = \
src/settings/nm-secret-agent.h \
src/settings/nm-settings-connection.c \
src/settings/nm-settings-connection.h \
src/settings/nm-settings-storage.c \
src/settings/nm-settings-storage.h \
src/settings/nm-settings-plugin.c \
src/settings/nm-settings-plugin.h \
src/settings/nm-settings.c \
src/settings/nm-settings.h \
src/settings/nm-settings-utils.c \
src/settings/nm-settings-utils.h \
src/settings/plugins/keyfile/nms-keyfile-connection.c \
src/settings/plugins/keyfile/nms-keyfile-connection.h \
src/settings/plugins/keyfile/nms-keyfile-storage.c \
src/settings/plugins/keyfile/nms-keyfile-storage.h \
src/settings/plugins/keyfile/nms-keyfile-plugin.c \
src/settings/plugins/keyfile/nms-keyfile-plugin.h \
src/settings/plugins/keyfile/nms-keyfile-reader.c \
......@@ -2819,10 +2823,11 @@ $(src_settings_plugins_ifcfg_rh_libnms_ifcfg_rh_core_la_OBJECTS): $(libnm_core_l
src_settings_plugins_ifcfg_rh_libnm_settings_plugin_ifcfg_rh_la_SOURCES = \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.h \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.h \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c \
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.h \
src_settings_plugins_ifcfg_rh_libnm_settings_plugin_ifcfg_rh_la_CPPFLAGS = $(src_cppflags_base)
......@@ -3135,8 +3140,6 @@ src_settings_plugins_ifupdown_libnms_ifupdown_core_la_LIBADD = \
src_settings_plugins_ifupdown_libnm_settings_plugin_ifupdown_la_SOURCES = \
src/settings/plugins/ifupdown/nms-ifupdown-connection.c \
src/settings/plugins/ifupdown/nms-ifupdown-connection.h \
src/settings/plugins/ifupdown/nms-ifupdown-plugin.c \
src/settings/plugins/ifupdown/nms-ifupdown-plugin.h \
......@@ -4834,6 +4837,7 @@ install-data-hook: $(install_data_hook)
$(mkinstalldirs) -m 0755 $(DESTDIR)$(nmconfdir)/dnsmasq-shared.d
$(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/conf.d
$(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/VPN
$(mkinstalldirs) -m 0755 $(DESTDIR)$(nmlibdir)/system-connections
$(mkinstalldirs) -m 0700 $(DESTDIR)$(nmstatedir)
$(mkinstalldirs) -m 0755 $(DESTDIR)$(plugindir)
......@@ -847,6 +847,7 @@ fi
%dir %{nmlibdir}
%dir %{nmlibdir}/conf.d
%dir %{nmlibdir}/VPN
%dir %{nmlibdir}/system-connections
......@@ -56,9 +56,7 @@
does not start the network connection unless (1) device is idle and able
to connect to the network described by the new connection, and (2) the
connection is allowed to be started automatically. Use the 'Save' method
on the connection to save these changes to disk. Note that unsaved changes
will be lost if the connection is reloaded from disk (either automatically
on file change or due to an explicit ReloadConnections call).
on the connection to save these changes to disk.
<method name="AddConnectionUnsaved">
<arg name="connection" type="a{sa{sv}}" direction="in"/>
......@@ -1014,6 +1014,9 @@ typedef enum { /*< flags >*/
* is not deleted but merely the connection is decoupled from the file
* on disk. If you later delete an in-memory connection, the connection
* on disk will be deleted as well.
* Note: with 1.20, this flag is no longer implemented because in-memory connections
* are also persisted under /run. For the moment, this behaves the same as
* but if the connection has a corresponding file on disk, the association between
* the connection and the file is forgotten but the file is not modified.
......@@ -171,6 +171,11 @@ gboolean _nm_keyfile_has_values (GKeyFile *keyfile);
#define NM_KEYFILE_GROUP_NMMETA ".nmmeta"
#define NM_KEYFILE_PATH_NAME_LIB NMLIBDIR "/system-connections"
#define NM_KEYFILE_PATH_NAME_ETC_DEFAULT NMCONFDIR "/system-connections"
#define NM_KEYFILE_PATH_NAME_RUN NMRUNDIR "/system-connections"
......@@ -3537,7 +3537,9 @@ nm_keyfile_read (GKeyFile *keyfile,
vpn_secrets = TRUE;
_read_setting_wireguard_peer (&info);
else if (nm_streq (groups[i], NM_KEYFILE_GROUP_NMMETA)) {
/* pass */
} else
_read_setting (&info); = NULL;
......@@ -235,15 +235,17 @@ pan_connection_check_create (NMBluezDevice *self)
* which then already finds the suitable connection in priv->connections. This is confusing,
* so block the signal. check_emit_usable will succeed after this function call returns. */
g_signal_handlers_block_by_func (priv->settings, cp_connection_added, self);
added = nm_settings_add_connection (priv->settings, connection, FALSE, &error);
nm_settings_add_connection (priv->settings,
g_signal_handlers_unblock_by_func (priv->settings, cp_connection_added, self);
if (added) {
nm_assert (!g_slist_find (priv->connections, added));
nm_assert (connection_compatible (self, added));
nm_settings_connection_set_flags (added, NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE);
priv->connections = g_slist_prepend (priv->connections, g_object_ref (added));
priv->pan_connection = added;
nm_log_dbg (LOGD_BT, "bluez[%s] added new Bluetooth connection for NAP device: '%s' (%s)", priv->path, id, uuid);
......@@ -392,7 +394,7 @@ cp_connection_removed (NMSettings *settings,
static void
cp_connection_updated (NMSettings *settings,
NMSettingsConnection *sett_conn,
gboolean by_user,
guint update_reason_u,
NMBluezDevice *self)
if (_internal_track_connection (self, sett_conn,
......@@ -1225,7 +1227,7 @@ dispose (GObject *object)
if (to_delete) {
nm_log_dbg (LOGD_BT, "bluez[%s] removing Bluetooth connection for NAP device: '%s' (%s)", priv->path,
nm_settings_connection_get_id (to_delete), nm_settings_connection_get_uuid (to_delete));
nm_settings_connection_delete (to_delete, NULL);
nm_settings_connection_delete (to_delete, FALSE);
g_object_unref (to_delete);
......@@ -12404,16 +12404,28 @@ nm_device_set_ip_config (NMDevice *self,
if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self))
&& NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
&& NM_FLAGS_ALL (nm_settings_connection_get_flags (settings_connection),
&& nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (priv->act_request.obj)) == NM_ACTIVATION_TYPE_EXTERNAL) {
g_object_freeze_notify (G_OBJECT (settings_connection));
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_add_setting (nm_settings_connection_get_connection (settings_connection),
gs_unref_object NMConnection *new_connection = NULL;
new_connection = nm_simple_connection_new_clone (nm_settings_connection_get_connection (settings_connection));
nm_connection_add_setting (new_connection,
? nm_ip4_config_create_setting (priv->ip_config_4)
: nm_ip6_config_create_setting (priv->ip_config_6));
g_object_thaw_notify (G_OBJECT (settings_connection));
nm_settings_connection_update (settings_connection,
nm_device_queue_recheck_assume (self);
......@@ -14365,7 +14377,7 @@ cp_connection_added (NMSettings *settings, NMSettingsConnection *sett_conn, gpoi
static void
cp_connection_updated (NMSettings *settings, NMSettingsConnection *sett_conn, gboolean by_user, gpointer user_data)
cp_connection_updated (NMSettings *settings, NMSettingsConnection *sett_conn, guint update_reason_u, gpointer user_data)
cp_connection_added_or_updated (user_data, sett_conn);
......@@ -1762,7 +1762,8 @@ supplicant_iface_wps_credentials_cb (NMSupplicantInterface *iface,
if (nm_settings_connection_new_secrets (nm_act_request_get_settings_connection (req),
nm_act_request_get_applied_connection (req),
secrets, &error)) {
&error)) {
wifi_secrets_cancel (self);
nm_device_activate_schedule_stage1_device_prepare (NM_DEVICE (self));
} else {
......@@ -469,19 +469,18 @@ mirror_8021x_connection (NMIwdManager *self,
if (!nm_connection_normalize (connection, NULL, NULL, NULL))
return NULL;
settings_connection = nm_settings_add_connection (priv->settings, connection,
FALSE, &error);
if (!settings_connection) {
if (!nm_settings_add_connection (priv->settings,
&error)) {
_LOGW ("failed to add a mirror NMConnection for IWD's Known Network '%s': %s",
name, error->message);
g_error_free (error);
return NULL;
nm_settings_connection_set_flags (settings_connection,
return settings_connection;
......@@ -498,7 +497,7 @@ mirror_8021x_connection_take_and_delete (NMSettingsConnection *sett_conn)
/* If connection has not been saved since we created it
* in interface_added it too can be removed now. */
nm_settings_connection_delete (sett_conn, NULL);
nm_settings_connection_delete (sett_conn, FALSE);
g_object_unref (sett_conn);
......@@ -103,7 +103,7 @@ sources = files(
......@@ -113,6 +113,8 @@ sources = files(
......@@ -181,7 +181,7 @@ NM_UTILS_FLAGS2STR_DEFINE_STATIC (_state_flags_to_string, NMActivationStateFlags
static void
_settings_connection_updated (NMSettingsConnection *sett_conn,
gboolean by_user,
guint update_reason_u,
gpointer user_data)
NMActiveConnection *self = user_data;
......@@ -522,8 +522,9 @@ nm_active_connection_clear_secrets (NMActiveConnection *self)
if (nm_settings_connection_has_unmodified_applied_connection (priv->settings_connection.obj,
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (priv->settings_connection.obj));
nm_settings_connection_clear_secrets (priv->settings_connection.obj,
nm_connection_clear_secrets (priv->applied_connection);
......@@ -217,19 +217,35 @@ restore_and_activate_connection (NMCheckpoint *self,
gs_unref_object NMAuthSubject *subject = NULL;
GError *local_error = NULL;
gboolean need_update, need_activation;
NMSettingsConnectionPersistMode persist_mode;
NMSettingsConnectionIntFlags sett_flags;
NMSettingsConnectionIntFlags sett_mask;
connection = find_settings_connection (self,
/* FIXME: we need to ensure to re-create/update the profile for the
* same settings plugin. E.g. if it was a keyfile in /run or /etc,
* it must be again. If it was previously handled by a certain settings plugin,
* so it must again.
* FIXME: preserve and restore the right settings flags (volatile, nm-generated). */
if (connection) {
if (need_update) {
_LOGD ("rollback: updating connection %s",
nm_settings_connection_get_uuid (connection));
nm_settings_connection_update (connection,
......@@ -238,11 +254,13 @@ restore_and_activate_connection (NMCheckpoint *self,
_LOGD ("rollback: adding connection %s again",
nm_connection_get_uuid (dev_checkpoint->settings_connection));
connection = nm_settings_add_connection (NM_SETTINGS_GET,
if (!nm_settings_add_connection (NM_SETTINGS_GET,
if (!connection) {
&local_error)) {
_LOGD ("rollback: connection add failure: %s", local_error->message);
g_clear_error (&local_error);
return FALSE;
......@@ -428,7 +446,7 @@ next_dev:
nm_settings_connection_get_uuid (con))) {
_LOGD ("rollback: deleting new connection %s",
nm_settings_connection_get_uuid (con));
nm_settings_connection_delete (con, NULL);
nm_settings_connection_delete (con, FALSE);
This diff is collapsed.
......@@ -1846,8 +1846,7 @@ device_state_changed (NMDevice *device,
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (sett_conn));
nm_settings_connection_clear_secrets (sett_conn, FALSE, FALSE);
......@@ -1858,9 +1857,7 @@ device_state_changed (NMDevice *device,
/* And clear secrets so they will always be requested from the
* settings service when the next connection is made.
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (sett_conn));
nm_settings_connection_clear_secrets (sett_conn, FALSE, FALSE);
/* Add device's new IPv4 and IPv6 configs to DNS */
......@@ -2399,13 +2396,14 @@ dns_config_changed (NMDnsManager *dns_manager, gpointer user_data)
static void
connection_updated (NMSettings *settings,
NMSettingsConnection *connection,
gboolean by_user,
guint update_reason_u,
gpointer user_data)
NMPolicyPrivate *priv = user_data;
NMPolicy *self = _PRIV_TO_SELF (priv);
NMSettingsConnectionUpdateReason update_reason = update_reason_u;
if (by_user) {
const CList *tmp_lst;
NMDevice *device;
......@@ -2414,9 +2412,6 @@ connection_updated (NMSettings *settings,
if (nm_device_get_settings_connection (device) == connection)
nm_device_reapply_settings_immediately (device);
/* Reset auto retries back to default since connection was updated */
nm_settings_connection_autoconnect_retries_reset (connection);
schedule_activate_all (self);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -23,6 +23,21 @@
#include "nm-connection.h"
#include "nm-settings-storage.h"
typedef struct _NMSettingsPlugin NMSettingsPlugin;
typedef void (*NMSettingsPluginConnectionLoadCallback) (NMSettingsPlugin *self,
NMSettingsStorage *storage,
NMConnection *connection,
gpointer user_data);
typedef struct {
const char *filename;
GError *error;
bool handled:1;
} NMSettingsPluginConnectionLoadEntry;
#define NM_TYPE_SETTINGS_PLUGIN (nm_settings_plugin_get_type ())
......@@ -32,32 +47,14 @@
#define NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed"
#define NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED "unrecognized-specs-changed"
#define NM_SETTINGS_PLUGIN_CONNECTION_ADDED "connection-added"
typedef struct {
struct _NMSettingsPlugin {
GObject parent;
} NMSettingsPlugin;
typedef struct {
GObjectClass parent;
/* Returns a GSList of NMSettingsConnection objects that represent
* connections the plugin knows about. The returned list is freed by the
* system settings service.
GSList * (*get_connections) (NMSettingsPlugin *plugin);
/* Requests that the plugin load/reload a single connection, if it
* recognizes the filename. Returns success or failure.
gboolean (*load_connection) (NMSettingsPlugin *plugin,
const char *filename);
/* Requests that the plugin reload all connection files from disk,
* and emit signals reflecting new, changed, and removed connections.
void (*reload_connections) (NMSettingsPlugin *plugin);
* Return a string list of specifications of devices which NetworkManager
* should not manage. Returned list will be freed by the system settings
......@@ -67,7 +64,7 @@ typedef struct {
* Each string in the list must be in one of the formats recognized by
* nm_device_spec_match_list().
GSList * (*get_unmanaged_specs) (NMSettingsPlugin *plugin);
GSList * (*get_unmanaged_specs) (NMSettingsPlugin *self);
* Return a string list of specifications of devices for which at least
......@@ -79,49 +76,131 @@ typedef struct {
* Each string in the list must be in one of the formats recognized by
* nm_device_spec_match_list().
GSList * (*get_unrecognized_specs) (NMSettingsPlugin *plugin);
GSList * (*get_unrecognized_specs) (NMSettingsPlugin *self);
* Initialize the plugin-specific connection and return a new
* NMSettingsConnection subclass that contains the same settings as the
* original connection. The connection should only be saved to backing
* storage if @save_to_disk is TRUE. The returned object is owned by the
* plugin and must be referenced by the owner if necessary.
/* Requests that the plugin load/reload a set of filenames.
NMSettingsConnection * (*add_connection) (NMSettingsPlugin *plugin,
void (*load_connections) (NMSettingsPlugin *self,
NMSettingsPluginConnectionLoadEntry *entries,
gsize n_entries,
NMSettingsPluginConnectionLoadCallback callback,
gpointer user_data);
/* Requests that the plugin reload all connection files from disk,
* and emit signals reflecting new, changed, and removed connections.
void (*reload_connections) (NMSettingsPlugin *self,
NMSettingsPluginConnectionLoadCallback callback,
gpointer user_data);
void (*load_connections_done) (NMSettingsPlugin *self);
gboolean (*add_connection) (NMSettingsPlugin *self,
NMConnection *connection,
NMSettingsStorage **out_storage,
NMConnection **out_connection,
GError **error);
gboolean (*update_connection) (NMSettingsPlugin *self,
NMSettingsStorage *storage,
NMConnection *connection,
gboolean save_to_disk,
NMSettingsStorage **out_storage,
NMConnection **out_connection,
GError **error);
gboolean (*delete_connection) (NMSettingsPlugin *self,
NMSettingsStorage *storage,
GError **error);
const char *plugin_name;
} NMSettingsPluginClass;
GType nm_settings_plugin_get_type (void);
typedef NMSettingsPlugin *(*NMSettingsPluginFactoryFunc) (void);
/* Plugin's factory function that returns a #NMSettingsPlugin */
NMSettingsPlugin *nm_settings_plugin_factory (void);
nm_settings_plugin_get_plugin_name (nm_settings_storage_get_plugin (storage))
static inline const char *
nm_settings_plugin_get_plugin_name (NMSettingsPlugin *self)
NMSettingsPluginClass *klass;
nm_assert (NM_SETTINGS_PLUGIN (self));
nm_assert (klass && klass->plugin_name && strlen (klass->plugin_name) > 0);
return klass->plugin_name;
GSList *nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *self);
GSList *nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *self);
GSList *nm_settings_plugin_get_connections (NMSettingsPlugin *plugin);
void nm_settings_plugin_reload_connections (NMSettingsPlugin *self,
NMSettingsPluginConnectionLoadCallback callback,
gpointer user_data);
gboolean nm_settings_plugin_load_connection (NMSettingsPlugin *plugin,
const char *filename);
void nm_settings_plugin_reload_connections (NMSettingsPlugin *plugin);
NMSettingsPluginConnectionLoadEntry *nm_settings_plugin_create_connection_load_entries (const char *const*filenames,
gsize *out_len);
GSList *nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *plugin);
GSList *nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *plugin);
void nm_settings_plugin_load_connections (NMSettingsPlugin *self,
NMSettingsPluginConnectionLoadEntry *entries,
gsize n_entries,
NMSettingsPluginConnectionLoadCallback callback,
gpointer user_data);
NMSettingsConnection *nm_settings_plugin_add_connection (NMSettingsPlugin *plugin,
void nm_settings_plugin_load_connections_done (NMSettingsPlugin *self);
gboolean nm_settings_plugin_add_connection (NMSettingsPlugin *self,
NMConnection *connection,
NMSettingsStorage **out_storage,
NMConnection **out_connection,
GError **error);
gboolean nm_settings_plugin_update_connection (NMSettingsPlugin *self,
NMSettingsStorage *storage,
NMConnection *connection,
gboolean save_to_disk,
NMSettingsStorage **out_storage,
NMConnection **out_connection,
GError **error);
/* internal API */
gboolean nm_settings_plugin_delete_connection (NMSettingsPlugin *self,
NMSettingsStorage *storage,
GError **error);
typedef NMSettingsPlugin *(*NMSettingsPluginFactoryFunc) (void);
NMSettingsPlugin *nm_settings_plugin_factory (void);
* Internal API
void _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NMSettingsPlugin *self);
void _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NMSettingsPlugin *self);
void _nm_settings_plugin_emit_signal_connection_added (NMSettingsPlugin *plugin,
NMSettingsConnection *sett_conn);
void _nm_settings_plugin_emit_signal_unmanaged_specs_changed (NMSettingsPlugin *plugin);
/* forward declare this function from NMSettings. It's used by the ifcfg-rh plugin,
* but that shouldn't include all "nm-settings.h" header. */
NMSettings *nm_settings_get (void);
void _nm_settings_plugin_emit_signal_unrecognized_specs_changed (NMSettingsPlugin *plugin);
const char *nm_settings_get_dbus_path_for_uuid (NMSettings *self,
const char *uuid);
#endif /* __NM_SETTINGS_PLUGIN_H__ */
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
* Copyright 2018 Red Hat, Inc.
#include "nm-default.h"
#include "nm-settings-storage.h"
#include "nm-utils.h"
#include "nm-settings-plugin.h"
#include "settings/plugins/keyfile/nms-keyfile-storage.h"
nm_settings_storage_cmp (NMSettingsStorage *a,
NMSettingsStorage *b,
const GSList *plugin_list)
NMSettingsStorageClass *klass;
NMSettingsPlugin *plugin_a;
NMSettingsPlugin *plugin_b;
/* Sort by priority.
* If a > b (by priority), we return a positive number (as one
* would expect by a cmp() function). */
nm_assert (NM_IS_SETTINGS_STORAGE (a));
nm_assert (NM_IS_SETTINGS_STORAGE (b));
nm_assert (a != b);