The function backup_migrate_file_download() returns -1 if a user doesn't have user_access('access backup files'), which most users do not. However, this tells private_upload to deny access to files users should have access to. Not sure which module is as fault.

Comments

agerson’s picture

Actually, it may be another issue with backup_migrate_file_download() because I could't access my private files as admin either. Somehow this function is returning false or null when it should not be.

function backup_migrate_file_download($path) {
  if ($path = _backup_migrate_path_is_in_save_dir($path)) {
    if (user_access('access backup files') && $info = _backup_migrate_file_info($path)) {
      return array(
        'Content-Type: '. $info['filemime'],
        'Content-Length: '. $info['filesize'],
        'Content-Disposition: attachment; filename="'. $info['filename'] .'"',
      );
    }
    else {
      return -1;
    }
  }
  return NULL;
}
ronan’s picture

Version: 6.x-2.2 » 6.x-1.2
Status: Active » Closed (works as designed)

That code seems to be from the 1.2 version.

For non backup files Backup and Migrate should be returning NULL. That response basically means ignore this response (neither allow nor deny) so if that is what is being returned then B&M is doing its job and some other module is denying access (or none is specifically allowing it). http://api.drupal.org/api/function/hook_file_download/6

If B&M is returning -1 (meaning deny access) for files it doesn't control, then please reopen this ticket.

Thanks

agerson’s picture

Yikes, I am on version = "6.x-1.3". It was returning -1 for files it did not own, but I will update.

riisi’s picture

Version: 6.x-1.2 » 6.x-1.3

I just had this problem. Update to Backup Migrate 1.3 resulted in all private files having "access denied".

Updating to 6.x-2.2 has worked for me.

Perhaps this should be flagged in the release notes as it's not the first module you look into when encountering problems with file access.

bbeyer’s picture

Status: Closed (works as designed) » Closed (won't fix)

I had this same issue and it was fixed by upgrading to 6.x-2.x.

Changing it to closed(won't fix) since I doubt it was designed to block all other file downloads.