changeset 7a48158d56c3 in /home/hg/repos/gajim
author: Yann Leboulanger <asterix(a)lagaule.org>
branches:
details:http://hg.gajim.org/gajim?cmd=changeset;node=7a48158d56c3
description: correctly detect that key is not trusted before encrypting. Doc says: "gpg just prints a message to the console, but does not provide a specific error indication that the Python wrapper can use." Fixes #8040. See #8041
diffstat:
src/common/gnupg.py | 5 ++++-
src/common/gpg.py | 10 +++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diffs (45 lines):
diff -r 1b7cd2956f67 -r 7a48158d56c3 src/common/gnupg.py
--- a/src/common/gnupg.py Tue Jul 28 20:19:19 2015 +0200
+++ b/src/common/gnupg.py Wed Jul 29 22:32:02 2015 +0200
@@ -1094,7 +1094,7 @@
getattr(result, keyword)(L)
return result
- def list_keys(self, secret=False):
+ def list_keys(self, secret=False, keys=None):
""" list the keys currently in the keyring
>>> import shutil
@@ -1116,6 +1116,9 @@
which='secret-keys'
args = ["--list-%s" % which, "--fixed-list-mode", "--fingerprint",
"--with-colons"]
+ if keys:
+ for key in keys:
+ args.append(key)
p = self._open_subprocess(args)
return self._get_list_output(p, 'list')
diff -r 1b7cd2956f67 -r 7a48158d56c3 src/common/gpg.py
--- a/src/common/gpg.py Tue Jul 28 20:19:19 2015 +0200
+++ b/src/common/gpg.py Wed Jul 29 22:32:02 2015 +0200
@@ -54,12 +54,16 @@
for key in recipients:
if key not in self.always_trust:
trust = False
+ if not trust:
+ # check that we'll be able to encrypt
+ result = super(GnuPG, self).list_keys(recipients,
+ keys=recipients)
+ for key in result:
+ if key['trust'] not in ('f', 'u'):
+ return '', 'NOT_TRUSTED'
result = super(GnuPG, self).encrypt(str_, recipients,
always_trust=trust, passphrase=self.passphrase)
- if result.status == 'invalid recipient':
- return '', 'NOT_TRUSTED'
-
if result.ok:
error = ''
else:
changeset 89fb94925f32 in /home/hg/repos/gajim
author: Yann Leboulanger <asterix(a)lagaule.org>
branches:
details:http://hg.gajim.org/gajim?cmd=changeset;node=89fb94925f32
description: if config file says password is saved with libsecret (with py3 branch) we can still get it with gnomekeyring
diffstat:
src/common/passwords.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (23 lines):
diff -r f583d7b71314 -r 89fb94925f32 src/common/passwords.py
--- a/src/common/passwords.py Fri Jul 24 21:30:14 2015 +0200
+++ b/src/common/passwords.py Fri Jul 24 21:53:58 2015 +0200
@@ -49,8 +49,8 @@
class SimplePasswordStorage(PasswordStorage):
def get_password(self, account_name):
passwd = gajim.config.get_per('accounts', account_name, 'password')
- if passwd and (passwd.startswith('gnomekeyring:') or \
- passwd == '<kwallet>'):
+ if passwd and (passwd.startswith('gnomekeyring:') or passwd.startswith('libsecret:') or \
+ passwd == '<kwallet>'):
# this is not a real password, it's either a gnome
# keyring token or stored in the KDE wallet
return None
@@ -79,7 +79,7 @@
conf = gajim.config.get_per('accounts', account_name, 'password')
if conf is None or conf == '<kwallet>':
return None
- if not conf.startswith('gnomekeyring:'):
+ if not (conf.startswith('gnomekeyring:') or conf.startswith('libsecret')):
password = conf
## migrate the password over to keyring
try: