remail/gpg: Use the lists private key for signing

Konstantin reported that outgoing mail from a mailing list is signed with
the default private key found in the private keyring.

That's caused by just handing boolen True into the 'sign' argument of
gpg_encrypt() while the documentation clearly says:

  sign (defaults to None)
    Either the Boolean value True, or the fingerprint of a key which is
    used to sign the encrypted data. If True is specified, the default key
    is used for signing. When not specified, the data is not signed.

Hand the list account fingerprint in if signing is enabled in the
configuration.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Reviewed-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
This commit is contained in:
Thomas Gleixner 2020-02-18 21:40:36 +01:00
parent 9b0ec00c8f
commit fc918a9bef

View file

@ -89,9 +89,14 @@ class gpg_crypt(object):
def do_encrypt(self, payload, fingerprints): def do_encrypt(self, payload, fingerprints):
''' Common encryption helper''' ''' Common encryption helper'''
if self.config.sign:
signit = self.account.fingerprint
else:
signit = None
enc = self.gpg.encrypt(payload, fingerprints, armor=self.config.armor, enc = self.gpg.encrypt(payload, fingerprints, armor=self.config.armor,
always_trust=self.config.always_trust, always_trust=self.config.always_trust,
sign=self.config.sign) sign=signit)
if enc.ok: if enc.ok:
return str(enc) return str(enc)
raise RemailGPGException('Encryption fail: %s' % enc.status) raise RemailGPGException('Encryption fail: %s' % enc.status)