Skip to content

Commit

Permalink
Containers: remove debug messages (via files)
Browse files Browse the repository at this point in the history
Remove container_log messages ahead of debug info being sent over
standard streams.
  • Loading branch information
deeplow authored and apyrgio committed Jan 31, 2024
1 parent 0e4c83d commit 4631f0e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
4 changes: 0 additions & 4 deletions dangerzone/conversion/doc_to_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,6 @@ async def main() -> int:
except Exception as e:
converter.update_progress(str(e), error=True)
error_code = errors.UnexpectedConversionError.error_code
if not running_on_qubes():
# Write debug information (containers version)
with open("/tmp/dangerzone/captured_output.txt", "wb") as container_log:
container_log.write(converter.captured_output)
return error_code


Expand Down
11 changes: 2 additions & 9 deletions dangerzone/conversion/pixels_to_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,10 @@ async def main() -> int:

try:
await converter.convert(ocr_lang)
error_code = 0 # Success!

return 0
except (RuntimeError, TimeoutError, ValueError) as e:
converter.update_progress(str(e), error=True)
error_code = 1

if not running_on_qubes():
# Write debug information (containers version)
with open("/safezone/captured_output.txt", "wb") as container_log:
container_log.write(converter.captured_output)
return error_code
return 1


if __name__ == "__main__":
Expand Down
18 changes: 0 additions & 18 deletions dangerzone/isolation_provider/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,6 @@ def _convert_with_tmpdirs(
]
ret = self.exec_container(document, command, extra_args)

if getattr(sys, "dangerzone_dev", False):
log_path = pixel_dir / "captured_output.txt"
with open(log_path, "r", encoding="ascii", errors="replace") as f:
untrusted_log = f.read(MAX_CONVERSION_LOG_CHARS)
log.info(
f"Conversion output (doc to pixels):\n{self.sanitize_conversion_str(untrusted_log)}"
)

if ret != 0:
log.error("documents-to-pixels failed")

Expand Down Expand Up @@ -348,16 +340,6 @@ def _convert_with_tmpdirs(
# We did it
success = True

if getattr(sys, "dangerzone_dev", False):
log_path = safe_dir / "captured_output.txt"
if log_path.exists(): # If first stage failed this may not exist
with open(log_path, "r", encoding="ascii", errors="replace") as f:
text = (
f"Container output: (pixels to PDF)\n"
f"{PIXELS_TO_PDF_LOG_START}\n{f.read()}{PIXELS_TO_PDF_LOG_END}"
)
log.info(text)

return success

def get_max_parallel_conversions(self) -> int:
Expand Down

0 comments on commit 4631f0e

Please sign in to comment.