Uploads complete but permissions wrong (403)

Permalink 2 users found helpful
Hi all

I can upload files to my server using the file manager, but they aren't inheriting the correct permissions.

I've chmodded my files/ folder recursively to both 755 and 777, but any newly uploaded files don't appear when I insert them (I just get the alt text) and if I try to access them directly I get a 403 error. The only way to make them work is to manually re-chmod the files/ directory (or the files themselves) to 755/777.

Any idea why this might be happening? I've seen a couple of similar problems on the forum but none of the solutions has worked for me.

Any help would be much appreciated!

PS my phpinfo() can be see here:

http://r33769.ovh.net/~scotlawc/info.php...

And I'm running 5.4.0.5 :)

melat0nin
 
nteaviation replied on at Permalink Reply
nteaviation
What owner, group and permissions do the newly uploaded files get prior to you having to chmod them? What owner, group and permissions are on the /files folder?
melat0nin replied on at Permalink Reply
melat0nin
Thanks for the reply.

Here's the output of ls -l:

drwxrwxrwx 19 scotlawc users 4096 2010-05-27 12:51 files

and when I upload a file, it gets these permissions (before I chmod):

-rw-r--r-- 1 scotlawc users 9309 2010-05-27 15:13 homepage.png

Any thoughts?
nteaviation replied on at Permalink Reply
nteaviation
Look in the filemanager under the "Access" tab. Is the Guest set to "Yes"? Are you using the filemanager assigned URL to acces the files (likehttp://www.mysite.com/file/1612/7256/1610/filename.png)?... This URL can be found in the file properties in the filemanager.
melat0nin replied on at Permalink Reply
melat0nin
Guest is set to 'yes'.

I can't access the files directly via their URL - I get a 403 :(

When I try to view them in the filemanager, it's blank. Also, no thumbnails are generated (probably because c5 can't access the files to do it).
nteaviation replied on at Permalink Reply
nteaviation
In that same access tab, where is the "standard File Location" pointing to? Also, check the Alternate Storage Directory.
melat0nin replied on at Permalink Reply
melat0nin
The standard location is set to where I would expect it to be i.e. /home/username/www/files

There's nothing set in the alternative location fields.
nteaviation replied on at Permalink Reply
nteaviation
And when you chmod the files the filemanager loves them ( you get thumbnails, can edit, etc...) and the direct URL works fine.
melat0nin replied on at Permalink Reply
melat0nin
@nteaviation

That's right.. once I've chmodded them, everything works as it should.
nteaviation replied on at Permalink Reply
nteaviation
Wow, this is wierd. Are there any .htaccess settings getting in your way? What user does your webserver process run as? I'm starting to run out of things to look at :(
melat0nin replied on at Permalink Reply
melat0nin
Here's the output of 'ps -FA | grep apache'

root     31733     1  0  1730  2896   1 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31738 31733  0  1764  2344   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31739 31733  0  1783  2492   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31740 31733  0  1764  2292   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31741 31733  0  1764  2340   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31747 31733  0  1777  2432   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31754 31733  0  1843  2592   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31755 31733  0  1777  2432   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31756 31733  0  1775  2440   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31757 31733  0  1764  2292   0 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
nobody   31769 31733  0  1730  1804   1 22:50 ?        00:00:00 /usr/local/apache/bin/httpd -D SSL -k start
root     32154 31402  0   442   708   1 22:54 pts/0    00:00:00 grep --colour=auto apache


I'm not sure what that means.

I've emptied .htaccess (it just had the c5 url-rewriting stuff in it) but that didn't help.
jjdb210 replied on at Permalink Reply
jjdb210
I'm with nteaviation, that it's probably that the apache process is on a different user/group, but because it looks like even if it is, it should still be able to read with the permissions you have set for world (read)... That said though, if it turns out that it isn't it.....

It makes me think that maybe you have all file paths set to run through the CGI wrapper, and so the issue is coming from the fact that the execute flag isn't set...

So I guess that's my question: do you have apache processing all urls through php/cgi? What happens if you set it to manually to 700, how about 070?
melat0nin replied on at Permalink Reply
melat0nin
I'm not sure.. does the phpinfo link in my first post tell you this? I don't know how to check.
jjdb210 replied on at Permalink Best Answer Reply
jjdb210
At this point (given that the read flag is set, and it seems to be activating the execute flag is what solves the problem), my gut is telling me that your probably running some form of suPHP and that the issue is with the default umask set for php upload scripts...

Do you have access to a server config file called suphp.conf? It's normally buried in /usr/local/etc/suphp.conf or /etc/suphp.conf

If yes look for a line says:
umask=0133 and change it to
umask=0022

if you can find that line, then restart apache (apachectl restart), and hopefully all will be solved...
melat0nin replied on at Permalink Reply
melat0nin
That worked!!

umask was set to 0033 not 0133, but I changed it to 0022 anyway and that did the trick. Many thanks :)