Skip to content

Commit

Permalink
fix: create tool folders with 775 for openshift (#305)
Browse files Browse the repository at this point in the history
* fix: create tool folders with 775 for openshift

* fix: us 755 for root, 775 for user tool creation

* fix: tool folders always have 755, version specific umasks

* Update test/bash/filesystem.bats

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* Update src/usr/local/buildpack/utils/filesystem.sh

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

* fix: set root tool path to 755 only

* fix: 755 all the way

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
Chumper and viceice authored Feb 14, 2022
1 parent fd5b636 commit 468f2ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/usr/local/buildpack/utils/filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ function find_versioned_tool_path () {

function create_versioned_tool_path () {
install_dir=$(get_install_dir)
mkdir -p "${install_dir}/${TOOL_NAME}/${TOOL_VERSION}"

local umask=775
if [ "$(is_root)" -eq 0 ]; then
umask=755
fi

# shellcheck disable=SC2174
mkdir -p -m "${umask}" "${install_dir}/${TOOL_NAME}"
mkdir -m "${umask}" "${install_dir}/${TOOL_NAME}/${TOOL_VERSION}"
echo "${install_dir}/${TOOL_NAME}/${TOOL_VERSION}"
}

Expand Down
4 changes: 4 additions & 0 deletions test/bash/filesystem.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ teardown() {

assert_output "${TEST_ROOT_DIR}/user/foo/1.2.3"
assert [ -d "${TEST_ROOT_DIR}/user/foo/1.2.3" ]
assert [ $(stat --format '%a' "${TEST_ROOT_DIR}/user/foo") -eq 775 ]
assert [ $(stat --format '%a' "${TEST_ROOT_DIR}/user/foo/1.2.3") -eq 775 ]
}

@test "can create a versioned tool path as root" {
Expand All @@ -52,6 +54,8 @@ teardown() {

assert_output "${TEST_ROOT_DIR}/root/foo/1.2.3"
assert [ -d "${TEST_ROOT_DIR}/root/foo/1.2.3" ]
assert [ $(stat --format '%a' "${TEST_ROOT_DIR}/root/foo") -eq 755 ]
assert [ $(stat --format '%a' "${TEST_ROOT_DIR}/root/foo/1.2.3") -eq 755 ]
}

@test "finds the versioned tool path" {
Expand Down

0 comments on commit 468f2ea

Please sign in to comment.