Created
March 13, 2018 20:43
-
-
Save lukapaunovic/a77d9397e6de942de268b3b738f3fccb to your computer and use it in GitHub Desktop.
SUPHP cPanel open_basedir hardening
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
value="open_basedir" | |
for USER in $(ls -I system /var/cpanel/users/) | |
do | |
if [ ! -f /home/$USER/.user.ini ]; then | |
sudo -H -u$USER bash -c "echo 'open_basedir = /home/$USER:/tmp:/opt/cpanel/composer/bin/composer:/var/cpanel/php/sessions/' >> /home/$USER/.user.ini" | |
chmod 0555 /home/$USER/.user.ini | |
elif ! grep -q "$value" "/home/$USER/.user.ini"; then | |
sudo -H -u$USER bash -c "echo 'open_basedir = /home/$USER:/tmp:/opt/cpanel/composer/bin/composer:/var/cpanel/php/sessions/' >> /home/$USER/.user.ini" | |
chmod 0555 /home/$USER/.user.ini | |
else | |
echo Gospodin /home/$USER/.user.ini vec sadrzi basedir varijablu | |
fi | |
if [ ! -f /home/$USER/php.ini ]; then | |
sudo -H -u$USER bash -c "echo 'open_basedir = /home/$USER:/tmp:/opt/cpanel/composer/bin/composer:/var/cpanel/php/sessions/' >> /home/$USER/php.ini" | |
chmod 0555 /home/$USER/php.ini | |
elif ! grep -q "$value" "/home/$USER/php.ini"; then | |
sudo -H -u$USER bash -c "echo 'open_basedir = /home/$USER:/tmp:/opt/cpanel/composer/bin/composer:/var/cpanel/php/sessions/' >> /home/$USER/php.ini" | |
chmod 0555 /home/$USER/php.ini | |
else | |
echo Gospodin /home/$USER/php.ini vec sadrzi basedir varijablu | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment