file permissions for uploaded files

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Suggested Hosts
Locked
User avatar
shortmort37
Registered User
Posts: 656
Joined: Sat Aug 26, 2006 8:40 pm
Location: Upper Darby, PA, USA
Name: Dan Morton
Contact:

file permissions for uploaded files

Post by shortmort37 »

“People won't change until the pain of not changing is greater than the pain changing brings.” -Just B. Jordan

OK; I've conceded that I'm never going to get to the bottom of my 500 errors when clearing cache on a shared server, as described in excruciating detail here. So I've bit the bullet, and subscribed to a VPS service, where I have control over what gets logged, and what doesn't. The downside, of course, is that I also have to manage the server. Well; I cut my teeth on a PDP-11 running BSD 4.3 in the Seventies, how hard can this be?

It's hard. But, I'm learning. I've got LAMP up and running, and I've ported my site from the shared server to a test environment on my VPS, and it's working. Not surprisingly, when I ported my board to a test environment there, I can clear the cache without triggering 500 errors. Which only substantiates the conjecture that the shared server was resource constrained. Now, my resources are fixed, and can be fully monitored.

But...

All the uploaded files on my shared server had 644 permissions - and, so they do after porting. However, any newly uploaded files have 666 permissions (which, includes world-writeable). For a time, I thought this had something to do with my server configuration, but it doesn't. I've placed this sample code from W3 Schools directly within my phpBB root, and when I use it to upload a file, the permissions are 644. What explains this difference? Is there something configurable with phpBB, that would set the permissions for new uploads to match that of legacy uploads?
Last edited by shortmort37 on Fri Jun 11, 2021 3:58 am, edited 1 time in total.
User avatar
shortmort37
Registered User
Posts: 656
Joined: Sat Aug 26, 2006 8:40 pm
Location: Upper Darby, PA, USA
Name: Dan Morton
Contact:

Re: file permissions for uploaded files

Post by shortmort37 »

Just an update: The W3 Schools example uploads files into directory "upload", which I had placed in my phpBB root, along with upload.html and upload.php. I edited the code to deposit the upload into the <root>/files directory, where phpBB attachments get uploaded. Again, the file permissions on the uploaded file using upload.html were 644; yet, attachment uploads using phpBB into the very same directory have permissions of 666.

Is there any explanation, other than phpBB is explicitly setting these permissions? If so, how can I change the behavior?
User avatar
shortmort37
Registered User
Posts: 656
Joined: Sat Aug 26, 2006 8:40 pm
Location: Upper Darby, PA, USA
Name: Dan Morton
Contact:

Re: file permissions for uploaded files

Post by shortmort37 »

If I echo umask() in the upload.php from W3Schools, it reports 18 (22 octal), as expected. In the grasping at straws dept., shouldn't this line from public function move in Symfony's UploadedFile.php...

Code: Select all

@chmod($target, 0666 & ~umask());
...set the permissions to 644, when the uploaded file is moved from temp to /files?

Hoping for a clue. I've gone down this VPS path, because it was recommended to me I move away from my service provider's shared server services, and my topic was closed; I've followed those recommendations, but now I'm feeling a bit lost.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3726
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: file permissions for uploaded files

Post by Kailey »

Since you posted in the support forum, I'll close this one.. viewtopic.php?f=661&p=15727381#p15727381
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
Locked

Return to “phpBB Discussion”