aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuildtools/subst-vars.py28
-rwxr-xr-xconfigure5
-rw-r--r--configure.ac3
-rw-r--r--rpkid/Makefile.in16
-rw-r--r--rpkid/portal-gui/default_settings.py48
-rw-r--r--rpkid/portal-gui/rpki.wsgi.in2
-rw-r--r--rpkid/rpki/gui/default_settings.py (renamed from rpkid/portal-gui/settings.py.in)72
7 files changed, 60 insertions, 114 deletions
diff --git a/buildtools/subst-vars.py b/buildtools/subst-vars.py
deleted file mode 100755
index 5083c2dd..00000000
--- a/buildtools/subst-vars.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# $Id$
-
-"""
-Copyright (C) 2011 SPARTA, Inc., dba Cobham Analytic Solutions
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-"""
-
-
-import os, sys
-
-# pull out all AC_* environment variables into a dict to substitute in the input file
-d = {}
-for v in os.environ:
- if v.startswith('AC_'):
- d[v] = os.environ[v]
-
-sys.stdout.write(sys.stdin.read() % d)
diff --git a/configure b/configure
index 482065ff..7755f62a 100755
--- a/configure
+++ b/configure
@@ -604,7 +604,6 @@ LIBOBJS
WSGI_PROCESS_GROUP
WSGI_DAEMON_PROCESS
DJANGO_ADMIN
-SECRET_KEY
OPENSSL_SO_GLOB
OPENSSL_CONFIG_COMMAND
TOP_LEVEL_SUBDIRS
@@ -4878,10 +4877,6 @@ fi
if test $build_ca_tools = yes
then
- # Source: http://blog.leosoto.com/2008/04/django-secretkey-generation.html
- SECRET_KEY=`$PYTHON -c 'import random; print "".join(random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50))'`
-
-
# There is no standard name for this tool, so check for it.
for ac_prog in django-admin django-admin.py
do
diff --git a/configure.ac b/configure.ac
index ac261db3..b0e2f6d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -699,9 +699,6 @@ fi
if test $build_ca_tools = yes
then
- # Source: http://blog.leosoto.com/2008/04/django-secretkey-generation.html
- AC_SUBST(SECRET_KEY, `$PYTHON -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'`)
-
# There is no standard name for this tool, so check for it.
AC_PATH_PROGS(DJANGO_ADMIN, [django-admin django-admin.py])
diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in
index 6bcd03e9..dd0c5eb4 100644
--- a/rpkid/Makefile.in
+++ b/rpkid/Makefile.in
@@ -5,7 +5,6 @@ SUBDIRS = portal-gui
PYTHON = @PYTHON@
TRANG = @TRANG@
-SECRET_KEY = @SECRET_KEY@
DJANGO_ADMIN = @DJANGO_ADMIN@
CFLAGS = @CFLAGS@
@@ -74,12 +73,9 @@ BUILD_SCRIPTS = \
DATA_FILES = portal-gui/routeviews.sh
# these files get put in ${sysconfdir}/rpki
-CONF_FILES = portal-gui/apache.conf portal-gui/default_settings.py ${SETTINGS}
+CONF_FILES = portal-gui/apache.conf
-# automatically generated config files
-SETTINGS=portal-gui/settings.py
-
-all:: ${POW_SO} rpki/relaxng.py myrpki.rng rpki/sql_schemas.py ${SCRIPTS} ${SETTINGS} ${BUILD_SCRIPTS}
+all:: ${POW_SO} rpki/relaxng.py myrpki.rng rpki/sql_schemas.py ${SCRIPTS} ${BUILD_SCRIPTS}
${POW_SO}: ext/POW.c setup.py
${SETUP_PY} build_ext --inplace
@@ -224,11 +220,6 @@ COMPILE_PYTHON = \
${PYTHON} ${abs_top_srcdir}/buildtools/make-python-executable.py <$? >$@; \
chmod 555 $@
-COMPILE_SETTINGS = \
- rm -f $@; \
- AC_SECRET_KEY='${SECRET_KEY}' \
- ${PYTHON} ${abs_top_srcdir}/buildtools/subst-vars.py <$? >$@
-
rpki-sql-backup: rpki-sql-backup.py
${COMPILE_PYTHON}
@@ -273,9 +264,6 @@ portal-gui/rpki.wsgi: ${srcdir}/portal-gui/rpki.wsgi.in
sed -e "s|@PYTHON""PATH@|${sysconfdir}/rpki|" \
${srcdir}/portal-gui/rpki.wsgi.in > portal-gui/rpki.wsgi
-portal-gui/settings.py: ${srcdir}/portal-gui/settings.py.in
- ${COMPILE_SETTINGS}
-
portal-gui/scripts/rpki-manage: ${srcdir}/portal-gui/scripts/rpki-manage.in
sed -e "s|@DJANGO""_ADMIN@|${DJANGO_ADMIN}|" \
-e "s|@PYTHON""PATH@|${sysconfdir}/rpki|" \
diff --git a/rpkid/portal-gui/default_settings.py b/rpkid/portal-gui/default_settings.py
deleted file mode 100644
index 3d3e3f51..00000000
--- a/rpkid/portal-gui/default_settings.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""
-This module contains static configuration settings for the web portal.
-"""
-
-__version__ = '$Id$'
-
-import os
-from rpki import autoconf
-
-# where to put static files
-STATIC_ROOT = autoconf.datarootdir + '/rpki/media'
-
-# must end with a slash!
-STATIC_URL = '/media/'
-
-# where to email server errors
-ADMINS = (('Administrator', 'root@localhost'),)
-
-LOGGING = {
- 'version': 1,
- 'formatters': {
- 'verbose': {
- # see http://docs.python.org/2.7/library/logging.html#logging.LogRecord
- 'format': '%(levelname)s %(asctime)s %(name)s %(message)s'
- },
- },
- 'handlers': {
- 'stderr': {
- 'class': 'logging.StreamHandler',
- 'level': 'DEBUG',
- 'formatter': 'verbose',
- },
- 'mail_admins': {
- 'level': 'ERROR',
- 'class': 'django.utils.log.AdminEmailHandler',
- },
- },
- 'loggers': {
- 'django': {
- 'level': 'ERROR',
- 'handlers': ['stderr', 'mail_admins'],
- },
- 'rpki.gui': {
- 'level': 'WARNING',
- 'handlers': ['stderr'],
- },
- },
-}
diff --git a/rpkid/portal-gui/rpki.wsgi.in b/rpkid/portal-gui/rpki.wsgi.in
index d6b12350..8fedf93e 100644
--- a/rpkid/portal-gui/rpki.wsgi.in
+++ b/rpkid/portal-gui/rpki.wsgi.in
@@ -20,7 +20,7 @@ __version__ = '$Id$'
import sys
import os
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings'
sys.path.insert(1, '@PYTHONPATH@')
import django.core.handlers.wsgi
diff --git a/rpkid/portal-gui/settings.py.in b/rpkid/rpki/gui/default_settings.py
index f352874d..eadb570a 100644
--- a/rpkid/portal-gui/settings.py.in
+++ b/rpkid/rpki/gui/default_settings.py
@@ -1,16 +1,55 @@
-#
-# Sample Django settings.py for running the RPKI portal gui. This
-# template was written for Django 1.3.
-#
-# DO NOT EDIT! This file is automatically generated from
-# settings.py.in
-
+"""
+This module contains static configuration settings for the web portal.
+"""
__version__ = '$Id$'
-import rpki.config
-import os.path
+import os
+import random
+import string
+import rpki.config
+import rpki.autoconf
+
+# where to put static files
+STATIC_ROOT = rpki.autoconf.datarootdir + '/rpki/media'
+
+# must end with a slash!
+STATIC_URL = '/media/'
+
+# where to email server errors
+ADMINS = (('Administrator', 'root@localhost'),)
+
+LOGGING = {
+ 'version': 1,
+ 'formatters': {
+ 'verbose': {
+ # see http://docs.python.org/2.7/library/logging.html#logging.LogRecord
+ 'format': '%(levelname)s %(asctime)s %(name)s %(message)s'
+ },
+ },
+ 'handlers': {
+ 'stderr': {
+ 'class': 'logging.StreamHandler',
+ 'level': 'DEBUG',
+ 'formatter': 'verbose',
+ },
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'class': 'django.utils.log.AdminEmailHandler',
+ },
+ },
+ 'loggers': {
+ 'django': {
+ 'level': 'ERROR',
+ 'handlers': ['stderr', 'mail_admins'],
+ },
+ 'rpki.gui': {
+ 'level': 'WARNING',
+ 'handlers': ['stderr'],
+ },
+ },
+}
# load the sql authentication bits from the system rpki.conf
rpki_config = rpki.config.parser(section='web_portal')
@@ -50,8 +89,16 @@ def select_tz():
# system time zone.
TIME_ZONE = select_tz()
+
+def get_secret_key():
+ """Retrieve the secret-key value from rpki.conf or generate a random value
+ if it is not present."""
+ d = string.letters + string.digits
+ val = ''.join([random.choice(d) for _ in range(50)])
+ return rpki_config.get('secret-key', val)
+
# Make this unique, and don't share it with anybody.
-SECRET_KEY = '%(AC_SECRET_KEY)s'
+SECRET_KEY = get_secret_key()
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
@@ -94,11 +141,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.static"
)
-try:
- from default_settings import *
-except:
- pass
-
# allow local site to override any setting above
try:
from local_settings import *