Allow docker installed from snap package

This commit is contained in:
Micah Lee 2020-10-26 15:11:41 -07:00
parent 31b63e5471
commit 92b19fe1b3
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
2 changed files with 17 additions and 4 deletions

View file

@ -1,3 +1,4 @@
import os
import platform
import tempfile
@ -8,16 +9,27 @@ class Common(object):
"""
def __init__(self):
# Temporary directory to store pixel data
# Note in macOS, temp dirs must be in /tmp (or a few other paths) for Docker to mount them
# Temporary directory to store pixel data and safe PDFs
if platform.system() == "Windows":
self.pixel_dir = tempfile.TemporaryDirectory(prefix="dangerzone-pixel-")
self.safe_dir = tempfile.TemporaryDirectory(prefix="dangerzone-safe-")
else:
elif platform.system() == "Darwin":
# In macOS, temp dirs must be in /tmp (or a few other paths) for Docker to mount them
self.pixel_dir = tempfile.TemporaryDirectory(
prefix="/tmp/dangerzone-pixel-"
)
self.safe_dir = tempfile.TemporaryDirectory(prefix="/tmp/dangerzone-safe-")
else:
# In Linux, temp dirs must be in the homedir for the snap package version of Docker to mount them
cache_dir = os.path.expanduser("~/.cache/dangerzone")
os.makedirs(cache_dir, exist_ok=True)
self.pixel_dir = tempfile.TemporaryDirectory(
prefix=os.path.join(cache_dir, "pixel-")
)
self.safe_dir = tempfile.TemporaryDirectory(
prefix=os.path.join(cache_dir, "safe-")
)
print(
f"Temporary directories created, dangerous={self.pixel_dir.name}, safe={self.safe_dir.name}"
)

View file

@ -4,6 +4,7 @@ import subprocess
import sys
import pipes
import getpass
import shutil
# What is the container runtime for this platform?
if platform.system() == "Darwin":
@ -11,7 +12,7 @@ if platform.system() == "Darwin":
elif platform.system() == "Windows":
container_runtime = "C:\\Program Files\\Docker\\Docker\\resources\\bin\\docker.exe"
else:
container_runtime = "/usr/bin/docker"
container_runtime = shutil.which("docker")
# Define startupinfo for subprocesses
if platform.system() == "Windows":