Page 1 of 1

File Permissions on Uploaded files

Posted: Tue Jan 18, 2005 10:43 pm
by nicknick
Can anyone explain or point me in the right direction to solve the problem I have? (cmsms version 8.2)

When uploading files through the web interface they are written to the web server with permissions of 600. This means I can't edit them, as they seem to need to be 666 - I can prove this almost works by using a shell to see the perms of what has been uploaded and to change them by hand.

Even then I run into problems when using the image editor (configured to GD) - I can see the image, even re-size it, but have trouble writing it back

e.g.
*Upload a file. It can be seen in the image manager page with dimensions etc.
*It creates the file itself (perms 600) and a thumbnail (perms 644)
*Fix the perms to 666 (from 600) by hand in a shell.
*Cick on the edit icon - it loads into the pop-up. I re-size the image - looks fine.
*Click on the save icon - it _seems_ to save.

I get left with the orginal files, as well as a file with a long temporary sort of name with perms 644 and no updated file in the image manager page.

Now, I'm guessing that this is something constrained by the web server - but can I do anything about it?

Many thanks for any clues or pointers....

Re: File Permissions on Uploaded files

Posted: Wed Mar 23, 2005 11:34 pm
by Tamlyn Rhodes
I have exactly the same problem. For the moment I've circumvented it by adding explicit chmod's in the source (do a search for move_uploaded_file to find where). But surely there's a better way...

Re: File Permissions on Uploaded files

Posted: Thu Mar 24, 2005 1:10 am
by Ted
Chances are that the umask for the process that the web server is running as is set to 177.  Other servers are probably set to 022 (which makes them 755).  Basically, I think I need to write a way to override the default permission when files are uploaded.  Maybe make a config.php option?

Tamlyn: Nice work on Singapore!  You have a great little app there.  Thank you very much for releasing it.

Re: File Permissions on Uploaded files

Posted: Thu Mar 24, 2005 2:52 am
by tamlyn
Yeah I think you might be right. This particular site is running in some kind of ensim high security mode which I don't fully understand. The admin switched it over to normal mode for me but then everythign broke so he switched it back...

As for overriding default permissions this is what I found for singapore: I used to set the umask to a user defined value (usually 0) and hoped for the best. This worked on some servers but failed on others. I've now gone over the code and added explicit chmod's every time a file or directory is created or uploaded. This seems to work quite well although it hasn't been released yet so I'm sure someone will find a way to make it fail!

Nice work on CMS too! I've never used any content management systems before but I need one for a site I'm building. I took mambo for a spin and was pretty impressed but the backend is soooo complex. I was sure my client would get lost or give up before getting anything done! CMS strikes a great balance between simplicity and functionality - something I think singapore had to begin with but I'm afraid it may be straying from.

Re: File Permissions on Uploaded files

Posted: Thu Mar 24, 2005 2:57 am
by Ted
Doing explicit chmods will probably make people the happiest.  People do like options, as long as their hidden until needed.  :)

I'll add it to my TODO list.