Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(templates): set ownership and permissions on private files folder #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions templates/drupal-fix-permissions.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ for x in ./*/files; do
# Don't need to set non-directory perms as they're already set above.
done


# Set permissions on private files path.
# Ask drush where the files directories are.
cd $drupal_path
private_files_path="$(drush status | grep Private | grep -oP '[:][ ]+\K([^: ]*)')"
if [ "$private_files_path" ] && [ -d "$private_files_path" ]; then
chown -R ${drupal_user}:${httpd_group} ${private_files_path} &
printf "Changing permissions of all files inside private files directory ${private_files_path} to rw-rw----...\n" && \
printf "Changing permissions of private files directory and all directories inside ${private_files_path} to rwxrwx---...\n" && \
chmod u=rwx,g=rwx,o= ${private_files_path}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this line (248) become redundant if the two 'find' commands below apply the correct permissions to the same path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finalhow I wasn't sure if the find command would apply the permissions to the containing (top-level) directory, or if the find command would only return and apply permissions to only the directories contained within that top-level private files directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense. Well, either way its just one chmod extra on one directory and its not recursive so no big deal.

Easy way to test if ever you need to: Run the same find command without the 'exec' bit and 'head' the output:

find <path> -type d | head

Anyway ok perfect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ClassicCut Forgot to @ mention my reply... bah

find ${private_files_path} -type d -exec chmod u=rwx,g=rwx,o= '{}' +
find ${private_files_path} -not -type d -exec chmod u=rw,g=rw,o= '{}' +
# Restore SELinux modes for private files directory.
command_exists restorecon && \
printf "Restoring SeLinux file contexts for ${private_files_path}, please wait...\n" && \
restorecon -RF ${private_files_path} &
fi


# Check permissions for supporting directories.
if [ "$dversion" -eq 7 ] && [ -d "${drupal_path}/sites/all/vendor/bin" ]; then
printf "Changing permissions of "vendor/bin" directories in "${drupal_path}/sites/all/vendor/bin" to "u+x"...\n" && \
Expand Down