The Unix permissions model relies on the creator of a file being cognizant of others in their group, and setting the permissions and ownership on their files accordingly, within the group structure promulgated by the omnipresent and benevolent
root and his
wheel oligarchy. This, of course, is hilariously naive, almost to the point of being adorable, but we get what we get.
To effect this on newly-created files, I run a script somewhat like the following, via cron.hourly:
Code:
for sitedir in "${groupsitedirs}"
do
if [ -d "/srv/www/${sitedir}" ]; then
find /srv/www/${sitedir} \
\( -path /srv/www/${sitedir}/bin -prune \) -o \
\( -type f \! -perm 664 -exec chmod 664 "{}" \; \) , \
\( -type d \! -perm 775 -exec chmod 775 "{}" \; \) , \
\( \! -group $GROUPNAME -exec chgrp $GROUPNAME "{}" \; \)
else
echo "Directory ${sitedir} doesn't exist!"
EXITSTATE=1
fi
done
Hourly seems good enough, but this could be fired more often if required. If you feel led to adjust the
find conditions, be very mindful of the punctuation and order of operations. I usually break it every time I try to adjust something.
(... ok, hoopycat; put the dictionary down, stfu, and gbtw...)
_________________
Code:
/* TODO: need to add signature to posts */