Setting default permissions for files uploaded through php script

Hi,
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-- )

sandeep_thAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

paullamhkgCommented:
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 :)
0
sandeep_thAuthor Commented:
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?
0
paullamhkgCommented:
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 :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.