cmdlib: change perms on overlay dir copy when stripping bits
Follow-up to The cosa bash alias mounts the source config
read-only, so we can't modify those files. Let's just copy it to a
tmpdir instead to avoid touching the source config repo.
Reported-by: Dusty Mabe
@@ -267,13 +267,13 @@ commit_overlay() {
name=$1
path=$2
respath=$(realpath "${path}")
- # Only keep write bit for owner for all overlay files/dirs. This modifies
- # the source config, but meh... git doesn't track it anyway and it's easier
- # than using ostree's --statoverride when dealing with executable files.
- # See: https://github.com/ostreedev/ostree/issues/2368
- chmod -cR go-w "${respath}"
+ # Only keep write bit for owner for all overlay files/dirs. We copy it over
+ # but with the umask we want so the perms are dropped. This is easier than
+ # using ostree's --statoverride when dealing with executable files. See:
+ # https://github.com/ostreedev/ostree/issues/2368
+ rm -rf "${TMPDIR}/overlay" && (umask 0022 && cp -r "${respath}" "${TMPDIR}/overlay")
echo -n "Committing ${name}: ${path} ... "
- ostree commit --repo="${tmprepo}" --tree=dir="${respath}" -b "${name}" \
+ ostree commit --repo="${tmprepo}" --tree=dir="${TMPDIR}/overlay" -b "${name}" \
--owner-uid 0 --owner-gid 0 --no-xattrs --no-bindings --parent=none \
--mode-ro-executables --timestamp "${git_timestamp}"
}
