568
by Francois Marier
Ensure settings.py has the right permissions and ownership (bug #808560) |
1 |
import os, stat, sys |
2 |
||
3 |
INSTALL_PATH = '/usr/share/libravatar/' |
|
4 |
CONFIG_FILE = INSTALL_PATH + 'libravatar/settings.py' |
|
5 |
||
6 |
# Make sure the config file is protected against unauthorized changes
|
|
7 |
if (os.stat(CONFIG_FILE).st_uid != 0) or (os.stat(CONFIG_FILE).st_gid != 0): |
|
8 |
print "settings.py file must be owned by root:root" |
|
9 |
sys.exit(1) |
|
10 |
group_writable = bool(os.stat(CONFIG_FILE).st_mode & stat.S_IWGRP) |
|
11 |
other_writable = bool(os.stat(CONFIG_FILE).st_mode & stat.S_IWOTH) |
|
12 |
if group_writable or other_writable: |
|
13 |
print "settings.py file must only be writable by its owner" |
|
14 |
sys.exit(2) |
|
15 |
||
147
by Francois Marier
Switch to mod_wsgi and Postgres to match production environment |
16 |
os.environ['DJANGO_SETTINGS_MODULE'] = 'libravatar.settings' |
17 |
||
568
by Francois Marier
Ensure settings.py has the right permissions and ownership (bug #808560) |
18 |
if INSTALL_PATH not in sys.path: |
19 |
sys.path.append(INSTALL_PATH) |
|
147
by Francois Marier
Switch to mod_wsgi and Postgres to match production environment |
20 |
|
938.1.5
by Francois Marier
Update to the new way to do WSGI scripts |
21 |
from django.core.wsgi import get_wsgi_application |
22 |
application = get_wsgi_application() |