mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Add Qubes RPC calls
Add two RPC calls that can run on disposable VMs: * dz.Convert: This call simply imports the dangerzone package and runs the Qubes wrapper for the "document to pixels" code. This call is similar to the way we run the conversion part in a container. * dz.ConvertDev: This call is for development purposes, and does the following: - First it receives the `dangerzone.conversion` module as Python zipfile. This way, we can quickly iterate on changes on the server-side part of Qubes, without altering the templates. - Second, it calls the Qubes wrapper for the "document to pixels" code, as dz.Convert does.
This commit is contained in:
parent
a83f5dfc7a
commit
c194606550
2 changed files with 44 additions and 0 deletions
2
qubes/dz.Convert
Executable file
2
qubes/dz.Convert
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
python -m dangerzone.conversion.doc_to_pixels_qubes_wrapper
|
42
qubes/dz.ConvertDev
Executable file
42
qubes/dz.ConvertDev
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
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())
|
Loading…
Reference in a new issue