Skip to content

Commit

Permalink
FIXUP: redirect stderr when debug=True or sys.dangerzone_dev == True
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Oct 8, 2024
1 parent 55b170b commit 12fa830
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dangerzone/isolation_provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ class IsolationProvider(ABC):

def __init__(self, debug) -> None:
self.debug = debug
if self.debug:
if self.should_display_errors():
self.proc_stderr = subprocess.PIPE
else:
# We do not trust STDERR from the inner container,
# which could be exploited to ask users to open the document with
# a default PDF reader for instance.
self.proc_stderr = subprocess.DEVNULL

def should_display_errors(self) -> bool:
return self.debug or getattr(sys, "dangerzone_dev", False)

@abstractmethod
def install(self) -> bool:
pass
Expand Down Expand Up @@ -146,7 +149,7 @@ def doc_to_pixels(
text = "Converted document to pixels"
self.print_progress(document, False, text, percentage)

if self.debug:
if self.should_display_errors():
assert p.stderr
debug_log = read_debug_text(p.stderr, MAX_CONVERSION_LOG_CHARS)
p.stderr.close()
Expand Down

0 comments on commit 12fa830

Please sign in to comment.