summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-07-18 22:39:39 -0500
committerDan Williams <dcbw@redhat.com>2013-07-31 08:16:34 -0500
commit16bb798861b0f8b727dcb9d843693edee6959003 (patch)
tree587afa2f95ea099472c885a9ec36af4132f4c5ee
parentcfa4117ebb6a928ef3332f5c606bbfbf4b7159d7 (diff)
downloadNetworkManager-16bb798861b0f8b727dcb9d843693edee6959003.tar.gz
agents: add agent capabilities
A new agent registration method enables agents to pass capabilities during the registration process.
-rw-r--r--introspection/nm-agent-manager.xml18
-rw-r--r--introspection/nm-secret-agent.xml12
-rw-r--r--src/settings/nm-agent-manager.c22
-rw-r--r--src/settings/nm-secret-agent.c13
-rw-r--r--src/settings/nm-secret-agent.h13
5 files changed, 72 insertions, 6 deletions
diff --git a/introspection/nm-agent-manager.xml b/introspection/nm-agent-manager.xml
index e26caacf42..d107442860 100644
--- a/introspection/nm-agent-manager.xml
+++ b/introspection/nm-agent-manager.xml
@@ -23,6 +23,24 @@
</arg>
</method>
+ <method name="RegisterWithCapabilities">
+ <tp:docstring>
+ Like Register() but indicates agent capabilities to NetworkManager.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_register_with_capabilities"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="identifier" type="s" direction="in">
+ <tp:docstring>
+ See the Register() method's identifier argument.
+ </tp:docstring>
+ </arg>
+ <arg name="capabilities" type="u" direction="in" tp:type="NM_SECRET_AGENT_CAPABILITIES">
+ <tp:docstring>
+ Indicates various agent capabilities to NetworkManager.
+ </tp:docstring>
+ </arg>
+ </method>
+
<method name="Unregister">
<tp:docstring>
Called by secret Agents to notify NetworkManager that they will no
diff --git a/introspection/nm-secret-agent.xml b/introspection/nm-secret-agent.xml
index fa85cb6c65..291f1bdd92 100644
--- a/introspection/nm-secret-agent.xml
+++ b/introspection/nm-secret-agent.xml
@@ -223,6 +223,18 @@
</arg>
</method>
+ <tp:flags name="NM_SECRET_AGENT_CAPABILITIES" value-prefix="NM_SECRET_AGENT_CAPABILITY" type="u">
+ <tp:flag suffix="NONE" value="0x0">
+ <tp:docstring>No special capabilities.</tp:docstring>
+ </tp:flag>
+ <tp:flag suffix="VPN_HINTS" value="0x1">
+ <tp:docstring>
+ The agent supports passing hints to VPN plugin authentication
+ dialogs.
+ </tp:docstring>
+ </tp:flag>
+ </tp:flags>
+
</interface>
</node>
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c
index 3f6d355d49..c6ab771e56 100644
--- a/src/settings/nm-agent-manager.c
+++ b/src/settings/nm-agent-manager.c
@@ -80,6 +80,11 @@ static void impl_agent_manager_register (NMAgentManager *self,
const char *identifier,
DBusGMethodInvocation *context);
+static void impl_agent_manager_register_with_capabilities (NMAgentManager *self,
+ const char *identifier,
+ NMSecretAgentCapabilities capabilities,
+ DBusGMethodInvocation *context);
+
static void impl_agent_manager_unregister (NMAgentManager *self,
DBusGMethodInvocation *context);
@@ -259,9 +264,10 @@ find_agent_by_identifier_and_uid (NMAgentManager *self,
}
static void
-impl_agent_manager_register (NMAgentManager *self,
- const char *identifier,
- DBusGMethodInvocation *context)
+impl_agent_manager_register_with_capabilities (NMAgentManager *self,
+ const char *identifier,
+ NMSecretAgentCapabilities capabilities,
+ DBusGMethodInvocation *context)
{
NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self);
char *sender = NULL;
@@ -305,7 +311,7 @@ impl_agent_manager_register (NMAgentManager *self,
}
/* Success, add the new agent */
- agent = nm_secret_agent_new (context, sender, identifier, sender_uid);
+ agent = nm_secret_agent_new (context, sender, identifier, sender_uid, capabilities);
if (!agent) {
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
NM_AGENT_MANAGER_ERROR_INTERNAL_ERROR,
@@ -339,6 +345,14 @@ done:
}
static void
+impl_agent_manager_register (NMAgentManager *self,
+ const char *identifier,
+ DBusGMethodInvocation *context)
+{
+ impl_agent_manager_register_with_capabilities (self, identifier, 0, context);
+}
+
+static void
impl_agent_manager_unregister (NMAgentManager *self,
DBusGMethodInvocation *context)
{
diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c
index a44625a921..aa6f2822d4 100644
--- a/src/settings/nm-secret-agent.c
+++ b/src/settings/nm-secret-agent.c
@@ -47,6 +47,7 @@ typedef struct {
char *identifier;
uid_t owner_uid;
char *owner_username;
+ NMSecretAgentCapabilities capabilities;
guint32 hash;
GSList *permissions;
@@ -145,6 +146,14 @@ nm_secret_agent_get_owner_username(NMSecretAgent *agent)
return NM_SECRET_AGENT_GET_PRIVATE (agent)->owner_username;
}
+NMSecretAgentCapabilities
+nm_secret_agent_get_capabilities (NMSecretAgent *agent)
+{
+ g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), NM_SECRET_AGENT_CAPABILITY_NONE);
+
+ return NM_SECRET_AGENT_GET_PRIVATE (agent)->capabilities;
+}
+
guint32
nm_secret_agent_get_hash (NMSecretAgent *agent)
{
@@ -421,7 +430,8 @@ NMSecretAgent *
nm_secret_agent_new (DBusGMethodInvocation *context,
const char *owner,
const char *identifier,
- uid_t owner_uid)
+ uid_t owner_uid,
+ NMSecretAgentCapabilities capabilities)
{
NMSecretAgent *self;
NMSecretAgentPrivate *priv;
@@ -443,6 +453,7 @@ nm_secret_agent_new (DBusGMethodInvocation *context,
priv->identifier = g_strdup (identifier);
priv->owner_uid = owner_uid;
priv->owner_username = g_strdup (username);
+ priv->capabilities = capabilities;
hash_str = g_strdup_printf ("%08u%s", owner_uid, identifier);
priv->hash = g_str_hash (hash_str);
diff --git a/src/settings/nm-secret-agent.h b/src/settings/nm-secret-agent.h
index ace060919a..a59182e533 100644
--- a/src/settings/nm-secret-agent.h
+++ b/src/settings/nm-secret-agent.h
@@ -30,6 +30,14 @@
#include "nm-dbus-manager.h"
#include "nm-settings-flags.h"
+/* NOTE: ensure these capabilities match those in introspection/nm-secret-agent.xml and
+ * libnm-glib/nm-secret-agent.h.
+ */
+typedef enum {
+ NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
+ NM_SECRET_AGENT_CAPABILITY_VPN_HINTS = 0x1,
+} NMSecretAgentCapabilities;
+
#define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ())
#define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent))
#define NM_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))
@@ -50,7 +58,8 @@ GType nm_secret_agent_get_type (void);
NMSecretAgent *nm_secret_agent_new (DBusGMethodInvocation *context,
const char *owner,
const char *identifier,
- uid_t owner_uid);
+ uid_t owner_uid,
+ NMSecretAgentCapabilities capabilities);
const char *nm_secret_agent_get_description (NMSecretAgent *agent);
@@ -62,6 +71,8 @@ uid_t nm_secret_agent_get_owner_uid (NMSecretAgent *agent);
const char *nm_secret_agent_get_owner_username (NMSecretAgent *agent);
+NMSecretAgentCapabilities nm_secret_agent_get_capabilities (NMSecretAgent *agent);
+
guint32 nm_secret_agent_get_hash (NMSecretAgent *agent);
void nm_secret_agent_add_permission (NMSecretAgent *agent,