Skip to content

Commit

Permalink
Fix warning messages when fix-permissions run on a symlink (sclorg#126)
Browse files Browse the repository at this point in the history
* Change permissions only for files for which I have permissions to
do so (to avoid "Operation not permitted" error messages)
  • Loading branch information
omron93 authored and pkubatrh committed Jun 22, 2017
1 parent 91f1519 commit 643a458
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/fix-permissions
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set +e
# Fix permissions on the given directory or file to allow group read/write of
# regular files and execute of directories.

[ $(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
Expand All @@ -14,10 +16,10 @@ if ! [ -e "$1" ] ; then
exit 0
fi

find -L "$1" \! -gid 0 -exec chgrp 0 {} +
find -L "$1" \! -perm -g+rw -exec chmod g+rw {} +
find -L "$1" -perm /u+x -a \! -perm /g+x -exec chmod g+x {} +
find -L "$1" -type d \! -perm /g+x -exec chmod g+x {} +
find -L "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} +
find -L "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} +
find -L "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} +
find -L "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} +

# Always end successfully
exit 0

0 comments on commit 643a458

Please sign in to comment.