summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-11-20 16:00:34 -0600
committerDan Williams <dcbw@redhat.com>2014-11-20 16:00:34 -0600
commit0dbafbf42466518f78f143ddb385280b8928b88f (patch)
treebfa7278d3830afc710c5e440329a15cb08ec5881
parent3592c5f199d75b5c5969e172a06831d2fcacdf30 (diff)
downloadNetworkManager-danw/secret-agent-old-bgo740345.tar.gz
libnm: merge nm_secret_agent_simple_set_connection_path() into nm_secret_agent_simple_enable()danw/secret-agent-old-bgo740345
set_connection_path() is almost always called right before enable(), and it's unclear why it would be called anywhere else. So just merge the two methods.
-rw-r--r--clients/cli/agent.c2
-rw-r--r--clients/cli/connections.c11
-rw-r--r--clients/cli/devices.c5
-rw-r--r--clients/common/nm-secret-agent-simple.c29
-rw-r--r--clients/common/nm-secret-agent-simple.h3
-rw-r--r--clients/tui/nmtui-connect.c11
6 files changed, 23 insertions, 38 deletions
diff --git a/clients/cli/agent.c b/clients/cli/agent.c
index 2a5a81e5a3..1695ed5961 100644
--- a/clients/cli/agent.c
+++ b/clients/cli/agent.c
@@ -147,7 +147,7 @@ do_agent_secret (NmCli *nmc, int argc, char **argv)
/* We keep running */
nmc->should_wait = TRUE;
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), NULL);
g_signal_connect (nmc->secret_agent, "request-secrets", G_CALLBACK (secrets_requested), nmc);
g_print (_("nmcli successfully registered as a NetworkManager's secret agent.\n"));
} else {
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index dafb097f8c..70f20e7f6e 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -1768,10 +1768,9 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
if (nmc->secret_agent) {
NMRemoteConnection *connection = nm_active_connection_get_connection (active);
- const gchar *path = nm_connection_get_path (NM_CONNECTION (connection));
- nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent),
+ nm_connection_get_path (NM_CONNECTION (connection)));
}
devices = nm_active_connection_get_devices (active);
@@ -2092,10 +2091,8 @@ nmc_activate_connection (NmCli *nmc,
if (nmc->secret_agent) {
g_signal_connect (nmc->secret_agent, "request-secrets", G_CALLBACK (nmc_secrets_requested), nmc);
if (connection) {
- const gchar *path = nm_object_get_path (NM_OBJECT (connection));
-
- nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent),
+ nm_object_get_path (NM_OBJECT (connection)));
}
}
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index b5b04dc3ad..9c64c880d1 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -1520,10 +1520,9 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
} else {
if (nmc->secret_agent) {
NMRemoteConnection *connection = nm_active_connection_get_connection (active);
- const char *path = nm_connection_get_path (NM_CONNECTION (connection));
- nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), path);
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent),
+ nm_connection_get_path (NM_CONNECTION (connection)));
}
g_object_ref (device);
diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c
index e0a1c02669..80022a4dc3 100644
--- a/clients/common/nm-secret-agent-simple.c
+++ b/clients/common/nm-secret-agent-simple.c
@@ -583,34 +583,27 @@ nm_secret_agent_simple_delete_secrets (NMSecretAgentOld *agent,
}
/**
- * nm_secret_agent_simple_set_connection_path:
- * @self: the #NMSecretAgentSimple
- * @path: the path of the connection the agent handle secrets for
- *
- * Sets the path for a new #NMSecretAgentSimple.
- */
-void
-nm_secret_agent_simple_set_connection_path (NMSecretAgentSimple *self, const char *path)
-{
- NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (self);
-
- g_free (priv->path);
- priv->path = g_strdup (path);
-}
-
-/**
* nm_secret_agent_simple_enable:
* @self: the #NMSecretAgentSimple
+ * @path: (allow-none): the path of the connection (if any) to handle secrets
+ * for. If %NULL, secrets for any connection will be handled.
*
- * Enables servicing the requests including the already queued ones.
+ * Enables servicing the requests including the already queued ones. If @path
+ * is given, the agent will only handle requests for connections that match
+ * @path.
*/
void
-nm_secret_agent_simple_enable (NMSecretAgentSimple *self)
+nm_secret_agent_simple_enable (NMSecretAgentSimple *self, const char *path)
{
NMSecretAgentSimplePrivate *priv = NM_SECRET_AGENT_SIMPLE_GET_PRIVATE (self);
GList *requests, *iter;
GError *error;
+ if (g_strcmp0 (path, priv->path) != 0) {
+ g_free (priv->path);
+ priv->path = g_strdup (path);
+ }
+
if (priv->enabled)
return;
priv->enabled = TRUE;
diff --git a/clients/common/nm-secret-agent-simple.h b/clients/common/nm-secret-agent-simple.h
index 5503a70ccb..81fec65139 100644
--- a/clients/common/nm-secret-agent-simple.h
+++ b/clients/common/nm-secret-agent-simple.h
@@ -54,9 +54,8 @@ void nm_secret_agent_simple_response (NMSecretAgentSimpl
const char *request_id,
GPtrArray *secrets);
-void nm_secret_agent_simple_set_connection_path (NMSecretAgentSimple *self,
+void nm_secret_agent_simple_enable (NMSecretAgentSimple *self,
const char *path);
-void nm_secret_agent_simple_enable (NMSecretAgentSimple *self);
G_END_DECLS
diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c
index 7176541f4c..438915d2a6 100644
--- a/clients/tui/nmtui-connect.c
+++ b/clients/tui/nmtui-connect.c
@@ -148,9 +148,8 @@ activate_connection (NMConnection *connection,
agent = nm_secret_agent_simple_new ("nmtui");
if (agent) {
if (connection) {
- nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (agent),
- nm_object_get_path (NM_OBJECT (connection)));
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent),
+ nm_object_get_path (NM_OBJECT (connection)));
}
g_signal_connect (agent, "request-secrets", G_CALLBACK (secrets_requested), NULL);
}
@@ -192,10 +191,8 @@ activate_connection (NMConnection *connection,
if (!connection) {
connection = NM_CONNECTION (nm_active_connection_get_connection (ac));
if (connection) {
- const gchar *path = nm_object_get_path (NM_OBJECT (connection));
-
- nm_secret_agent_simple_set_connection_path (NM_SECRET_AGENT_SIMPLE (agent), path);
- nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent));
+ nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent),
+ nm_object_get_path (NM_OBJECT (connection)));
}
}