How to Fix permissions for all cPanel-registered Users

hr-ethadmin
Site Admin
Posts: 67
Joined: Fri May 31, 2013 1:04 pm

How to Fix permissions for all cPanel-registered Users

Postby hr-ethadmin » Wed Dec 25, 2013 12:37 pm

Hello,

Using following shell scripts we can fix it very easily.

#!/bin/bash -

echo "Fixing permissions for all cPanel-registered Users..."
for i in `cut -f1 -d: /etc/trueuserowners | sort | uniq | grep -v '^#' | grep manualpe -A 500`
do
USER_HOME=`grep -E "^$i:" /etc/passwd | cut -f6 -d:`

if [[ -d "${USER_HOME}" ]]; then
find "${USER_HOME}/" -type f -perm +033 -iname '*.php' -exec chmod u+r,a-x,go-w '{}' \;
find "${USER_HOME}/" -type d -perm +022 -exec chmod u+r,a+x,go-w '{}' \;
chown -R $i:$i "${USER_HOME}/public_html/"
chgrp nobody "${USER_HOME}/public_html"
chmod 750 "${USER_HOME}/public_html"

find "${USER_HOME}/" -type f -name '.htaccess' -exec grep -qE 'php_(flag|value)' '{}' \; -and -exec sed -r -i.suphpfix -e 's/^[ \t]*php_(flag|value)/#php_\1/g' '{}' \;

echo "User $i done"
else
echo "user $i doesn't exist"
fi
done

-------

Thank you.

Return to “Hostripples dedicated Servers (Linux/Windows)”

Who is online

Users browsing this forum: No registered users and 0 guests