sudo-rs — the default sudo from Ubuntu 25.10, so on 26.04 — does not
implement bare -E. It does not reject it either: it warns to stderr
("preserving the entire environment is not supported, '-E' is ignored")
and runs the command with the environment DROPPED, leaving the exit
status untouched. Callers capture stderr, so the warning is invisible and
the backup engines simply never receive RESTIC_PASSWORD / BORG_PASSPHRASE
/ KOPIA_PASSWORD and cannot open the repository.
Name the nine vars explicitly via --preserve-env=<list>, which sudo-rs
and classic sudo (>=1.8.21, so Debian 10's 1.8.27) both honour, so this
needs no version gate. The list is cross-checked against every
RESTIC_/BORG_/KOPIA_ var the engine env scripts export.
The list lives in variables.sh with a literal fallback in runBackupOp,
because init.sh sources run_privileged.sh directly during install without
ever loading variables.sh — an unguarded empty list would silently
reproduce the same dropped-credential bug.
restoreFirstRunDiscover now goes through runBackupOp rather than issuing
its own sudo. It was the only backup-engine call bypassing that funnel,
which is why it missed this fix by construction; routing it back also
gives it the -H that keeps restic's cache under the backup user's HOME.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
restoreFirstRunDiscover()
|
|
{
|
|
local idx="$1"
|
|
|
|
if ! resticLocationEnabled "$idx"; then
|
|
isError "Location $idx is not enabled"
|
|
return 1
|
|
fi
|
|
|
|
resticEnvExport "$idx" || return 1
|
|
# Via runBackupOp rather than its own sudo: this was the one backup-engine
|
|
# call bypassing that funnel, so it silently missed the -E fix for sudo-rs
|
|
# (and the -H that puts restic's cache under the backup user's HOME).
|
|
runBackupOp restic snapshots --tag engine=libreportal --json --no-lock 2>/dev/null
|
|
local rc=$?
|
|
resticEnvUnset
|
|
return $rc
|
|
}
|
|
|
|
restoreFirstRunBulk()
|
|
{
|
|
local idx="$1"
|
|
local source_host="$2"
|
|
shift 2
|
|
local apps_to_restore=("$@")
|
|
|
|
if [[ ${#apps_to_restore[@]} -eq 0 ]]; then
|
|
isError "No apps specified for bulk first-run restore"
|
|
return 1
|
|
fi
|
|
|
|
isHeader "First-run bulk restore from $(resticLocationName "$idx") (host=$source_host)"
|
|
|
|
for app in "${apps_to_restore[@]}"; do
|
|
restoreAppStart "$app" "latest" "$idx" "$source_host"
|
|
done
|
|
|
|
isSuccessful "First-run restore complete — ${#apps_to_restore[@]} apps restored"
|
|
}
|