[elbe-devel] [PATCH 07/10] egpg: use gpg executable to export keys
Torben Hohn
torben.hohn at linutronix.de
Wed Apr 3 18:04:05 CEST 2019
On Wed, Apr 03, 2019 at 12:34:55PM +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.
> Therefore call the 'gpg' command to export they key.
>
> Signed-off-by: Manuel Traut <manut at linutronix.de>
> ---
> elbepack/egpg.py | 15 ++-------------
> elbepack/repomanager.py | 10 +++++-----
> 2 files changed, 7 insertions(+), 18 deletions(-)
>
> diff --git a/elbepack/egpg.py b/elbepack/egpg.py
> index 6b66b004..86da1e00 100644
> --- a/elbepack/egpg.py
> +++ b/elbepack/egpg.py
> @@ -220,17 +220,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))
> -
> + run(["/usr/bin/gpg", "-a", "-o", outfile,
> + "--export", fingerprint], env={"GNUPGHOME": "/var/cache/elbe/gnupg"})
dont use run... use elbepack.shellhelper.system()
> return '/var/cache/elbe/gnupg/pubring.kbx'
> diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
> index 19a481ab..4fb9361d 100644
> --- a/elbepack/repomanager.py
> +++ b/elbepack/repomanager.py
> @@ -159,11 +159,11 @@ 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, os.path.join(self.fs.path,
> + "repo.pub"))
self.fs.fname("/repo.pub")
> + if keyring:
> + shutil.copyfile(keyring, os.path.join(self.fs.path,
> + "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/20190403/4f681203/attachment.sig>
More information about the elbe-devel
mailing list