[elbe-devel] [PATCH v2] egpg: use gpg executable to export keys
Torben Hohn
torben.hohn at linutronix.de
Thu Apr 4 10:03:48 CEST 2019
On Thu, Apr 04, 2019 at 09:44:19AM +0200, Manuel Traut wrote:
> The python-gpg bindings return the exported key in the keybox format.
> python-pyme seemed to return it in gpg format.
>
> The key is needed in gpg format for apt-key add.
>
> I see now method to export the key in gpg format with python-gpg.
typo ^^^ "no"
> Therefore call the 'gpg' command to export they key.
>
> Signed-off-by: Manuel Traut <manut at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
>
> changes since v1: use shellhelper, and fshelper
>
> elbepack/egpg.py | 15 ++-------------
> elbepack/repomanager.py | 8 +++-----
> 2 files changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/elbepack/egpg.py b/elbepack/egpg.py
> index 7c3827cf..1da1553c 100644
> --- a/elbepack/egpg.py
> +++ b/elbepack/egpg.py
> @@ -216,17 +216,6 @@ def generate_elbe_internal_key():
>
>
> def export_key(fingerprint, outfile):
> - os.environ['GNUPGHOME'] = "/var/cache/elbe/gnupg"
> - ctx = core.Context()
> - ctx.set_armor(True)
> -
> - try:
> - outdata = core.Data()
> - ctx.op_export(fingerprint, 0, outdata)
> - outdata.seek(0, os.SEEK_SET)
> - key = outdata.read()
> - outfile.write(key)
> - except Exception:
> - print("Error exporting key %s" % (fingerprint))
> -
> + system("/usr/bin/gpg -a -o %s --export %s" % (outfile, fingerprint),
> + env_add={"GNUPGHOME": "/var/cache/elbe/gnupg"})
> return '/var/cache/elbe/gnupg/pubring.kbx'
> diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
> index 19a481ab..8898d4d2 100644
> --- a/elbepack/repomanager.py
> +++ b/elbepack/repomanager.py
> @@ -159,11 +159,9 @@ class RepoBase(object):
> fp.write("\n")
> fp.close()
>
> - with self.fs.open("repo.pub", "w") as pubkey_fp:
> - keyring = export_key(self.keyid, pubkey_fp)
> - if keyring:
> - shutil.copyfile(keyring, os.path.join(self.fs.path,
> - "elbe-keyring.gpg"))
> + keyring = export_key(self.keyid, self.fs.fname("/repo.pub"))
> + if keyring:
> + shutil.copyfile(keyring, self.fs.fname("/elbe-keyring.gpg"))
>
> if need_update:
> self.log.do(
> --
> 2.20.1
>
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20190404/b79d0453/attachment.sig>
More information about the elbe-devel
mailing list