Backup cannot copy User Files - open_basedir restriction in effect

Backup cannot copy User Files - open_basedir restriction in effect

de António Vilela -
Número de respuestas: 6
Imagen de Plugin developers Imagen de Translators

Hi

I have migrated a moodle 1.8.2 to a new server, with 1.8.3.

The upgrading didn't show any errors.

Everything is working fine except backup, that is not able to copy user files.

Down are the errors I get with debuging on.

Somebody has a clue about what is happening?

Our dirs:

$CFG->dirroot   = '/var/www/vhosts/elearning-laranjeira.net/httpdocs';
$CFG->dataroot  = '/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata';

Thanks

Name: backup-dp_10oi-20071018-2301.zip
  • Creating temporary structures
  • Deleting old data
  • Creating XML file
    • Writing header
    • Writing general info
    • Writing course data
    • Writing users info
    • Writing scales info
    • Writing groupings info
    • Writing groups info
    • Writing events info
    • Writing gradebook info
    • Writing modules info
      • Assignments
        Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

        Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

        Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

        Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

        Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/moddata/assignment/1/4/Magazine.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275
      • Forums
      • Journals
      • Resources
    • Course format data
  • Copying user files
    Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

    Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

    Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

    Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/3/f2.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/3/f1.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275

    Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

    Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/23/f2.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/23/f1.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275

    Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6898

    Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/var/) is not within the allowed path(s): (/var/www/vhosts/elearning-laranjeira.net/httpdocs:/tmp) in /var/www/vhosts/elearning-laranjeira.net/httpdocs/lib/moodlelib.php on line 6899

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/26/f2.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275

    Warning: copy(/var/www/vhosts/elearning-laranjeira.net/httpdocs/moodledata/temp/backup/1192744905/user_files/0/26/f1.jpg) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/elearning-laranjeira.net/httpdocs/backup/lib.php on line 275
    An error occurred while copying user files


The backup did not complete successfully
Promedio de valoraciones: -
En respuesta a António Vilela

Re: Backup cannot copy User Files - open_basedir restriction in effect

de António Vilela -
Imagen de Plugin developers Imagen de Translators

What is happening is that our server doesn't allow Apache User permissions to use the function is_dir($dir) with any directory below httpdocs.

So when the below function in moodlelib.php is called with $recursive=true this error always happens.

This is a situation that only occurs on Moodle 1.8.3 because Moodle 1.8.2 backup never calls this function with $recursive=true.

function check_dir_exists($dir, $create=false, $recursive=false) {

    global $CFG;

    $status = true;

    if(!is_dir($dir)) {
        if (!$create) {
            $status = false;
        } else {
            umask(0000);
            if ($recursive) {
                // PHP 5.0 has recursive mkdir parameter, but 4.x does not triste
                $dir = str_replace('\\', '/', $dir); //windows compatibility
                $dirs = explode('/', $dir);
                $dir = array_shift($dirs).'/'; //skip root or drive letter
                foreach ($dirs as $part) {
                    if ($part == '') {
                        continue;
                    }
                    $dir .= $part.'/';
                    if (!is_dir($dir)) {
                        if (!mkdir($dir, $CFG->directorypermissions)) {
                            $status = false;
                            break;
                        }
                    }
                }
            } else {
                $status = mkdir($dir, $CFG->directorypermissions);
            }
        }
    }
    return $status;
}

En respuesta a António Vilela

Re: Backup cannot copy User Files - open_basedir restriction in effect

de Eloy Lafuente (stronk7) -
Imagen de Core developers Imagen de Documentation writers Imagen de Moodle HQ Imagen de Peer reviewers Imagen de Plugin developers Imagen de Testers
Hi Antonio,

well spotted! guay

Right now there are two ongoing bugs in the tracker related with this:

- MDL-11912 : The backup problem itself under open_basedir
- MDL-11437 : A general solution to make check_dir_exists() more open_basedir friendly.

Hopefully both will be fixed soon. Sí

Thanks and ciao sonrisa
En respuesta a Eloy Lafuente (stronk7)

Re: Backup cannot copy User Files - open_basedir restriction in effect

de Chrissie Turkington -

I'm getting exactly the same error but am a little confused about the solution mentioned above (MDL-11437) - basically i don't understand it!  Please can someone explain in simple terms the best way of fixing this?

Thanks.

En respuesta a Chrissie Turkington

Re: Backup cannot copy User Files - open_basedir restriction in effect

de Eloy Lafuente (stronk7) -
Imagen de Core developers Imagen de Documentation writers Imagen de Moodle HQ Imagen de Peer reviewers Imagen de Plugin developers Imagen de Testers
Hi Chissie,

the problem was that before fixing MDL-11437, the copy of files was really incompatible with the open_baserdir() PHP restriction (it needed to be 100% disabled), and after the fix, it should work with the restriction enabled if your $CFG->moodledata is within the allowed directories in the directive.

Note that the change was applied after Moodle 1.8.3 release, so you'll need at least Moodle 1.8.3+ to have backup & open_safedir() working together.

Hope this helps, ciao sonrisa
En respuesta a Eloy Lafuente (stronk7)

Re: Backup cannot copy User Files - open_basedir restriction in effect

de Andy An -
Hi Eloy:
I have the similar problem (See: http://moodle.org/mod/forum/discuss.php?d=87733) and I have tried the way here but the problem is still there.
If I do the same backup at my development sandbox, which is clone of the live site, it can complete the backup though there is a error message as to the point to the coying user files, saying "the_path_to_dataroot/user does not exist!".
Here the dataroot just contains users dir and after I modified the users to user it works fine without any complain.

Then I found I have two user dirs in the dataroot: one is user which contains three dirs(0/, 1000/ and 2000), another is users, which seemed to be there before upgrading. And the 0/ dir seems the copy of user dir.

How can I fix this problem?
Any clues welcome!
Thanks.
En respuesta a Andy An

Re: Backup cannot copy User Files - open_basedir restriction in effect

de Andy An -
Hi Eloy:
As I replaced the user dir(the dir created after upgraded to 1.8.3) with old users (the original users dir before upgrading)(mv user user_new and mv users user) I run /backup/backup.php successfully.

I don't think it's a solution for this problem.
Any other suggestion?
Thanks.