mirror of git://git.sysmocom.de/ofono
Add support for GDBus security action and flags
This commit is contained in:
parent
679f17303d
commit
e173173a1f
|
@ -58,6 +58,8 @@ typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection,
|
||||||
typedef guint32 GDBusPendingReply;
|
typedef guint32 GDBusPendingReply;
|
||||||
|
|
||||||
typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
|
typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
|
||||||
|
const char *action,
|
||||||
|
gboolean interaction,
|
||||||
GDBusPendingReply pending);
|
GDBusPendingReply pending);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -74,6 +76,12 @@ typedef enum {
|
||||||
G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0),
|
G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0),
|
||||||
} GDBusPropertyFlags;
|
} 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 {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *signature;
|
const char *signature;
|
||||||
|
@ -97,6 +105,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int privilege;
|
unsigned int privilege;
|
||||||
|
const char *action;
|
||||||
|
GDBusSecurityFlags flags;
|
||||||
GDBusSecurityFunction function;
|
GDBusSecurityFunction function;
|
||||||
} GDBusSecurityTable;
|
} GDBusSecurityTable;
|
||||||
|
|
||||||
|
|
|
@ -317,9 +317,10 @@ static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg,
|
||||||
{
|
{
|
||||||
const GDBusSecurityTable *security;
|
const GDBusSecurityTable *security;
|
||||||
|
|
||||||
for (security = security_table; security && security->function &&
|
for (security = security_table; security && security->privilege;
|
||||||
security->privilege; security++) {
|
security++) {
|
||||||
struct security_data *secdata;
|
struct security_data *secdata;
|
||||||
|
gboolean interaction;
|
||||||
|
|
||||||
if (security->privilege != method->privilege)
|
if (security->privilege != method->privilege)
|
||||||
continue;
|
continue;
|
||||||
|
@ -332,7 +333,14 @@ static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg,
|
||||||
|
|
||||||
pending_security = g_slist_prepend(pending_security, secdata);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue