'local result=$(cmd)' resets $? to 0 (the local builtin's own exit), so the
following checkSuccess always saw success regardless of cmd's real exit — the
mechanism that masked the de-sudo write failures. Split declaration from
assignment ('local result; result=$(cmd)') across all 235 active-code sites
(84 files) so the command's exit reaches checkSuccess. No behaviour change
beyond $? now being accurate (no set -e in runtime code; multi-line
assignments transform safely).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
29 lines
1.1 KiB
Bash
Executable File
29 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
copyFile()
|
|
{
|
|
local silent_flag="$1"
|
|
local file="$2"
|
|
local file_name=$(basename "$file")
|
|
local save_dir="$3"
|
|
local save_dir_file=$(basename "$save_dir")
|
|
local user_name="$4" # advisory — the destination path determines the owner
|
|
local flags="$5"
|
|
local flags_full=""
|
|
[[ "$flags" == "overwrite" ]] && flags_full="-f"
|
|
|
|
# Write as the destination's owner — no root, no chown. Under
|
|
# /docker/containers/<app> that's the docker install user (runFileOp);
|
|
# the manager-owned control plane (configs/logs/etc.) is runInstallOp.
|
|
# Mirrors createTouch's path-based ownership; $user_name is now advisory.
|
|
local op="runInstallOp"
|
|
[[ "$save_dir" == "$containers_dir"* || "$save_dir" == "${LP_CONTAINERS_DIR:-/libreportal-containers}"/* ]] && op="runFileOp"
|
|
|
|
if [ "$silent_flag" == "loud" ]; then
|
|
local result; result=$($op cp $flags_full "$file" "$save_dir")
|
|
checkSuccess "Copying $file_name to $save_dir_file"
|
|
else
|
|
$op cp $flags_full "$file" "$save_dir" >/dev/null 2>&1
|
|
fi
|
|
}
|