Commit 3b6f367e by Tomas Hlavacek

Move config file to an arbitrary path.

Implement loading of config.py from arbitrary path. The file potentially contains sensitive material like passwords, usernames, list of routers etc. and should be placed outside the www root directory.
parent 2de45733
......@@ -16,6 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Router config file
config_file = '/etc/ulg/config.py'
# HTML presentation settings
header = 'Universal looking glass test header'
refresh_interval = 5 # interval of html refresh
......
......@@ -21,7 +21,6 @@
import os, sys
import random
import config
import defaults
import ulgmodel
......@@ -33,6 +32,8 @@ import re
import time
import traceback
config = ulgmodel.import_config()
def testRouterCommand(router=0,command=0,params=[]):
r = config.routers[router]
......
......@@ -24,11 +24,12 @@ import time, datetime
import pickle
import re
import config
import defaults
import ulgmodel
config = ulgmodel.import_config()
### ULG cron script
SESSION_FILE_REGEX='^ulg-.*\.session$'
......
......@@ -32,12 +32,13 @@ import md5
import time
import random
import config
import defaults
import ulgmodel
import whois
config = ulgmodel.import_config()
IPV4_ANNOTATE_REGEXP = '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(/[0-9]{1,2})?)'
ipv4_annotate_regexp = re.compile(IPV4_ANNOTATE_REGEXP)
......
......@@ -20,6 +20,7 @@
# Imports
import os
import re
import sys
from time import localtime, strftime
from genshi.template import TemplateLoader
from genshi.core import Markup
......@@ -49,6 +50,14 @@ def debug(message):
if(defaults.debug):
log('DEBUG:' + message)
def import_config():
path, filename = os.path.split(defaults.config_file)
filename, ext = os.path.splitext(filename)
sys.path.append(path)
module = __import__(filename)
reload(module)
del sys.path[-1]
return module
def annotateAS(asn):
return asn+' | '+whois.lookup_as_name(asn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment