mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 09:52:37 +02:00

When building the Dangerzone RPMs, we were seeing the following shebang warnings: + /usr/lib/rpm/redhat/brp-mangle-shebangs mangling shebang in /usr/lib/python3.12/site-packages/dangerzone/conversion/doc_to_pixels.py from /usr/bin/env python3 to #!/usr/bin/python3 mangling shebang in /usr/lib/python3.12/site-packages/dangerzone/conversion/common.py from /usr/bin/env python3 to #!/usr/bin/python3 mangling shebang in /usr/lib/python3.12/site-packages/dangerzone/conversion/pixels_to_pdf.py from /usr/bin/env python3 to #!/usr/bin/python3 mangling shebang in /etc/qubes-rpc/dz.ConvertDev from /usr/bin/env python3 to #!/usr/bin/python3 mangling shebang in /etc/qubes-rpc/dz.Convert from /bin/sh to #!/usr/bin/sh These warnings are benign in nature, but coupled with #727, they could lead to incorrect file permissions. Remove shebangs from the following files, since they are not executed directly, but are imported instead: dangerzone/conversion/common.py dangerzone/conversion/doc_to_pixels.py dangerzone/conversion/pixels_to_pdf.py Also, accept the suggestions by Fedora (/bin/sh -> /usr/bin/sh, /usr/bin/env python3 -> /usr/bin/python3) for the following files: qubes/dz.Convert qubes/dz.ConvertDev Refs #727
42 lines
901 B
Python
Executable file
42 lines
901 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import asyncio
|
|
import glob
|
|
import io
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import zipfile
|
|
|
|
|
|
def say(msg):
|
|
print(msg, file=sys.stderr, flush=True)
|
|
|
|
|
|
def main():
|
|
say("Debugging mode enabled")
|
|
|
|
# Get the size of the zipfile
|
|
size = int.from_bytes(sys.stdin.buffer.read(4))
|
|
say(f"Reading {size} bytes of Python zipfile")
|
|
|
|
# Read the zipfile from stdin
|
|
zf = sys.stdin.buffer.read(size)
|
|
if len(zf) < size:
|
|
say(f"Client closed the connection early")
|
|
return 1
|
|
|
|
with tempfile.NamedTemporaryFile(suffix=".zip") as t:
|
|
say(f"Storing the Python zipfile to {t.name}")
|
|
t.write(zf)
|
|
t.flush()
|
|
|
|
say(f"Importing the conversion module")
|
|
sys.path.insert(0, t.name)
|
|
|
|
from dangerzone.conversion.doc_to_pixels import main
|
|
return asyncio.run(main())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|