Skip to content

Commit

Permalink
settings: track keyfile plugin explicitly in NMSettings
Browse files Browse the repository at this point in the history
The keyfile plugin is special. For one, NetworkManager will always load
it.

In the future, only this plugin should handle in-memory connections.
In-memory connections are kinda special, and we don't need general
plugins to be concerned about them. They should be handled by keyfile
plugin.

But then NMSettings needs to have a reference to the keyfile plugin
instance at hand.
  • Loading branch information
thom311 committed Jun 17, 2019
1 parent 45013bf commit 408a453
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/settings/nm-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ typedef struct {

NMConfig *config;

NMHostnameManager *hostname_manager;

CList auth_lst_head;

NMSKeyfilePlugin *keyfile_plugin;

GSList *plugins;

NMKeyFileDB *kf_db_timestamps;
Expand All @@ -124,11 +128,10 @@ typedef struct {
CList connections_lst_head;

NMSettingsConnection **connections_cached_list;

GSList *unmanaged_specs;
GSList *unrecognized_specs;

NMHostnameManager *hostname_manager;

NMSettingsConnection *startup_complete_blocked_by;

guint connections_len;
Expand Down Expand Up @@ -1339,17 +1342,18 @@ add_plugin_load_file (NMSettings *self, const char *pname, GError **error)
static void
add_plugin_keyfile (NMSettings *self)
{
gs_unref_object NMSKeyfilePlugin *keyfile_plugin = NULL;
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);

keyfile_plugin = nms_keyfile_plugin_new ();
add_plugin (self, NM_SETTINGS_PLUGIN (keyfile_plugin), "keyfile", NULL);
if (priv->keyfile_plugin)
return;
priv->keyfile_plugin = nms_keyfile_plugin_new ();
add_plugin (self, NM_SETTINGS_PLUGIN (priv->keyfile_plugin), "keyfile", NULL);
}

static gboolean
load_plugins (NMSettings *self, const char **plugins, GError **error)
{
const char **iter;
gboolean keyfile_added = FALSE;
gboolean success = TRUE;
gboolean add_ibft = FALSE;
gboolean has_no_ibft;
Expand Down Expand Up @@ -1382,10 +1386,7 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)

/* keyfile plugin is built-in now */
if (nm_streq (pname, "keyfile")) {
if (!keyfile_added) {
add_plugin_keyfile (self);
keyfile_added = TRUE;
}
add_plugin_keyfile (self);
continue;
}

Expand Down Expand Up @@ -1414,7 +1415,7 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
}

/* If keyfile plugin was not among configured plugins, add it as the last one */
if (!keyfile_added && success)
if (success)
add_plugin_keyfile (self);

return success;
Expand Down Expand Up @@ -1964,6 +1965,8 @@ finalize (GObject *object)
g_signal_handlers_disconnect_by_data (plugin, self);
}

g_clear_object (&priv->keyfile_plugin);

g_clear_object (&priv->agent_mgr);

g_clear_object (&priv->config);
Expand Down

0 comments on commit 408a453

Please sign in to comment.