Hello people.

I was wondering what runfcgi's umask argument is meant to do. When I first 
met it I though it would set the permissions mask for my fcgi socket. 
runfgi's help told another thing instead:

    umask to use when daemonizing, in octal notation (default 022).

And it is right. That's what it does. When daemonize=false, it will set the 
umask for Django child processes, effectively changing default permissions 
for newly created files, including the socket. When daemonize=true, it will 
do nothing.

What sense makes that? Is there any case in where I would like my Django 
process umask to be different when I run it in the background than when I 
run it on the foreground? I can't think of any. Is there even any logical 
reason for the default umask for new files setting to be a runfcgi argument?

On the other hand, I feel a flagrant miss: I need to set the permission 
mask just for my socket, not for other files. I want my web server being 
run as a different user and I want it to be able to write on the socket, 
but not to overwrite uploaded files, for example. I am not entirely alone. 
There are questions like this in StackOverflow [1], in this list [2], in 
the IRC logs [3] and I would bet there is many people suffering it in 
silence.

>From my point of view, this is what runfcgi should tell in the help and do 
about umask:

    UNIX socket umask, in octal notation (default 022)

And in fact, this is really easy to get. Just go to 
django/core/servers/fastcgi.py and change line 172 which looks like this:

    daemon_kwargs['umask'] = int(options['umask'], 8)

To this:

    wsgi_opts['umask'] = int(options['umask'], 8)

And done! Now it will have exactly the -- from my point of view -- sensible 
behaviour. The socket will be created with the specified umask and other 
files created from Django, like uploaded files, will remain with their 
default umask. It's so easy to fix and return it to sanity that I almost 
can't believe it's not a covert bug.

I would like to read your thoughts on the matter.

- Juan Luis

[1] http://stackoverflow.com/a/15135644/1777162
[2] 
https://groups.google.com/forum/#!searchin/django-developers/umask/django-developers/XVlh-uF-ffE/tFYAQVLyK1QJ
[3] http://django-irc-logs.com/search/?q=umask

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to