Disallow php.ini to be uploaded by users

LeetsHost

Member
Apr 2, 2012
5
0
51
cPanel Access Level
Root Administrator
Hi
Can someone tell me how can i prevent users uploading php.ini in there accounts. I found it can bypass my serversSafe mode. It can make my servers Safe mode from ON to OFF for that particular user only. Any idea how to stop users from doing that or stopping users to upload php.ini
Thanks in advance :D ......
 

LeetsHost

Member
Apr 2, 2012
5
0
51
cPanel Access Level
Root Administrator
If a user makes a file or uploads a file named php.ini at file manager or a shell, and adds the following code:
Code:
safe_mode=OFF

disable_functions=NONE
safe_mode_gid=OFF
open_basedir=OFF
It makes Safe Mode OFF / disable_functions=NONE / safe_mode_gid=OFF / open_basedir=OFF
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

If you are using suPHP, you can disable the ability to use individual php.ini files by editing this section in /opt/suphp/etc/suphp.conf file:

Code:
[phprc_paths]
;Uncommenting these will force all requests to that handler to use the php.ini
;in the specified directory regardless of suPHP_ConfigPath settings.
;application/x-httpd-php=/usr/local/lib/
;application/x-httpd-php4=/usr/local/php4/lib/
;application/x-httpd-php5=/usr/local/lib/
Change to the following to disallow user-based php.ini files and force the global /usr/local/lib/php.ini file:

Code:
[phprc_paths]
;Uncommenting these will force all requests to that handler to use the php.ini
;in the specified directory regardless of suPHP_ConfigPath settings.
application/x-httpd-php=/usr/local/lib/
application/x-httpd-php4=/usr/local/php4/lib/
application/x-httpd-php5=/usr/local/lib/
After that, you would want to restart Apache.

Please note that you will no longer have the ability for set accounts to have individual settings, so if any user needs to increase upload_max_filesize value, for example, that account won't be able to change it. There's a thread on how to allow some accounts to have different settings and still restrict all values from being changed under suPHP at this location:

http://forums.cpanel.net/f185/metho...ricting-who-can-use-php-ini-files-167186.html

Thanks!