actions, backup: Implement raw output for privileged daemon

- Regression: downloading does not work with sudo based action anymore. However,
sudo based actions are to be removed in later patches.

Tests:

- Downloading tar backup archive works. Untar works. Downloading gives upto
10MiB/s speed.

- If API is not called with _raw_output=True, then special exception is raised.

- Downloading tar file from command line using nc also works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa authored and Joseph Nuthalapati committed 2025-09-05 20:23:25 +05:30
1 parent 0aa3ee5a70
commit 143e4a00bd
3 files changed
+47 -11

No files matched your search

+6 -3
View File
@@ -12,7 +12,7 @@ import tarfile
from django.utils.translation import gettext_lazy as _
from plinth import action_utils
from plinth import action_utils, actions
from plinth import app as app_module
from plinth import module_loader
from plinth.actions import privileged, secret_str
@@ -340,8 +340,11 @@ def _extract(archive_path, destination, encryption_passphrase, locations=None):
@privileged
def export_tar(path: str, encryption_passphrase: secret_str | None = None):
"""Export archive contents as tar stream on stdout."""
_run(['borg', 'export-tar', path, '-', '--tar-filter=gzip'],
encryption_passphrase)
env = _get_env(encryption_passphrase)
process = subprocess.Popen(
['borg', 'export-tar', path, '-', '--tar-filter=gzip'], env=env,
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
return actions.ProcessBufferedReader(process)
def _read_archive_file(archive, filepath, encryption_passphrase):