From 38ad89e39e5e756ce1749682331fcbe168d35bea Mon Sep 17 00:00:00 2001 From: Chumper Date: Sat, 19 Mar 2022 00:00:05 +0100 Subject: [PATCH 1/3] refactor: replace symlink with simple shell wrapper --- src/usr/local/buildpack/utils/linking.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/usr/local/buildpack/utils/linking.sh b/src/usr/local/buildpack/utils/linking.sh index c6421e5516..dcd30c785a 100644 --- a/src/usr/local/buildpack/utils/linking.sh +++ b/src/usr/local/buildpack/utils/linking.sh @@ -36,5 +36,11 @@ function link_wrapper () { SOURCE=$SOURCE/${1} fi check_command "$SOURCE" - ln -sf "$SOURCE" "$TARGET" + cat > "$TARGET" <<- EOM +#!/bin/bash + +${SOURCE} "\$@" +EOM + # make it writable for the owner and the group + chmod 775 "$FILE" } From 96cfcbe4f8e4f74eb2d3e99f36d0f5468c0f1d53 Mon Sep 17 00:00:00 2001 From: Chumper Date: Sat, 19 Mar 2022 00:06:09 +0100 Subject: [PATCH 2/3] fix: chmod on correct path --- src/usr/local/buildpack/utils/linking.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/local/buildpack/utils/linking.sh b/src/usr/local/buildpack/utils/linking.sh index dcd30c785a..4dac9bb99a 100644 --- a/src/usr/local/buildpack/utils/linking.sh +++ b/src/usr/local/buildpack/utils/linking.sh @@ -42,5 +42,5 @@ function link_wrapper () { ${SOURCE} "\$@" EOM # make it writable for the owner and the group - chmod 775 "$FILE" + chmod 775 "$TARGET" } From e6c0c60b63872cbeca325ac6e4eb39189f54cd82 Mon Sep 17 00:00:00 2001 From: Chumper Date: Sat, 19 Mar 2022 00:25:49 +0100 Subject: [PATCH 3/3] fix: only set 775 if we are the owner --- src/usr/local/buildpack/utils/linking.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/usr/local/buildpack/utils/linking.sh b/src/usr/local/buildpack/utils/linking.sh index 4dac9bb99a..a71100b55c 100644 --- a/src/usr/local/buildpack/utils/linking.sh +++ b/src/usr/local/buildpack/utils/linking.sh @@ -20,8 +20,10 @@ fi ${1} "\$@" EOM - # make it writable for the owner and the group - chmod 775 "$FILE" + if [[ -O "$FILE" ]] && [ "$(stat --format '%a' "${FILE}")" -ne 775 ] ; then + # make it writable for the owner and the group only if we are the owner + chmod 775 "$FILE" + fi } # use this for simple symlink to /usr/local/bin @@ -41,6 +43,8 @@ function link_wrapper () { ${SOURCE} "\$@" EOM - # make it writable for the owner and the group - chmod 775 "$TARGET" + if [[ -O "$TARGET" ]] && [ "$(stat --format '%a' "${TARGET}")" -ne 775 ] ; then + # make it writable for the owner and the group only if we are the owner + chmod 775 "$TARGET" + fi }