The old copy/move helpers ran 'sudo cp/mv X Y; sudo chown $user_name Y' (root + arbitrary chown). Rework them to write AS the destination's owner — no root, no chown — classifying by dest path like createTouch: /docker/containers/<app> -> runFileOp (docker install user), manager-owned control plane -> runInstallOp. The $user_name arg is now advisory (the path decides). Covers copyFile/copyFiles/ copyFolder/copyFolders/moveFile; copyResource is always containers -> runFileOp; createFolders' non-container branch -> runInstallOp; updateFileOwnership (an arbitrary user1:user2 chown) -> runSystem. Confirmed by callers (containers vs $docker_dir/backup_install_dir/configs dests). Removes a class of root data ops + arbitrary-chown from the runtime. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
14 lines
344 B
Bash
Executable File
14 lines
344 B
Bash
Executable File
#!/bin/bash
|
|
|
|
updateFileOwnership()
|
|
{
|
|
local file="$1"
|
|
local file_name=$(basename "$file")
|
|
local clean_dir=$(echo "$file" | sed 's#//*#/#g')
|
|
local user_name_1="$2"
|
|
local user_name_2="$3"
|
|
|
|
local result=$(runSystem chown $user_name_1:$user_name_2 "$file")
|
|
checkSuccess "Updating $file_name with $user_name ownership"
|
|
}
|