[elbe-devel] [PATCH v2] Work around a pyme.core.Data init bug
bage at linutronix.de
bage at linutronix.de
Fri Mar 15 15:28:22 CET 2019
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.
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
More information about the elbe-devel
mailing list