ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


realpath and freeBSD question


  • 2007-05-09 09:24:15

    realpath and freeBSD question

    After an ugrade on my server from FreBSD FreeBSD 5.5 to 6.2 my ATutor installation suddenly couldn't fetch content (my content dir is outside web scope) with get.php. The problems seems to be related to freeBSD's handling of realpath() in PHP.
    The following changes to get.php solved it and the solution maybe interesting for others?
    I have tested the new code and it seems to work fine, but have any of you comments or idea why it may not work in certain situations or?

    Things to describe:
    operating system - FreeBSD 6.2
    version of ATutor - 1.5.3.2
    versions of php - 5.2.1
    version of mysq l - 5.0.37
    webserver & version - Apache 1.3.37
    copies of error messages -
    changes to default settings - in get.php the following changes (starting line 92) have been made:
    [php]// NOTE!! for some reason realpath() is not returning FALSE when the file doesn't exist! NOTE!!
    #$real = realpath('/usr'.$file);
    $real = $file;

    //If (file_exists($real) && (substr($real, 0, strlen(AT_CONTENT_DIR)) == AT_CONTENT_DIR)) {
    if ($force_download) {
    header('Content-Type: application/force-download');
    header('Content-transfer-encoding: binary');
    header('Content-Disposition: attachment; filename="'.$pathinfo['basename'].'"');
    } else {
    header('Content-Disposition: filename="'.$pathinfo['basename'].'"');
    }
    header('Content-Type: '.$ext);
    echo file_get_contents($file);
    exit;
    //} else {
    //header('HTTP/1.1 404 Not Found', TRUE);
    // exit;
    //}[/php]

    web browser being used -
    and anything else relevant -

  • 2007-05-24 16:13:36

    Re: realpath() and freeBSD question

    The change you made isn't a good idea and can be a big security problem on your server.

    Which version of PHP are you using? You might want to upgrade and see if the problem goes away.

  • 2007-05-28 16:12:01

    Re: realpath() and freeBSD question

    Sorry - been away from my PC :-(
    I'm using PHP 5.2.1on FreeBSD.
    I think I wil move my content dir into the dir where I installed ATutor. If I understand it right get.php is then no longer used to fetch the material and therefore there should be no broplems with freeBSD?
    Greetings
    Jens

    [reply][b]In reply to:[/b]
    The change you made isn't a good idea and can be a big security problem on your server.

    Which version of PHP are you using? You might want to upgrade and see if the problem goes away.
    [op]forums/view.php?fid=7;pid=10609;page=1#10692[/op][/reply]

  • 2007-05-29 12:47:30

    Re: realpath() and freeBSD question

    That is correct. You will have to edit the config file as well.

    But, it'll make upgrading more difficult if you have lots of files.