From 51bee645ed676ed82266f21e9ac227f404c4a5e9 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 21 Jun 2021 12:39:53 -0700 Subject: [PATCH] Explicitly set the container_tech to either "docker" or "podman" --- dangerzone/container.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dangerzone/container.py b/dangerzone/container.py index b9b88a9..0b57eaa 100644 --- a/dangerzone/container.py +++ b/dangerzone/container.py @@ -8,11 +8,18 @@ import os # What is the container runtime for this platform? if platform.system() == "Darwin": - container_runtime = "/usr/local/bin/docker" + container_tech = "docker" + container_runtime = shutil.which("docker") elif platform.system() == "Windows": + container_tech = "docker" container_runtime = shutil.which("docker.exe") -else: +elif platform.system() == "Linux": + container_tech = "podman" container_runtime = shutil.which("podman") +else: + print("Unknown operating system, defaulting to Docker") + container_tech = "docker" + container_runtime = shutil.which("docker") # Define startupinfo for subprocesses if platform.system() == "Windows": @@ -84,8 +91,8 @@ def documenttopixels(document_filename, pixel_dir, container_name): """docker run --network none -v [document_filename]:/tmp/input_file -v [pixel_dir]:/dangerzone [container_name] document-to-pixels""" args = ["run", "--network", "none"] - # Linux uses podman instead of docker, and only docker uses --security-opt - if platform.system() != "Linux": + # docker uses --security-opt, podman doesn't + if container_tech == "docker": args += ["--security-opt=no-new-privileges:true"] args += [