Crash on start if default keyring is locked

Bug #1289510 reported by Bertrand Lorentz
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Polly
New
Undecided
Unassigned

Bug Description

For some reason, my default keyring is not unlocked automatically when I login.
So, if I start Polly before unlocking it, Polly crashes with the following stacktrace:

$ polly
Polly 0.93.11 (pre-alpha 3.11)
Copyright (C) 2011 Marcelo Hashimoto
cache path: /home/lorentz/.cache/polly
config path: /home/lorentz/.config/polly
data home: /home/lorentz/.local/share/polly
initializing...
Traceback (most recent call last):
  File "/usr/bin/polly", line 303, in <module>
    account_manager = gui.twitter.account.Manager(NAME, config_path, config_path_lock, setting_factory, proxy_controller, font_scheme, identifier_factory, status_bar)
  File "/usr/lib/python2.7/dist-packages/polly/gui/twitter/account.py", line 486, in __init__
    subtoken_secret = keyring.get_password(self.name, subtoken)
  File "/usr/lib/python2.7/dist-packages/keyring/core.py", line 36, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/lib/python2.7/dist-packages/keyring/backends/SecretService.py", line 44, in get_password
    collection = self.get_default_collection()
  File "/usr/lib/python2.7/dist-packages/keyring/backends/SecretService.py", line 37, in get_default_collection
    if collection.unlock():
  File "/usr/lib/python2.7/dist-packages/secretstorage/collection.py", line 70, in unlock
    return exec_prompt_glib(self.bus, prompt)[0]
  File "/usr/lib/python2.7/dist-packages/secretstorage/util.py", line 78, in exec_prompt_glib
    from gi.repository import GLib
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 27, in <module>
    from ._gi import _API
ImportError: cannot import name _API

If I unlock the keyring with Seahorse, then Polly works fine.

Revision history for this message
Conscious User (conscioususer) wrote :

I will confirm this later at home, but IIRC python-keyring indeed assumes that the chosen keyring is unlocked.

But what is weird is that the error message does not seem directly related to that, but to the fact that PyGI is incompatible with PyGTK2. Why is this error not being triggered when the keyring is unlocked? Does it use an older library in that case? Does not make sense, I need to check that out...

Oh, and which distro are you using?

Revision history for this message
Bertrand Lorentz (bertrand-lorentz) wrote :

I'm running a fully updated Ubuntu GNOME 13.10, along with the updates from the related GNOME3 PPA:
https://launchpad.net/~gnome3-team/+archive/gnome3

I don't know much about python, but maybe because the keyring is locked it goes into another code path which then tries to load PyGI ?

Revision history for this message
Bertrand Lorentz (bertrand-lorentz) wrote :

I've now upgraded my system to Ubuntu GNOME 14.04, and the same thing happens: keyring not unlocked, polly crashes.
But the error message is different at the end, so here it is:

$ polly
Polly 0.93.11 (pre-alpha 3.11)
Copyright (C) 2011 Marcelo Hashimoto
cache path: /home/lorentz/.cache/polly
config path: /home/lorentz/.config/polly
data home: /home/lorentz/.local/share/polly
initializing...
Traceback (most recent call last):
  File "/usr/bin/polly", line 303, in <module>
    account_manager = gui.twitter.account.Manager(NAME, config_path, config_path_lock, setting_factory, proxy_controller, font_scheme, identifier_factory, status_bar)
  File "/usr/lib/python2.7/dist-packages/polly/gui/twitter/account.py", line 486, in __init__
    subtoken_secret = keyring.get_password(self.name, subtoken)
  File "/usr/lib/python2.7/dist-packages/keyring/core.py", line 39, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/lib/python2.7/dist-packages/keyring/backends/SecretService.py", line 53, in get_password
    collection = self.get_default_collection()
  File "/usr/lib/python2.7/dist-packages/keyring/backends/SecretService.py", line 45, in get_default_collection
    collection.unlock()
  File "/usr/lib/python2.7/dist-packages/secretstorage/collection.py", line 71, in unlock
    return exec_prompt_glib(self.bus, prompt)[0]
  File "/usr/lib/python2.7/dist-packages/secretstorage/util.py", line 121, in exec_prompt_glib
    from gi.repository import GLib
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 32, in <module>
    raise ImportError('When using gi.repository you must not import static '
ImportError: When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".

Revision history for this message
Jason Kendall (coolacid) wrote :

I can confirm this.

Then adding an account with a locked keyring I would get this stack trace.

Polly 0.93.11 (pre-alpha 3.11)
Copyright (C) 2011-2014 Marcelo Hashimoto
cache path: /home/jakendall/.cache/polly
config path: /home/jakendall/.config/polly
data home: /home/jakendall/.local/share/polly
initializing... done
Xlib: extension "RANDR" missing on display ":0.0".
Xlib: extension "RANDR" missing on display ":0.0".
Created new window in existing browser session.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/polly/external/keyring/core.py", line 42, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/lib/python2.7/dist-packages/polly/external/keyring/backend.py", line 234, in set_password
    True)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.Secret.Error.IsLocked: Cannot create an item in a locked collection

Using seahorse did not unlock the keyring for me.

I finally had to unlock it using the following python code:

$ python
>>> import gnomekeyring
>>> gnomekeyring.unlock_sync(None, 'mypassword');

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.