Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if password exists in keyring, but retrieval fails for any reason #1020

Closed
tkedwards opened this issue Aug 5, 2020 · 1 comment · Fixed by #1138
Closed

Error if password exists in keyring, but retrieval fails for any reason #1020

tkedwards opened this issue Aug 5, 2020 · 1 comment · Fixed by #1138
Labels
bug Something isn't working 📌 This can't go stale

Comments

@tkedwards
Copy link

Bug Report

Environment

  • Jrnl version: jrnl version v2.4.5
  • Install method: Installed using the pip3 command on Ubuntu
  • OS Ubuntu 18.04

Current Behavior

If I ssh into a Linux machine and try to run jrnl to open a Journal that's encrypted I get the below traceback. This doesn't happen if I'm in a desktop environment (for example KDE or GNOME) on the same Linux machine. It appears that jrnl doesn't ask for the password when it can't access the KWallet/GNOME wallet system:

$ jrnl -from yesterday

WARNING: Python versions below 3.7 will no longer be supported as of jrnl v2.5
(the next release). You are currently on Python 3.6.9. Please update to
Python 3.7 (or higher) soon.

Traceback (most recent call last):
  File "/usr/local/bin/jrnl", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.6/dist-packages/jrnl/cli.py", line 387, in run
    journal = open_journal(journal_name, config)
  File "/usr/local/lib/python3.6/dist-packages/jrnl/Journal.py", line 405, in open_journal
    return EncryptedJournal.EncryptedJournal(name, **config).open()
  File "/usr/local/lib/python3.6/dist-packages/jrnl/EncryptedJournal.py", line 55, in open
    text = self._load(filename)
  File "/usr/local/lib/python3.6/dist-packages/jrnl/EncryptedJournal.py", line 82, in _load
    return util.decrypt_content(keychain=self.name, decrypt_func=decrypt_journal)
  File "/usr/local/lib/python3.6/dist-packages/jrnl/util.py", line 70, in decrypt_content
    pwd_from_keychain = keychain and get_keychain(keychain)
  File "/usr/local/lib/python3.6/dist-packages/jrnl/util.py", line 93, in get_keychain
    return keyring.get_password("jrnl", journal_name)
  File "/usr/local/lib/python3.6/dist-packages/keyring/core.py", line 56, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/local/lib/python3.6/dist-packages/keyring/backends/chainer.py", line 51, in get_password
    password = keyring.get_password(service, username)
  File "/usr/local/lib/python3.6/dist-packages/keyring/backends/SecretService.py", line 75, in get_password
    collection = self.get_preferred_collection()
  File "/usr/local/lib/python3.6/dist-packages/keyring/backends/SecretService.py", line 63, in get_preferred_collection
    raise KeyringLocked("Failed to unlock the collection!")
keyring.errors.KeyringLocked: Failed to unlock the collection!

Expected Behavior

jrnl should see that the journal was encrypted using a key stored in a Keyring (Kwallet/Gnome Wallet etc) and, if the keyring is not available, prompt for the password to decrypt it.

Repro Steps

  • encrypt a journal using a password in a keyrng
  • try to access that journal when at a command-line session (i.e ssh login, or direct console login) and not in a desktop environment

Other Information

@tkedwards tkedwards added 🆕 New! bug Something isn't working labels Aug 5, 2020
@wren
Copy link
Member

wren commented Aug 6, 2020

This is a very good point. I can repro the same behavior on desktop by denying the keyring request.

Currently, jrnl checks if the correct entry exists in the keyring, then tries to access it. If the entry exists on the keyring, but keyring access fails, then the jrnl command also fails with the above error. I think it would be a very reasonable fallback to ask the user to manually enter the password if keyring retrieval fails.

@wren wren added 📌 This can't go stale and removed 🆕 New! labels Aug 6, 2020
@wren wren changed the title keyring.errors.KeyringLocked: Failed to unlock the collection! at command line jrnl fails if password exists in keyring, but retrieval fails for any reason Aug 16, 2020
@wren wren changed the title jrnl fails if password exists in keyring, but retrieval fails for any reason Error if password exists in keyring, but retrieval fails for any reason Aug 16, 2020
@wren wren closed this as completed in #1138 Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📌 This can't go stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants