Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Avoid wrong permissions due to umask #751

Closed
whissle opened this Issue Aug 28, 2011 · 5 comments

Comments

Projects
None yet
3 participants

whissle commented Aug 28, 2011

On the permissions of folders (but not files) created by symphony, the user's umask is applied. This is done automatically by mkdir() but undesirable in most cases.
Solution: add a explicit chmod instruction to General::realiseDirectory() (symphony/lib/toolkit/class.general.php).

Owner

brendo commented Aug 28, 2011

That's really interesting, I actually wasn't aware that umask was applied when using the mkdir's parameters. Should of RTFM ;)

Member

michael-e commented Aug 29, 2011

Ah, yes, I remember that I had problems with this as well. If you look at General::realiseDirectory(), you find:

return mkdir($path, intval($mode, 8), true);

so Symphony attempts to set permissions, but actually that doesn't work (at least in my tests). So I agree that s.th. like this would be better:

$dir = mkdir($path);
@chmod($path, intval($mode, 8));
return $dir;

@ghost ghost assigned brendo Aug 29, 2011

@brendo brendo added a commit that referenced this issue Aug 29, 2011

@brendo brendo Clear umask before creating directories in General::realiseDirectory,…
… then restore it. RE: #751
797a4eb
Owner

brendo commented Aug 29, 2011

Interested in thoughts about the above commit.

Your example @michael-e didn't cater for when multiple directories have been created. Unfortunately the mkdir function offers recursive creation out of the box, but as a third parameter. I found this solution in the PHP comments, and it seems to work and is quite neat.

Owner

brendo commented Sep 1, 2011

Does the above commit fix the issue @michael-e / @whissle?

Member

michael-e commented Sep 1, 2011

I don't have a proper test case at the moment. @whissle?

@brendo brendo added a commit that referenced this issue Oct 8, 2011

@brendo brendo Clear umask before creating directories in General::realiseDirectory,…
… then restore it. RE: #751
5b4e966

@brendo brendo closed this Oct 8, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment