diff --git a/10.0/build/root/usr/bin/fix-permissions b/10.0/build/root/usr/bin/fix-permissions index 8fcd46aee..ddd33ace9 100755 --- a/10.0/build/root/usr/bin/fix-permissions +++ b/10.0/build/root/usr/bin/fix-permissions @@ -1,8 +1,27 @@ #!/bin/sh -# Fix permissions on the given directory to allow owner/group read/write of + +# Allow this script to fail without failing a build +set +e + +SYMLINK_OPT=${2:--L} + +# Fix permissions on the given directory or file to allow group read/write of # regular files and execute of directories. -# Note: Openshift uses random UIDs for running apps. Thus we need to grant -# some world-writable perms :( -chgrp -R 0 $1 -chmod -R og+rw $1 -find $1 -type d -exec chmod g+x {} + + +[ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" + +# If argument does not exist, script will still exit with 0, +# but at least we'll see something went wrong in the log +if ! [ -e "$1" ] ; then + echo "ERROR: File or directory $1 does not exist." >&2 + # We still want to end successfully + exit 0 +fi + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + + +# Always end successfully +exit 0 diff --git a/8.0/runtime/root/usr/bin/fix-permissions b/8.0/runtime/root/usr/bin/fix-permissions index 8fcd46aee..ddd33ace9 100755 --- a/8.0/runtime/root/usr/bin/fix-permissions +++ b/8.0/runtime/root/usr/bin/fix-permissions @@ -1,8 +1,27 @@ #!/bin/sh -# Fix permissions on the given directory to allow owner/group read/write of + +# Allow this script to fail without failing a build +set +e + +SYMLINK_OPT=${2:--L} + +# Fix permissions on the given directory or file to allow group read/write of # regular files and execute of directories. -# Note: Openshift uses random UIDs for running apps. Thus we need to grant -# some world-writable perms :( -chgrp -R 0 $1 -chmod -R og+rw $1 -find $1 -type d -exec chmod g+x {} + + +[ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" + +# If argument does not exist, script will still exit with 0, +# but at least we'll see something went wrong in the log +if ! [ -e "$1" ] ; then + echo "ERROR: File or directory $1 does not exist." >&2 + # We still want to end successfully + exit 0 +fi + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + + +# Always end successfully +exit 0 diff --git a/8.0/runtime/test/run b/8.0/runtime/test/run index 570108727..79fdff3c7 100755 --- a/8.0/runtime/test/run +++ b/8.0/runtime/test/run @@ -98,7 +98,7 @@ test_data_folder() { test_start # check a writable data folder is available - assert_equal $(docker_run $IMAGE_NAME stat -c %a /opt/app-root/data) "777" + assert_equal $(docker_run $IMAGE_NAME stat -c %a /opt/app-root/data) "775" } test_timezones() { diff --git a/9.0/runtime/root/usr/bin/fix-permissions b/9.0/runtime/root/usr/bin/fix-permissions index 8fcd46aee..ddd33ace9 100755 --- a/9.0/runtime/root/usr/bin/fix-permissions +++ b/9.0/runtime/root/usr/bin/fix-permissions @@ -1,8 +1,27 @@ #!/bin/sh -# Fix permissions on the given directory to allow owner/group read/write of + +# Allow this script to fail without failing a build +set +e + +SYMLINK_OPT=${2:--L} + +# Fix permissions on the given directory or file to allow group read/write of # regular files and execute of directories. -# Note: Openshift uses random UIDs for running apps. Thus we need to grant -# some world-writable perms :( -chgrp -R 0 $1 -chmod -R og+rw $1 -find $1 -type d -exec chmod g+x {} + + +[ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)" + +# If argument does not exist, script will still exit with 0, +# but at least we'll see something went wrong in the log +if ! [ -e "$1" ] ; then + echo "ERROR: File or directory $1 does not exist." >&2 + # We still want to end successfully + exit 0 +fi + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} + +find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} + + +# Always end successfully +exit 0 diff --git a/9.0/runtime/test/run b/9.0/runtime/test/run index 4d88c87f2..ee87babed 100755 --- a/9.0/runtime/test/run +++ b/9.0/runtime/test/run @@ -98,7 +98,7 @@ test_data_folder() { test_start # check a writable data folder is available - assert_equal $(docker_run $IMAGE_NAME stat -c %a /opt/app-root/data) "777" + assert_equal $(docker_run $IMAGE_NAME stat -c %a /opt/app-root/data) "775" } test_timezones() {