[Dextrose] [PATCH 3/5] keyring is locked at startup #2278

alsroot at sugarlabs.org alsroot at sugarlabs.org
Fri Oct 21 21:34:04 EDT 2011


From: Aleksey Lim <alsroot at sugarlabs.org>

---
 bin/sugar.in                     |   18 +++++++++++++-----
 src/jarabe/model/neighborhood.py |   28 ++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/bin/sugar.in b/bin/sugar.in
index f5fb399..d41d275 100755
--- a/bin/sugar.in
+++ b/bin/sugar.in
@@ -73,11 +73,19 @@ export LANGUAGE="${LANGUAGE:-${LANG}}"
 # Set Sugar's telepathy accounts directory
 export MC_ACCOUNT_DIR=$HOME/.sugar/$SUGAR_PROFILE/accounts
 
-# Workaround until gnome-keyring-daemon lets dbus activate it
-# https://bugzilla.gnome.org/show_bug.cgi?id=628302
-if test "$SUGAR_EMULATOR" = "yes" -a "$(type gnome-keyring-daemon)"; then
-    gnome-keyring-daemon --components=secrets &
-fi
+# Avoid using gnome-keyring. It doesn't make any sense in Sugar,
+# but is annoying popping up auth dialogs #2278
+export XDG_DATA_DIRS="$HOME/.sugar:$XDG_DATA_DIRS"
+for iface in org.freedesktop.secrets org.gnome.keyring; do
+    local path=$HOME/.sugar/dbus-1/services/$iface.service
+    [ -e $path ] && continue
+    mkdir -p $(dirname $path)
+    cat <<EOF >$path
+[D-BUS Service]
+Name=$iface
+Exec=/bin/false
+EOF
+done
 
 # Source language settings and debug definitions
 if [ -f ~/.dmrc ]; then
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index 828cb14..e52b743 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -14,9 +14,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
+import os
 import logging
 from functools import partial
 from hashlib import sha1
+from ConfigParser import RawConfigParser
 
 import gobject
 import gconf
@@ -701,6 +703,32 @@ class Neighborhood(gobject.GObject):
         client.add_dir('/desktop/sugar/user/nick', gconf.CLIENT_PRELOAD_NONE)
         client.notify_add('/desktop/sugar/user/nick', self.__nick_changed_cb)
 
+        # XXX Folowing code highly depends on telepathy-mission-control
+        # internals #2278
+        #
+        # If telepathy-mission-control uses gnome-keyring, it doesn't store
+        # passwords in accounts.cfg file even if sugar specifies it via
+        # param-password parameter. Adding param-password to accounts.cfg
+        # affects telepathy-mission-control to avoid using gnome-keyring for
+        # getting password.
+        #
+        # But, it triggers gnome-keyring daemon any way. See the bin/sugar.in
+        # patch in the same commit that avoids starting gnome-keyring.
+        #
+        accounts_path = os.path.join(
+                os.environ.get('MC_ACCOUNT_DIR', os.sep), 'accounts.cfg')
+        if os.path.exists(accounts_path):
+            accounts = RawConfigParser()
+            accounts.optionxform = str
+            accounts.read(accounts_path)
+            for section in accounts.sections():
+                if section.startswith('gabble'):
+                    accounts.set(section, 'param-password',
+                            get_profile().privkey_hash)
+            accounts_file = file(accounts_path, 'w')
+            accounts.write(accounts_file)
+            accounts_file.close()
+
         bus = dbus.Bus()
         obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
         account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
-- 
1.7.6.1



More information about the Dextrose mailing list