Search code examples
pythondjangodeploymentfastcgi

Socket permissions when running Django with FastCGI


I am running Django fcgi with standard line:

exec setuidgid $USERID $VENVBIN/python $WEBAPP/manage.py runfcgi daemonize=false socket=$FCGISOCKET

Problem is that only group is shared between fastcgi process and webserver, not user - however group do not have write permissions by default (hotfix is running chmod g+w manually).

How to force process to make socket in mode 0770?


Solution

  • ./manage.py runfcgi help says:

    umask=UMASK umask to use when daemonizing (default 022).

    So you just need to run:

    ./manage.py runfcgi socket=$FCGISOCKET umask=007
    

    and a socket with mode 0770 will be created. Please note that umask is being set only when daemonize is set to true (which is default).