When updating a module, the function drush_prepare_backup_dir (in drush/includes/drush.inc) is called. It tries to detect if the backup directory is inside the Drupal root. Since the Drupal root doesn't end with a slash, you can get false positives.

To reproduce:
1) Drupal root - /var/www/drupal
2) Drush backup-dir - /var/www/drupal_backup

With this setup "strpos($backup_parent, $drupal_root)" will return 0 since $backup_parent is /var/www/drupal_backup/databasename and $drupal_root is /var/www/drupal.

The trivial fix is attached as a patch.

PS! This bug might be fix in 5.x-dev, but is still a problem in 4.x-dev.

CommentFileSizeAuthor
drush-includes-drush-inc-201109231021.patch324 byteshansfn

Comments

jonhattan’s picture

Version: All-versions-4.x-dev »
Status: Active » Fixed

Committed. Thanks.

jonhattan’s picture

Version: » All-versions-4.x-dev
Assigned: Unassigned » msonnabaum
Priority: Major » Normal
Status: Fixed » Patch (to be ported)
hansfn’s picture

I wonder if my patch was too trivial - maybe DIRECTORY_SEPARATOR is needed in stead of a bare "/"? I don't know the inner workings of Drush (and I don't have Windows to test on).

jonhattan’s picture

I'm out of windows world. Perhaps we should always normalize paths to '/' form before any operation.

Reference #966002: Proper usage of DIRECTORY_SEPARATOR.

msonnabaum’s picture

Status: Patch (to be ported) » Fixed

Backported.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.