Moodle

Windows External Zip fails path change to different drive

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.3
  • Fix Version/s: None
  • Component/s: Backup
  • Labels:
    None
  • Environment:
    Windows with Mooodle Data on different drive to Moodle code
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

Moodle is configured to use external zip program.
Backup runs as are as starting the zip which failes.

Failure reason:
lib/Moodlelib @ 7314 - 7329 builds a command to execute to run the zip. This is a CD command followed by a zip command.
The CD command (if necessary) includes a drive change - eg x:\moodledata
The CD command requires a /D switch to perform the drive change - without the switch it does nothing.
The zip then fails because it does not have the correct current path.

I have changed the code to read -

//Construct the command
$separator = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? ' &' : ' ;';
$command = escapeshellarg($origpath).$separator.
escapeshellarg($CFG->zip).' -r '.
escapeshellarg(cleardoubleslashes("$destpath/$destfilename")).' '.$filestozip;
//All converted to backslashes in WIN
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $command = str_replace('/','\\',$command); }
$command = ' " cd /D '.$command.' " ';
Exec($command);

This is tested and working on windows , but I do not know if Unix will be happy with the /D option

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Sounds ok for me, if that /D switch has sense (note I know nothing about DOS).

Assigning to Petr, our security/zip/lovely expert.

Thanks for the report Roger. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Sounds ok for me, if that /D switch has sense (note I know nothing about DOS). Assigning to Petr, our security/zip/lovely expert. Thanks for the report Roger. Ciao
Hide
Wen Hao Chuang added a comment -

Would be nice if someone could verify and test it out to see if UNIX/Linux would be happy with that the /D option. +1 for this. Thanks!

Show
Wen Hao Chuang added a comment - Would be nice if someone could verify and test it out to see if UNIX/Linux would be happy with that the /D option. +1 for this. Thanks!
Hide
Eloy Lafuente (stronk7) added a comment -

well, we can add the "/D" switch only under windows, isn't it? That should keep the unix versions unmodified (something like):

$dswitch = '';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    $command = str_replace('/','\\',$command);
    $dswitch = '/D '
}
$command = ' " cd '. $dswitch . $command.' " ';

Ciao

Show
Eloy Lafuente (stronk7) added a comment - well, we can add the "/D" switch only under windows, isn't it? That should keep the unix versions unmodified (something like):
$dswitch = '';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    $command = str_replace('/','\\',$command);
    $dswitch = '/D '
}
$command = ' " cd '. $dswitch . $command.' " ';
Ciao
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Dates

  • Created:
    Updated:
    Resolved: