Skip to content

Commit a796544

Browse files
committed
Limit ownership fix to files and directories
Ignore other types like symlinks (their permissions are not relevant because the target's permissions are taken into account isntead of the symlink's ones) or exotic files (block an char files, pipes, sockets).
1 parent 04bbfeb commit a796544

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drupal_fix_permissions.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,20 @@ function fix_onwership() {
163163
case $simulate in
164164
0)
165165
# Real action.
166-
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) -print0 | xargs -r -0 -L20 chown $drupal_user:$httpd_group
166+
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print0 | xargs -r -0 -L20 chown $drupal_user:$httpd_group
167167
;;
168168

169169
1)
170170
# Simulate.
171171
printf "\n Items with wrong ownership: "
172-
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) -print | wc -l
172+
find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print | wc -l
173173
;;
174174

175175
2)
176176
# Simulate verbosely.
177177
printf "\n Files and directories that would have their ownership fixed: "
178178
# Use a variable to indent output.
179-
items=$(find "$1" $detected_vendor_path -type f -type -d \( ! -user $drupal_user -o ! -group $httpd_group \) -print)
179+
items=$(find "$1" $detected_vendor_path \( ! -user $drupal_user -o ! -group $httpd_group \) \( -type f -o -type d \) -print)
180180
items=${items:-None}
181181
printf "\n ${items//$'\n'/$'\n' }\n"
182182
;;

0 commit comments

Comments
 (0)