diff options
author | Jens Georg <mail@jensge.org> | 2014-08-19 21:20:06 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2018-11-07 11:04:05 +0100 |
commit | a7ea5e232504f495f1113a654bb1363300dac0f9 (patch) | |
tree | 0d5c5f94b318f1affcba7d0033fd1965f53c7d72 | |
parent | 2a8cf4e63ec7ecbf5ea355737a782488ebf2050d (diff) | |
download | rygel-a7ea5e232504f495f1113a654bb1363300dac0f9.tar.gz |
WIP
-rw-r--r-- | src/rygel/Makefile.am | 22 | ||||
-rw-r--r-- | src/rygel/acl-provider.vala | 75 | ||||
-rw-r--r-- | src/rygel/acl-store.vala | 4 |
3 files changed, 101 insertions, 0 deletions
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am index deacf8d9..60eb0ee9 100644 --- a/src/rygel/Makefile.am +++ b/src/rygel/Makefile.am @@ -1,6 +1,7 @@ include $(top_srcdir)/common.am bin_PROGRAMS = rygel +libexec_PROGRAMS = rygel-acl-provider rygel_SOURCES = \ rygel-acl.vala \ @@ -24,6 +25,27 @@ rygel_LDADD = \ $(RYGEL_DEPS_LIBS) \ $(RYGEL_COMMON_LIBRYGEL_SERVER_LIBS) +rygel_acl_provider_SOURCES = \ + acl-provider.vala \ + acl-store.vala + +rygel_acl_provider_VALAFLAGS = \ + $(RYGEL_COMMON_LIBRYGEL_CORE_VALAFLAGS) \ + $(RYGEL_COMMON_VALAFLAGS) + +rygel_acl_provider_CFLAGS = \ + $(RYGEL_DEPS_CFLAGS) \ + $(RYGEL_COMMON_LIBRYGEL_CORE_CFLAGS) \ + -include config.h \ + -DLOCALEDIR=\""$(datadir)/locale"\" \ + -DG_LOG_DOMAIN='"RygelAcl"' \ + -DSYS_CONFIG_DIR='"$(sysconfigdir)"' + +rygel_acl_provider_LDADD = \ + $(RYGEL_DEPS_LIBS) \ + $(RYGEL_COMMON_LIBRYGEL_CORE_LIBS) + + vapidir = $(VAPIDIR) vapi_DATA = $(VAPI_FILES) $(DEPS_FILES) diff --git a/src/rygel/acl-provider.vala b/src/rygel/acl-provider.vala new file mode 100644 index 00000000..8648c0a0 --- /dev/null +++ b/src/rygel/acl-provider.vala @@ -0,0 +1,75 @@ + +public class Rygel.AclProvider : DBusAclProvider, Object { + public async bool is_allowed (GLib.HashTable<string, string> device, + GLib.HashTable<string, string> service, + string path, + string address, + string? agent) + throws DBusError, IOError { + + Idle.add (() => { is_allowed.callback (); return false; }); + yield; + + + if (device.size () == 0 || service.size () == 0) { + message ("Nothing to decide on, passing true"); + + return true; + } + + message ("%s from %s is trying to access %s. Allow?", + agent, address, device["FriendlyName"]); + + if (path.has_prefix ("/Event")) { + message ("Trying to subscribe to events of %s on %s", + service["Type"], device["FriendlyName"]); + } else if (path.has_prefix ("/Control")) { + message ("Trying to access control of %s on %s", + service["Type"], device["FriendlyName"]); + } else { + return true; + } + + return true; + } + + private void on_bus_aquired (DBusConnection connection) { + try { + debug ("Trying to register ourselves at path %s", + DBusAclProvider.OBJECT_PATH); + connection.register_object (DBusAclProvider.OBJECT_PATH, + this as DBusAclProvider); + debug ("Success."); + } catch (IOError error) { + warning (_("Failed to register service: %s"), error.message); + } + } + + public void register () { + debug ("Trying to aquire name %s on session DBus", + DBusAclProvider.SERVICE_NAME); + Bus.own_name (BusType.SESSION, + DBusAclProvider.SERVICE_NAME, + BusNameOwnerFlags.NONE, + this.on_bus_aquired, + () => {}, + () => { warning (_("Could not aquire bus name %s"), + DBusAclProvider.SERVICE_NAME); + }); + } + + public int run () { + message (_("Rygel ACL Provider v%s starting."), + BuildConfig.PACKAGE_VERSION); + MainLoop loop = new MainLoop (); + this.register (); + loop.run (); + message (_("Rygel ACL Provider done.")); + + return 0; + } + + public static int main (string[] args) { + return new AclProvider().run(); + } +} diff --git a/src/rygel/acl-store.vala b/src/rygel/acl-store.vala new file mode 100644 index 00000000..6ad2ac2d --- /dev/null +++ b/src/rygel/acl-store.vala @@ -0,0 +1,4 @@ +internal class Rygel.AclStorage : Object { + public AclStorage () { + } +} |