From 678ee7743fef0d78803e802bc18660f8d173b2d9 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 22 Nov 2024 08:29:34 -0500 Subject: [PATCH] cmdlib.sh: only chown `compose.json` if it exists It only gets actually written in `cosa build`, so we need to handle the `cosa fetch` case where this path is also taken. Fixes 40a2027e8 ("cmdlib: also chown back `compose.json` in privileged path"). --- src/cmdlib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmdlib.sh b/src/cmdlib.sh index da20efa7f8..070d4d8ec8 100755 --- a/src/cmdlib.sh +++ b/src/cmdlib.sh @@ -566,7 +566,9 @@ runcompose_tree() { # with a consistent value, regardless of the environment (umask 0022 && sudo -E "$@") sudo chown -R -h "${USER}":"${USER}" "${tmprepo}" - sudo chown "${USER}":"${USER}" "${composejson}" + if [ -f "${composejson}" ]; then + sudo chown "${USER}":"${USER}" "${composejson}" + fi else runvm_with_cache -- "$@" --repo "${repo}" --write-composejson-to "${composejson}" fi