Hi!

I'm running my site with fastcgi and php safe_mode, thats why I changed the default octal permissions for both directories and files.

Under cache/normal everything is ok, directories 0775 and files 0664. Under cache/perm directories has got 0775 permission, files has got 0600 permission. The files permission should be 0664 too here.

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new3.67 KB

I set chmod for files in the perm dir as well... interesting.

// Writes to the normal dir
function boost_cache_write($filename, $buffer) {
...
        if (is_numeric(BOOST_PERMISSIONS_FILE)) {
          @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
        }
...
// Copy files to the perm dir
function _boost_copy_file($src, $dest) {
  $destinations = _boost_copy_file_get_domains($dest);
  foreach ($destinations as $destination) {
    if (_boost_mkdir_p(dirname($destination))) {
      @copy($src, $destination);
      if (is_numeric(BOOST_PERMISSIONS_FILE)) {
        @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
      }
    }
  }
}
// Write files to the perm dir
function _boost_gz_copy_file($src, $dest) {
  $destinations = _boost_copy_file_get_domains($dest);
  foreach ($destinations as $destination) {
    if (_boost_mkdir_p(dirname($destination))) {
      @file_put_contents($destination, gzencode(file_get_contents($src), 9));
      if (is_numeric(BOOST_PERMISSIONS_FILE)) {
        @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
      }
    }
  }
}

I went through the code and added in a chmod wherever there was a file_put_contents() let me know if this patch does the trick for you.

xmarket’s picture

Status: Needs work » Needs review

Hi!

Patch has been applied, but nothing changed at all. This is a multisite install, with one language. Drupal 6.14, php 5.2.11.

Structure:

cache
   '->perm
      |     '-> www.mysite.com (0775) File permissions wrong from this level. Only file permissions.
      |                  '-> files (0775)
      |                           '-> www.mysite.com (0775)
      |                                                '-> js (0775)
      |                                                        '-> js_812aa7a0979e5225e73cf72bd255b124.js_.js (0600)
      |                                                        '-> js_812aa7a0979e5225e73cf72bd255b124.js_.js.gz (0600)
      |
      '->boost-gzip-cookie-test.html.gz (0664)

Only the files permissions wrong from the first www.mysite.com level.

PHP default octal permission is 0600. I'm running php under fastcgi with fastphp user and group, that is why apache user and group can't access to the files directly with php safe_mode = on. I need at least 0644 octal permission, if I would like to use this module.

mikeytown2’s picture

My guess is php created the normal dir and you created the perm dir; or a subdir in here.
http://www.php.net/manual/en/features.safe-mode.functions.php
chmod will not work if php does not own that dir if running in safe mode.
What you need to do is del the perm dir and let boost automatically create the dir for you.

mikeytown2’s picture

Status: Needs review » Needs work

Scratch the above comment. I see the bug... patch should be here soon.

xmarket’s picture

Status: Needs review » Needs work

I'm looking forward to it.

mikeytown2’s picture

Status: Needs work » Needs review
StatusFileSize
new4.4 KB
xmarket’s picture

Patch boost-638390.patch has been applied without errors, and I can confirm, this patch works. Persmissions - both file and directory - now everywhere OK, as it should be. Thanks for the fast and great work!

xmarket’s picture

Status: Needs review » Reviewed & tested by the community
mikeytown2’s picture

StatusFileSize
new4.72 KB

Created a function that creates the dir, writes the file and chmod it.

xmarket’s picture

Patch at comment #9 fails. Bug comes back, under perm AND normal every file has got 0600 octal permission, ONLY files. Patch at comment #6 OK, works.

mikeytown2’s picture

StatusFileSize
new4.73 KB

try this one

key difference
if ($bytes && is_numeric(BOOST_PERMISSIONS_FILE)) {

xmarket’s picture

I'm so sorry, I didn't noticed, that the patch tricked me. After applying the patch, I needed to setup again the permissions in the settings page, and after everything becamed OK. So the patch at comment #9 works fine, just the settings needs to be checked.

mikeytown2’s picture

Status: Reviewed & tested by the community » Fixed

committed

Status: Fixed » Closed (fixed)

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