LibrePortal/scripts/backup/manifest/manifest_write.sh
librelad 7acfdabbac refactor(de-sudo): backup subsystem data ops via runFileOp/runFileWrite
The backup engine already drops to the backup user (sudo -E -u
$docker_install_user) and backupLocationOwner == $docker_install_user, which is
exactly what runFileOp/runFileWrite resolve to in both modes. So convert the
raw-sudo data ops (mkdir/chmod/rm/find/cat/grep/mv/chown/tee on backup repos,
location configs, keys, manifests) to runFileOp/runFileWrite — creating files
as the owner directly, no root chown. backup_verify creates its scratch as the
backup user (runFileOp mktemp) instead of chown-after. Binary installs
(kopia tar/install, borg dnf) -> runSystem. The 44 sudo -u engine drops stay
(already least-privilege; the scoped sudoers will grant them).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-24 17:01:05 +01:00

31 lines
819 B
Bash

#!/bin/bash
manifestWrite()
{
local app_name="$1"
local app_dir="$containers_dir$app_name"
local manifest_path="$app_dir/.libreportal-manifest.json"
if [[ ! -d "$app_dir" ]]; then
isError "Cannot write manifest — $app_dir does not exist"
return 1
fi
local manifest
manifest=$(manifestCollect "$app_name")
echo "$manifest" | runFileWrite "$manifest_path" >/dev/null
runFileOp chown "$docker_install_user":"$docker_install_user" "$manifest_path"
runFileOp chmod 0644 "$manifest_path"
local sha
sha=$(echo "$manifest" | sha256sum | cut -c1-12)
echo "$sha"
}
manifestRemove()
{
local app_name="$1"
local manifest_path="$containers_dir$app_name/.libreportal-manifest.json"
[[ -f "$manifest_path" ]] && runFileOp rm -f "$manifest_path"
}