Compare commits

..

No commits in common. "e7b55be73a93b8dfe1e036f16c3350447b27070e" and "007b39ea14629af7e4d12d7349b49a48c3a2488a" have entirely different histories.

View File

@ -1,36 +1,22 @@
#!/bin/bash #!/bin/bash
# Create an empty file with the correct owner FOR ITS LOCATION.
# under /docker/containers/<app>/ -> app data, owned by the docker install
# user -> create via runFileOp.
# anywhere else -> manager control plane -> runInstallOp
# (the current/manager user).
# Creating the file directly as the right owner avoids chown-to-another-user,
# which needs real root and isn't available to the unprivileged runtime.
# $2 (user_name) is kept for call-site compatibility but is now advisory — the
# path decides the owner, so a stale hint (e.g. passing the manager user for a
# file that lives under containers/) no longer lands the file with the wrong
# owner. Parent dirs are created with the same owner.
createTouch() createTouch()
{ {
local file="$1" local file="$1"
local user_name="$2" # advisory; location determines the real owner local user_name="$2"
local silent_flag="$3" local silent_flag="$3"
local clean_file=$(echo "$file" | sed 's#//*#/#g') local file_name=$(basename "$file")
local file_name=$(basename "$clean_file") local file_dir=$(dirname "$file")
local file_dir=$(dirname "$clean_file") local clean_dir=$(echo "$file" | sed 's#//*#/#g')
local op="runInstallOp"
if [[ "$clean_file" == "$containers_dir"* || "$clean_file" == /docker/containers/* ]]; then
op="runFileOp"
fi
if [ "$silent_flag" == "silent" ]; then if [ "$silent_flag" == "silent" ]; then
$op mkdir -p "$file_dir" 2>/dev/null runFileOp touch "$clean_dir"
$op touch "$clean_file" runFileOp chown $user_name:$user_name "$file"
else else
local result=$($op mkdir -p "$file_dir") local result=$(runFileOp touch "$clean_dir")
local result=$($op touch "$clean_file")
checkSuccess "Touching $file_name" checkSuccess "Touching $file_name"
local result=$(runFileOp chown $user_name:$user_name "$file")
checkSuccess "Updating $file_name with $user_name ownership"
fi fi
} }