When i create a new preset, imagecache create new folder with wrong permission.
example:
preset name: preset1
folder path: /files/imagecache/preset1
folder permission: 700 and not 755

Image permission too: every image got 775 permission and not 644

CommentFileSizeAuthor
#6 imagecache_umask.patch472 bytesstella

Comments

dopry’s picture

Status: Active » Postponed (maintainer needs more info)

check your system and php umask... this can be forced outside of mkdir...

alvinet’s picture

i'm using suPHP. In configuration file i change umask settings from 0077 to 0020.
Now folders is created with 755 permission but files with 775.
This value may be correct for this hosting, but for others?
Someone know the right solution for the umask value?

adamo’s picture

I also ran into problems with the suPHP umask defaulting to 0077.
Setting umask to "0002" in suphp.conf did the trick for me.

drewish’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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

stella’s picture

Version: 5.x-2.1 » 5.x-2.4
Status: Closed (fixed) » Needs review
StatusFileSize
new472 bytes

I ran into the same issue, and as changing the server's umask wasn't an option, I patched the module so it does a chmod() just after the directory is created, see attached patch.

NoRandom’s picture

I'm having problems too with imagecache folder permissions. In my case they are created with 744 and your patch doesn't help.

I've checked a lot of posts about this issue and I think I'm getting mad.

Kind regards.

NoRandom’s picture

Version: 5.x-2.4 » 5.x-2.5

...and still doesn't work with last update 2.5.

In a server with:

  • PHP 5.2.5-pl1-gentoo
  • Webserver Apache/2.0.59 (Unix) mod_ssl/2.0.59 OpenSSL/0.9.8g

Where should I change the umask setting? I don't konw almost anything about web servers.

Kind regards.

adamo’s picture

@Macarro: If you are using suPHP, find the umask in your suphp.conf file. If you are using mod_php, I believe it inherits the umask from Apache, which typically inherits the system umask. If you don't want to change your system umask you can edit the Apache init script and set it there using the umask command. There may be other ways to do it depending on your setup, but you're probably going to have to do some digging to find out what they are.

NoRandom’s picture

Hi

I've solved the problem patching the module but I don't know yet where is the problem.

In my site folder/file creation works perfectly for other modules and I've also created text files from my own php code simply saving a new file and they appear with the right permissions. So I assume it's not a server configuration error or problem (just an assumption).

My server admin told me the I'm working on a virtual apache server without any umask restriction. So, to check it I simply print the umask with "print umask()"... and I got 27 as result... So there was the problem. I don't know almost anything about this kind of issues but if this was right I would be impossible to get 705 permissions and that's not my case.

This way the simply solution was to modify the module (2.5 version) about at line 463 to force umask(0) during folder creation:

...
  $oldmask = umask(0);
  
  if (!file_check_directory($dir) && !mkdir($dir, 0755, true)) {
    watchdog('imagecache', t('Failed to create imagecache directory: %dir', array('%dir' => $dir)), WATCHDOG_ERROR);
    return false;
  }
  umask($oldmask);
...

Maybe I should put umask modification inside the if loop for security reasons... I don't know.

Kind regards and thanks for your answer, adamo.

adamo’s picture

If modifying the module is the solution, it would be better to call chmod() after the file is created than to use umask(). From the PHP manual:

Note: Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod() after creating the file. Using umask() can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask.

http://us.php.net/manual/en/function.umask.php

NoRandom’s picture

Thanks for the note, adamo.

I think I tried it and it didn't work in my case. Anyway I have to check it, I'll put here my results.

tazus’s picture

subscribe

NoRandom’s picture

Just in case it helps, I've recently upgraded to Drupal 6 and Imagecache works perfectly now, there is no folder permissions problem.

fizk’s picture

Status: Needs review » Closed (won't fix)