Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to make the files that created by webserver (Apache, lighttpd, ...) can be writable by the ftp users. Adding apache to nobody group and the vise versa. umask 002 for ftp works fine. But the webserver seems to ignore my umask setting in /etc/sysconfig/:

grep umask /etc/sysconfig/httpd 
umask 002

or /etc/init.d/:

start() {
    echo -n $"Starting $prog: "
    umask 002
    daemon $lighttpd -f $LIGHTTPD_CONF_PATH
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
    return $RETVAL
}

That files are still created with 755 permission:

-rwxr-xr-x 1 apache nobody 28243 Jul 28 09:49 ssvzone_997.js
-rwxr-xr-x 1 apache nobody 26224 Jul 28 09:49 ssvzone_998.js
-rwxr-xr-x 1 apache nobody 19686 Jul 28 09:49 ssvzone_999.js

-rwxr-xr-x 1 lighttpd nobody 23949 Jul 29 15:50 ssvzone_999_1.js
-rwxr-xr-x 1 lighttpd nobody 20668 Jul 29 15:50 ssvzone_999_2.js
-rwxr-xr-x 1 lighttpd nobody 22294 Jul 29 15:50 ssvzone_999_3.js

So, what is the root cause?

PS: I saw the some similar questions but none of them can help.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Don't know why file_put_contents() function creates files with 755 permission but @chmod 664 do a trick.

share|improve this answer
    
Looks like I was correct then. Your app isn't asking for the w bit to be set so it's nothing to do with umask :) –  Iain Aug 2 '11 at 6:22
add comment

Umask doesn't set bits. It could be that the application that creates the files doesn't ask for the group w bit to be set or that it explicitly chmods the file itself to be 'safe'.

What does a simple php script report for the umask ?

<?php 
    system ("umask");
?>

On a CentOS system I have to hand it reports the default 0022 or whatever I set it to in /etc/sysconfig/httpd

share|improve this answer
    
Thanks for your tip. It returns 0002. –  quanta Jul 29 '11 at 10:02
    
@quanta: I would definitely be looking at what creates the files then. –  Iain Jul 29 '11 at 12:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.