diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-09-09 16:39:46 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-09-09 18:27:18 +0200 |
commit | ae3c3ba18ed0db38d088d656a06d3c3d36e37fed (patch) | |
tree | 333626799c991f939e80d849cf6ea57d357d0583 /gdbus | |
parent | ab72158f2a28bfe1477ffce27478a2c7bba9e955 (diff) | |
download | connman-ae3c3ba18ed0db38d088d656a06d3c3d36e37fed.tar.gz connman-ae3c3ba18ed0db38d088d656a06d3c3d36e37fed.tar.bz2 connman-ae3c3ba18ed0db38d088d656a06d3c3d36e37fed.zip |
Add support for GDBus security action and flags
Diffstat (limited to 'gdbus')
-rw-r--r-- | gdbus/gdbus.h | 10 | ||||
-rw-r--r-- | gdbus/object.c | 14 |
2 files changed, 21 insertions, 3 deletions
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index 553918c0..d902f8e7 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -58,6 +58,8 @@ typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection, typedef guint32 GDBusPendingReply; typedef void (* GDBusSecurityFunction) (DBusConnection *connection, + const char *action, + gboolean interaction, GDBusPendingReply pending); typedef enum { @@ -74,6 +76,12 @@ typedef enum { G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0), } GDBusPropertyFlags; +typedef enum { + G_DBUS_SECURITY_FLAG_DEPRECATED = (1 << 0), + G_DBUS_SECURITY_FLAG_BUILTIN = (1 << 1), + G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION = (1 << 2), +} GDBusSecurityFlags; + typedef struct { const char *name; const char *signature; @@ -97,6 +105,8 @@ typedef struct { typedef struct { unsigned int privilege; + const char *action; + GDBusSecurityFlags flags; GDBusSecurityFunction function; } GDBusSecurityTable; diff --git a/gdbus/object.c b/gdbus/object.c index 48530f2a..725c0bbb 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -317,9 +317,10 @@ static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg, { const GDBusSecurityTable *security; - for (security = security_table; security && security->function && - security->privilege; security++) { + for (security = security_table; security && security->privilege; + security++) { struct security_data *secdata; + gboolean interaction; if (security->privilege != method->privilege) continue; @@ -332,7 +333,14 @@ static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg, pending_security = g_slist_prepend(pending_security, secdata); - security->function(conn, secdata->pending); + if (security->flags & G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION) + interaction = TRUE; + else + interaction = FALSE; + + if (security->function) + security->function(conn, security->action, + interaction, secdata->pending); return TRUE; } |