diff --git a/src/usr/local/buildpack/utils/linking.sh b/src/usr/local/buildpack/utils/linking.sh index c6421e551..a71100b55 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 @@ -36,5 +38,13 @@ function link_wrapper () { SOURCE=$SOURCE/${1} fi check_command "$SOURCE" - ln -sf "$SOURCE" "$TARGET" + cat > "$TARGET" <<- EOM +#!/bin/bash + +${SOURCE} "\$@" +EOM + 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 }