Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Ubuntu 12.04 Precise with a DUNG (Django, Unix, Nginx & Gunicorn) environment and my app (as well as various config files) is stored in a python virtual environment inside /srv, which the www-data user has access to.

The nginx & gunicorn processes are all run as www-data.

My web app requires secure credentials which I am storing in an file. This file contains various exports and is run using source before the gunicorn processes execute.

My concern is the location of the file and it's permissions. Will it be okay storing this file inside the /srv folder where the www-data has access to it? Or should it be stored and owned by root somewhere else such as /var/myapp/

Also, regarding the www-data user, if any of my web processes (which are run as www-data) are compromised and someone gains access to them, does that mean that the user could potentially read any file on the system, even if they can't write? Including my secure keys?

share|improve this question
+1 for making me laugh. I've never heard the acronym "DUNG" before. – Tom O'Connor Nov 29 '12 at 19:53

You can set user and group IDs in gunicorn configuration that will be used by the worker processes. Set the environmental variables in file owned by root and without read permissions (rw-------). This will save your compromised www-data proccess from reading data directly from configuration file, but compromised www-data proccess can still read variables directly from memory.

ps. +1 for DUNG :)

share|improve this answer

Your Answer


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.