[elbe-devel] [PATCH 2/2] elbepack: egpg: properly read returned plaintext data
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Mon Apr 29 14:37:09 CEST 2024
The gpg.core.Data() object does not automatically create nonexistent
files (anymore?).
Explicitly read the output data.
Closes: https://github.com/Linutronix/elbe/issues/383
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/egpg.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/elbepack/egpg.py b/elbepack/egpg.py
index f7af65bf9d1d..0cedf8b5465a 100644
--- a/elbepack/egpg.py
+++ b/elbepack/egpg.py
@@ -4,6 +4,7 @@
import logging
import os
+import shutil
import subprocess
from gpg import core
@@ -159,10 +160,10 @@ def unsign_file(fname):
try:
infile = core.Data(file=fname)
- outfile = core.Data(file=outfilename)
except (GPGMEError, ValueError) as E:
print(f'Error: Opening file {fname} or {outfilename} - {E}')
else:
+ outfile = core.Data()
# obtain signature and write unsigned file
ctx.op_verify(infile, None, outfile)
vres = ctx.op_verify_result()
@@ -174,6 +175,10 @@ def unsign_file(fname):
if overall_status.to_exitcode():
return None
+ with open(outfilename, 'wb') as f:
+ outfile.seek(0, os.SEEK_SET)
+ shutil.copyfileobj(outfile, f)
+
return outfilename
return None
--
2.44.0
More information about the elbe-devel
mailing list