dangerzone/qubes/dz.ConvertDev
Alex Pyrgiotis c4c46a0a8d
Small fixes for Qubes PRM
This commit fixes 3 small issues with the way we produce our Qubes RPM:

1. The `.exists()` method follows symlinks by default, whereas we want
   to check if a symlink exists. This functionality has been added in
   Python
   3.12.

   Instead of checking if a symlink exists and then removing it, simply
   remove it and don't throw an error if it doesn't exist in the first
   place.

2. The `dz.Convert*` policies were not installed with the executable bit
   set, therefore the qube could not start.

3. The `dz.ConvertDev` policy in particular had an ambiguous shebang,
   thus we change it to explicitly call Python3
2023-10-11 15:54:06 +01:00

42 lines
919 B
Python
Executable file

#!/usr/bin/env 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_qubes_wrapper import main
return asyncio.run(main())
if __name__ == "__main__":
sys.exit(main())