blog:set_rights_of_files_in_public_html
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
blog:set_rights_of_files_in_public_html [2011-03-10 18:55] – created brb | blog:set_rights_of_files_in_public_html [2011-03-11 07:52] – brb | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Set rights of files in public_html ====== | ====== Set rights of files in public_html ====== | ||
- | < | + | Set rights of user /home/*/ |
- | #!/bin/bash | + | - all files/ |
+ | - group www-data is added g+r for files (webserver can read all files) g+rsx for directories (webserver can read and change into all directories) | ||
+ | - o-rights (for all) are completely removed, so shell users can't read files of other users (possibly containing passwords etc). | ||
- | # setjog-here.sh | ||
- | find . -type d -print0 | xargs -0 chmod 755 | + | <code bash> |
- | find . -type f -print0 | xargs -0 chmod 644 | + | #!/bin/bash - |
- | chmod 755 . | + | # |
- | chmod u+x $0 | + | # |
+ | # FILE: fixphrights.sh | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # and useful way | ||
+ | # - all files/ | ||
+ | # and the webserver has group access | ||
+ | # - group www-data is added | ||
+ | # g+r for files (webserver can read all files) | ||
+ | # g+rsx for directories (webserver can read and change into all directories) | ||
+ | # - o-rights (for all) are completely removed, so shell users can't read | ||
+ | # files of other users (possibly containing passwords etc). | ||
+ | # This can be run in a cronjob and will fix rights every five minutes, e.g.: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Requirements: | ||
+ | # BUGS: --- | ||
+ | # | ||
+ | # Author: Bernhard Brunner (bn), bernhard.brunner@epr.ch | ||
+ | # | ||
+ | # | ||
+ | # Last modified: 2011/03/11 07:40 | ||
+ | # Revision: | ||
+ | # | ||
+ | |||
+ | set -o nounset | ||
+ | |||
+ | setrights () | ||
+ | { | ||
+ | echo $1 | ||
+ | cd /home/$1 | ||
+ | mkdir -p public_html | ||
+ | cd public_html | ||
+ | find . -type d -print0 | xargs -0 chown $1: | ||
+ | | ||
+ | find . -type f -print0 | xargs -0 chown $1: | ||
+ | | ||
+ | chown $1:www-data . | ||
+ | chmod u+x, | ||
+ | # chmod u+x | ||
+ | } | ||
+ | # ---------- | ||
+ | |||
+ | cd /home | ||
+ | for i in * ; do | ||
+ | echo $i | ||
+ | if [[ " | ||
+ | setrights $i | ||
+ | fi | ||
+ | done | ||
</ | </ | ||
Ref: http:// | Ref: http:// | ||
- | {{tag>}} | + | {{tag>linux bash webserver}} |
~~LINKBACK~~ | ~~LINKBACK~~ | ||
~~DISCUSSION~~ | ~~DISCUSSION~~ | ||
blog/set_rights_of_files_in_public_html.txt · Last modified: 2011-03-11 07:57 by brb