The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error: open_basedir restriction in effect

Discussion in 'General Discussion' started by Jeff75, Aug 15, 2003.

  1. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    Can somebody tell me what I need to do to fix this error? I've tried applying the php open_basedir Tweak in WHM but the error persists.

    Warning: getimagesize(): open_basedir restriction in effect. File(/var/tmp/phpvzduQL) is not within the allowed path(s): (/home/login:/usr/lib/php:/usr/local/lib/php:/tmp) in /usr/home/login/public_html/image.php on line 232

    Warning: getimagesize(/var/tmp/phpvzduQL): failed to open stream: Operation not permitted in /usr/home/login/public_html/image.php on line 232

    Here is what's on line 232:

    $size = getimagesize($poster);

    This is what's in the httpd.conf for the virtual host's entry:

    <IfModule mod_php4.c>
    php_admin_value open_basedir "/home/login:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>

    cPanel.net Support Ticket Number:
     
  2. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    It turns out the error was caused because it needed to have :/var/tmp at the end of the php_admin_value open_basedir.

    Is there anyway to make it so it will add the :/var/tmp automatically without having to manually go in and add it to each virtual host?

    Since this happened for one user, it's bound to happen to others since many scripts use the tmp directory to write files to.

    cPanel.net Support Ticket Number:
     
  3. Mat

    Mat Well-Known Member

    Joined:
    Sep 26, 2001
    Messages:
    55
    Likes Received:
    0
    Trophy Points:
    6
    Would be nice if the default line was editable from WHM so we could add the custom directories that we might have on our servers....

    cPanel.net Support Ticket Number:
     
  4. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    I think cPanel is going to have to make a way that we can specify custom directories as Mat had suggested. The client is getting this error again because cPanel keeps overwriting the change that I made to the clients virtual host.

    Please add this feature ASAP as it is really causing problems and we cannot disable support for open_basedir.

    cPanel.net Support Ticket Number:
     
  5. mmkassem

    mmkassem Well-Known Member

    Joined:
    Oct 21, 2002
    Messages:
    390
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Egypt
    A quick fix
    Code:
    pico /scripts/phpopenbasectl
    Search for: /tmp
    You will find this line:
    Code:
    $dir}:/usr/lib/php:/usr/local/lib/php:/tmp\"\n</IfModule>\n";
    
    Make it:
    Code:
    $dir}:/usr/lib/php:/usr/local/lib/php:/var/tmp:/tmp\"\n</IfModule>\n";
    
    and
    Code:
    chattr +i /scripts/phpopenbasectl
    cPanel.net Support Ticket Number:
     
  6. dgbaker

    dgbaker Well-Known Member
    PartnerNOC

    Joined:
    Sep 20, 2002
    Messages:
    2,578
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Toronto, Ontario Canada
    cPanel Access Level:
    DataCenter Provider
    Has anyone actually requested an enhancement on this? The workaround does work for global settings, but we have a need to be able to modify by individual basedir's as well.

    cPanel.net Support Ticket Number:
     
  7. binbash

    binbash Member

    Joined:
    Oct 23, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    if you need to add /var/tmp/ to open_basedir for all domains, just try adding it in the php.ini file, which is the global setting.

    /akm

    cPanel.net Support Ticket Number:
     
  8. Finkinstein

    Finkinstein Well-Known Member

    Joined:
    Mar 21, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    Where abouts would I add the code in the php.ini file? I can't see it.

    Also, why won't this work on account creation? Is it made a different way, how can I change this just as easily?
     
    #8 Finkinstein, Aug 28, 2003
    Last edited: Aug 29, 2003
  9. Finkinstein

    Finkinstein Well-Known Member

    Joined:
    Mar 21, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    Bump cos of edit..

    cPanel.net Support Ticket Number:
     
  10. Finkinstein

    Finkinstein Well-Known Member

    Joined:
    Mar 21, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    Still not room for custom folders to be added. Has it been recommended/requested?

    Also, to make this work on new accounts pico /scripts/wwwacct and do the same...
     
  11. salamandyr

    salamandyr Member

    Joined:
    Apr 29, 2003
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    hi,

    i tried to add this to enable use of /usr/share/squirrelmail, e.g. by chaning the line to this:

    ${homedir}:/usr/lib/php:/usr/local/lib/php:/usr/share/squirrelmail:/tmp\"\n</IfModule>\n";

    but it doesn't seem to work - still get this error from domains with openbasedir() in effect:


    Warning: Unknown(): open_basedir restriction in effect. File(/usr/share/squirrelmail/index.php) is not within the allowed path(s):

    any ideas?
     
  12. Jeff75

    Jeff75 Well-Known Member

    Joined:
    Apr 11, 2003
    Messages:
    555
    Likes Received:
    0
    Trophy Points:
    16
    Try restarting Apache.
     
  13. salamandyr

    salamandyr Member

    Joined:
    Apr 29, 2003
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    ya.. tried that ... and even rebooted :)
    no joy :(
     
  14. salamandyr

    salamandyr Member

    Joined:
    Apr 29, 2003
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    ah-ha!

    discovered that the entries in httpd.conf override the one in /scripts/phpopenbasdir

    :)

    all set now!
     
  15. gershwin

    gershwin Member

    Joined:
    Nov 16, 2003
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Similar problem after changing user name for account

    I had a problem running scripts in the appropriate user folders after changing the user name for one of my accounts. It turned out that while the whm script for assigning open_basedir protection picks up the home/username properly and places it in the httpd.conf virtualhost section for each account, the change username script

    (Account Functions | Edit an Account | Edit)

    in whm does not change this value even though it does change the name of the home/usernam folder for the account. Changing the name of the folder from

    php_admin_value open_basedir "/home/lodusername:/usr/lib/php:/usr/local/lib/php:/tmp"

    to
    php_admin_value open_basedir "/home/newusername:/usr/lib/php:/usr/local/lib/php:/tmp"

    and restartind apache did the trick.
     
  16. osfdeath

    osfdeath Well-Known Member

    Joined:
    Aug 29, 2003
    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    16
    Were there ever any fixes to this?

    I'm getting errors attempting to use a simple php include statment here:
    Code:
    Warning: main(forums/ssi.php?a=news&show=8): failed to open stream: No such file or directory in /home/domain/public_html/main2.php on line 35
    
    Warning: main(): Failed opening 'forums/ssi.php?a=news&show=2' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/domain/public_html/forums/') in /home/domain/public_html/main2.php on line 35
    
    Works fine if i use a full URL in the include statment though

    <?php
    include ('http://www.domain.com/forums/ssi.php?a=news&show=8')
    ?>

    ? <--that one is cuz I'm lost ;)
     
  17. mmkassem

    mmkassem Well-Known Member

    Joined:
    Oct 21, 2002
    Messages:
    390
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Egypt
    This is a php programming problem and not related to cpanel or oepn_basedir.

    You can not include file.php?whatever=whatever as a path because this is not a file .. the file name is file.php and not file.php?whatever=whatever

    include("path/file.php"); // is including a php file (its code)

    include("http://www.whatever.com/file.php"); // includes its output and not the code

    You can read the Warning printed by php .. it is very clear.
    "No such file or directory "
     
  18. osfdeath

    osfdeath Well-Known Member

    Joined:
    Aug 29, 2003
    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    16
    *light bulb goes off*

    I see :)

    Gives me an idea on how to include stuff in Flash tough :)

    The original reason I was wondering is because of bandwidth use - I was under the impression that every call to http://domain.com... meant having to go back to the ns then back to the site - bandwidth use and loading time
    Looking at my logs, it appears otherwise

    An include call for http://www.domain.com/file.php?name=myname comes up in apache logs as only file.php and doesn't count for the bandwidth use...not sure about load times - i'm sure it's slower but by how much...
    Probably takes longer to query the mysql server and return the data than to actually call for the page.

    Thanks!
     
Loading...

Share This Page