[elbe-devel] [PATCH v2] Work around a pyme.core.Data init bug

Manuel Traut manut at linutronix.de
Fri Mar 15 15:50:44 CET 2019


Hi Bastian,

first of all thanks for this bugfix!

On 15:28 Fri 15 Mar     , bage at linutronix.de wrote:
> From: Bastian Germann <bage at linutronix.de>
> 
> pyme, which is used in Debian jessie (initvm) has a long standing bug which is
> documented at https://sourceforge.net/p/pyme/bugs/9/
> 
> Unfortunately this was never fixed in Debian, so work around the bug by not
> using the pyme.core.Data(file=filedescriptor) constructor.
> pyme.core.Data(file=filename) is fine for reading data; it cannot be used for
> writing.

i would prefer a commit message that is more related to elbe.

This is just a rough example that you get an idea

gpg/projrepo/pbuilder: fix building packages with dependencies stored in project
repo

f8dd2f15f57efa84ebae1b89458c4d83ecb40e15 switched from using
gpgme to pyme. However pyme has an upstream bug:

...yourmessage...

This caused that the public key of the projectrepo was not exported. And
pbuilder refused to install build-dependencies from the projectrepo.



> Signed-off-by: Bastian Germann <bage at linutronix.de>
> ---
>  elbepack/egpg.py | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/elbepack/egpg.py b/elbepack/egpg.py
> index 019cdefa..32b07402 100644
> --- a/elbepack/egpg.py
> +++ b/elbepack/egpg.py
> @@ -167,8 +167,12 @@ def sign(infile, outfile, fingerprint):
>  
>      try:
>          indata = core.Data(file=infile)
> -        outdata = core.Data(file=outfile)
> +        outdata = core.Data()
>          ctx.op_sign(indata, outdata, sig.mode.NORMAL)
> +        outdata.seek(0, os.SEEK_SET)
> +        signature = outdata.read()
> +        with open(outfile, 'w') as fd:
> +            fd.write(signature)
>      except Exception as ex:
>          print("Error signing file %s" % ex.message)
>  
> @@ -177,9 +181,7 @@ def sign_file(fname, fingerprint):
>      outfilename = fname + '.gpg'
>  
>      try:
> -        with open(fname, 'r') as infile:
> -            with open(outfilename, 'w') as outfile:
> -                sign(infile, outfile, fingerprint)
> +        sign(fname, outfilename, fingerprint)
>      except Exception as ex:
>          print("Error signing file %s" % ex.message)
>  
> @@ -210,7 +212,11 @@ def export_key(fingerprint, outfile):
>      ctx.set_armor(True)
>  
>      try:
> -        ctx.op_export(fingerprint, 0, outfile)
> +        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))
>  
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list