Setting default permissions for files uploaded through php script

Posted on 2004-11-15
Medium Priority
Last Modified: 2013-12-15
The files uploaded to our webserver (using a php script) have default permissions: rw------- which suggests a umask setting of 0066, whereas our system-wide umask is 0022. The files are owned by wwwrun:www(default apache) and the system is SuSE linux.

How do I set the umask for wwwrun so that the files uploaded will have the desired permissions (rw-r--r-- )

Question by:sandeep_th
  • 2
LVL 12

Expert Comment

ID: 12591506
you have to add some script in your php script so that after the uploaded finished than change the umask will do.

or you can use a crontab to run a chmod to make it change to 644 on every 1hr or so.

eg. run 'crontab'

add below in the cron job

* 1 * * chmod 644 /data/www/*

so every an hour the crontab will run and all the files inside the /data/www will become 644 mode.

but the best way is add the chmod script into your php script.

hope can help a bit :)

Author Comment

ID: 12614949
hmmm ... not exactly what I was looking for....but CAN be a possible solution. But the fundamental issue is how can we change the default umask of the wwwrun user....THAT is not addressed by this solution. Any other ideas?
LVL 12

Accepted Solution

paullamhkg earned 200 total points
ID: 12622788
oh I miss understand that you need to add some script or so..

you can change the default umask of the wwwrun by 'umask -p 033 wwwrun' so every file(s) wwwrun create will be 'rw-r--r--', is that what you need?? I think so :)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question