[folks] Let each PersonaStore manage its trust-level
- From: Raul Gutierrez Segales <raulgs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Let each PersonaStore manage its trust-level
- Date: Fri, 16 Sep 2011 19:44:59 +0000 (UTC)
commit 44f9a8316082e5f86ac96e5018f11713767ecb9d
Author: Raul Gutierrez Segales <rgs collabora co uk>
Date: Wed Sep 14 20:48:47 2011 +0100
Let each PersonaStore manage its trust-level
Previously, the IndividualAggregator was in charge of
downgrading and upgrading the trust-level of each
PersonaStore. From now on, we let each Store manage its
trust-level since it's the natural way to do it.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=659075
backends/eds/lib/edsf-persona-store.vala | 32 ++++++++++++++++++++++++++-
backends/tracker/lib/trf-persona-store.vala | 1 +
folks/individual-aggregator.vala | 14 -----------
3 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala
index 687e83e..07e87e6 100644
--- a/backends/eds/lib/edsf-persona-store.vala
+++ b/backends/eds/lib/edsf-persona-store.vala
@@ -61,6 +61,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
private void _address_book_notify_read_only_cb (Object address_book,
ParamSpec pspec)
{
+ this._update_trust_level ();
this.notify_property ("can-add-personas");
this.notify_property ("can-remove-personas");
}
@@ -208,7 +209,6 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this._personas = new HashMap<string, Persona> ();
this._personas_ro = this._personas.read_only_view;
this._query_str = "(contains \"x-evolution-any-field\" \"\")";
- this.trust_level = PersonaStoreTrust.PARTIAL;
}
~PersonaStore ()
@@ -546,6 +546,8 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this._address_book_notify_read_only_cb);
yield this._addressbook.open (false, null);
+
+ this._update_trust_level ();
}
catch (GLib.Error e1)
{
@@ -1821,4 +1823,32 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this.removed ();
}
}
+
+ /* This isn't perfect, since we want to base our trust of the address book on
+ * whether *other people* can write to it (and potentially maliciously affect
+ * the linking our aggregator does). However, since we can't know that, we
+ * assume that if we can write to the address book we're probably in full
+ * control of it. If we can't, either nobody/a sysadmin is (e.g. LDAP) or
+ * or somebody else (who we can't trust) is (e.g. a read-only view of someone
+ * else's WebDAV address book).
+ */
+ private void _update_trust_level ()
+ {
+ unowned SourceGroup? group = (SourceGroup?) this._source.peek_group ();
+ if (group != null)
+ {
+ var base_uri = group.peek_base_uri ();
+ /* base_uri should be ldap:// for LDAP based address books */
+ if (base_uri != null && base_uri.has_prefix("ldap"))
+ {
+ this.trust_level = PersonaStoreTrust.PARTIAL;
+ return;
+ }
+ }
+
+ if (this._addressbook.readonly)
+ this.trust_level = PersonaStoreTrust.PARTIAL;
+ else
+ this.trust_level = PersonaStoreTrust.FULL;
+ }
}
diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala
index b291f26..7f4915b 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -417,6 +417,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
this._personas = new HashMap<string, Persona> ();
this._personas_ro = this._personas.read_only_view;
debug ("Initial query : \n%s\n", this._INITIAL_QUERY);
+ this.trust_level = PersonaStoreTrust.FULL;
}
/**
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 7a8bdd8..6b53a3c 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -614,7 +614,6 @@ public class Folks.IndividualAggregator : Object
this._configured_primary_store_id == store.id)
{
store.is_primary_store = true;
- store.trust_level = PersonaStoreTrust.FULL;
this._primary_store = store;
this.notify_property ("primary-store");
}
@@ -624,7 +623,6 @@ public class Folks.IndividualAggregator : Object
store.personas_changed.connect (this._personas_changed_cb);
store.notify["is-primary-store"].connect (
this._is_primary_store_changed_cb);
- store.notify["trust-level"].connect (this._trust_level_changed_cb);
store.notify["is-quiescent"].connect (
this._persona_store_is_quiescent_changed_cb);
@@ -660,7 +658,6 @@ public class Folks.IndividualAggregator : Object
store.personas_changed.disconnect (this._personas_changed_cb);
store.notify["is-quiescent"].disconnect (
this._persona_store_is_quiescent_changed_cb);
- store.notify["trust-level"].disconnect (this._trust_level_changed_cb);
store.notify["is-primary-store"].disconnect (
this._is_primary_store_changed_cb);
@@ -1277,17 +1274,6 @@ public class Folks.IndividualAggregator : Object
store != this._primary_store));
}
- private void _trust_level_changed_cb (Object object, ParamSpec pspec)
- {
- /* Only our primary_store can be fully trusted. */
- var store = (PersonaStore) object;
- if (this._primary_store != null &&
- store == this._primary_store)
- assert (store.trust_level == PersonaStoreTrust.FULL);
- else
- assert (store.trust_level != PersonaStoreTrust.FULL);
- }
-
private void _persona_store_is_quiescent_changed_cb (Object obj,
ParamSpec pspec)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]