summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2015-04-11 16:20:50 +0200
committerJens Georg <mail@jensge.org>2015-07-20 22:36:08 +0200
commit494ad67fb9d7b3ba64947bc0819eb4e36ada4bb0 (patch)
tree768ddca31418c3072ad4b1fc253f70bf02a055ec /src
parent97f7eaacafc3830d289df31e48fd4e6f99bc8dc8 (diff)
downloadrygel-494ad67fb9d7b3ba64947bc0819eb4e36ada4bb0.tar.gz
rygel: Add ACL fall-back policy handling
If provider is not available, use policy from config Signed-off-by: Jens Georg <mail@jensge.org>
Diffstat (limited to 'src')
-rw-r--r--src/rygel/rygel-acl.vala51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/rygel/rygel-acl.vala b/src/rygel/rygel-acl.vala
index 1cc2e6d1..d8c9ca03 100644
--- a/src/rygel/rygel-acl.vala
+++ b/src/rygel/rygel-acl.vala
@@ -23,23 +23,47 @@
internal class Rygel.Acl : GLib.Object, GUPnP.Acl
{
private DBusAclProvider provider;
+ private Configuration configuration;
+ private bool fallback_policy;
+
+ public override void constructed () {
+ base.constructed ();
- public Acl () {
Bus.watch_name (BusType.SESSION,
DBusAclProvider.SERVICE_NAME,
BusNameWatcherFlags.AUTO_START,
this.on_name_appeared,
this.on_name_vanished);
- }
- public bool can_sync () { return false; }
+ this.configuration = MetaConfig.get_default ();
+ this.fallback_policy = true;
+ this.update_fallback_policy ();
+
+ this.configuration.setting_changed.connect ( (s, k) => {
+ if (s == "general" && k == "acl-fallback-policy") {
+ this.update_fallback_policy ();
+ }
+ });
+ }
+
+ /**
+ * Whether this provider supports sync access.
+ *
+ * If we do not have a DBus provider (yet) there is no need to
+ * artificially delay the fall-back policy answer.
+ */
+ public bool can_sync () { return this.provider == null; }
public bool is_allowed (GUPnP.Device? device,
GUPnP.Service? service,
string path,
string address,
string? agent) {
- assert_not_reached ();
+ if (this.provider == null) {
+ return this.fallback_policy;
+ } else {
+ assert_not_reached ();
+ }
}
public async bool is_allowed_async (GUPnP.Device? device,
@@ -50,9 +74,10 @@ internal class Rygel.Acl : GLib.Object, GUPnP.Acl
GLib.Cancellable? cancellable)
throws GLib.Error {
if (this.provider == null) {
- debug ("No external provider found, allowing access…");
+ Idle.add ( () => { is_allowed_async.callback (); return false; });
+ yield;
- return true;
+ return this.fallback_policy;
}
debug ("Querying ACL for %s on %s by %s@%s",
@@ -107,4 +132,18 @@ internal class Rygel.Acl : GLib.Object, GUPnP.Acl
private void on_name_vanished (DBusConnection connection, string name) {
this.provider = null;
}
+
+ private void update_fallback_policy () {
+ try {
+ this.fallback_policy = this.configuration.get_bool
+ ("general",
+ "acl-fallback-policy");
+ } catch (Error error) {
+ if (this.fallback_policy) {
+ message (_("No ACL fallback policy found. Using \"allow\""));
+ } else {
+ message (_("No ACL fallback policy found. Using \"deny\""));
+ }
+ }
+ }
}