Skip to content

Commit 47dd175

Browse files
hhorakpkubatrh
authored andcommitted
Avoid errors when the process does not have enough permissions to change attributes
Closes sclorg#112, closes sclorg#123
1 parent ee76c59 commit 47dd175

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

bin/fix-permissions

+16-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
# Allow this script to fail without failing a build
44
set +e
55

6-
# Fix permissions on the given directory to allow group read/write of
6+
# Fix permissions on the given directory or file to allow group read/write of
77
# regular files and execute of directories.
8-
chgrp -R 0 $1;
9-
find -L $1 -xtype l -exec chgrp 0 {} \;
10-
chmod -R g+rw $1;
11-
find -L $1 -xtype l -exec chmod g+rw {} \;
12-
find $1 -type d -exec chmod g+x {} +
8+
9+
# If argument does not exist, script will still exit with 0,
10+
# but at least we'll see something went wrong in the log
11+
if ! [ -e "$1" ] ; then
12+
echo "ERROR: File or directory $1 does not exist." >&2
13+
# We still want to end successfully
14+
exit 0
15+
fi
16+
17+
find -L "$1" \! -gid 0 -exec chgrp 0 {} +
18+
find -L "$1" \! -perm /g+rw -exec chmod g+rw {} +
19+
find -L "$1" -perm /u+x -a \! -perm /g+x -exec chmod g+x {} +
20+
find -L "$1" -type d \! -perm /g+x -exec chmod g+x {} +
21+
22+
# Always end successfully
1323
exit 0

0 commit comments

Comments
 (0)