Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-11437

check_dir_exists in safe_mode is buggy

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2
    • Fix Version/s: 1.8.4, 1.9, 2.0
    • Component/s: Backup
    • Labels:
      None
    • Environment:
      Linux (Debian Etch), Apache 2.2.3-4+etch1, PHP5 5.2.0-8+etch7 with safe_mode turned on
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      When using safe_mode the is_dir() function might return a wrong result. My Moodle files are owned by www-data, the CFG->moodledata is in /var/local/moodledata. When checking is_dir('/var/') (like in lib/moodlelib.php:6771) PHP returns boolean(false); /var/ is owned by root and thus PHP returns false (for security reasons?!?). This results in errors when importing a course into another.

      It might be better to strip off the CFG->moodledata before recursively checking and creating directories. This directory should already exist anyway when calling this method. It even saves some execution time.

      Strip off CFG->moodledata (there might be another way that is more foolproof, this is just a quick workaround):

      $dir = str_replace($CFG->dataroot.'/', '', $dir);

      Start with $dir = CFG->dataroot:

      $dir = $CFG->dataroot.'/';

      See the patch for more information.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Jan/08