[llvm-commits] [LNT] r154548 - in /lnt/trunk/lnt: lnttool/create.py server/config.py server/ui/app.py
Daniel Dunbar
daniel at zuster.org
Wed Apr 11 16:14:27 PDT 2012
Author: ddunbar
Date: Wed Apr 11 18:14:27 2012
New Revision: 154548
URL: http://llvm.org/viewvc/llvm-project?rev=154548&view=rev
Log:
[users] Include a secret key in the LNT config.
Modified:
lnt/trunk/lnt/lnttool/create.py
lnt/trunk/lnt/server/config.py
lnt/trunk/lnt/server/ui/app.py
Modified: lnt/trunk/lnt/lnttool/create.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/create.py?rev=154548&r1=154547&r2=154548&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/create.py (original)
+++ lnt/trunk/lnt/lnttool/create.py Wed Apr 11 18:14:27 2012
@@ -1,12 +1,14 @@
+import hashlib
import os
import platform
+import random
import sys
###
kConfigVersion = (0,1,0)
kConfigTemplate = """\
-# LNT (aka Zorg) configuration file
+# LNT configuration file
#
# Paths are resolved relative to this file.
@@ -29,6 +31,9 @@
# paths are resolved relative to the config path + this path.
db_dir = %(db_dir)r
+# Secret key for this server instance.
+secret_key = %(secret_key)r
+
# The list of available databases, and their properties. At a minimum, there
# should be a 'default' entry for the default database.
databases = {
@@ -97,6 +102,8 @@
help="name of the directory to hold databases")
parser.add_option("", "--default-db", dest="default_db", default="lnt.db",
help="name for the default db [%default]", metavar="NAME")
+ parser.add_option("", "--secret-key", dest="secret_key", default=None,
+ help="secret key to use for this installation")
parser.add_option("", "--hostname", dest="hostname",
default=platform.uname()[1],
help="host name of the server [%default]", metavar="NAME")
@@ -132,6 +139,8 @@
db_path = os.path.join(db_dir_path, default_db)
tmp_path = os.path.join(basepath, tmp_dir)
wsgi_path = os.path.join(basepath, wsgi)
+ secret_key = (opts.secret_key or
+ hashlib.sha1(str(random.getrandbits(256))).hexdigest())
os.mkdir(path)
os.mkdir(db_dir_path)
Modified: lnt/trunk/lnt/server/config.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/config.py?rev=154548&r1=154547&r2=154548&view=diff
==============================================================================
--- lnt/trunk/lnt/server/config.py (original)
+++ lnt/trunk/lnt/server/config.py Wed Apr 11 18:14:27 2012
@@ -88,17 +88,20 @@
# FIXME: Remove this default.
tempDir = data.get('tmp_dir', 'viewer/resources/graphs')
+ secretKey = data.get('secret_key', None)
+
return Config(data.get('name', 'LNT'), data['zorgURL'],
- dbDir, os.path.join(baseDir, tempDir),
+ dbDir, os.path.join(baseDir, tempDir), secretKey,
dict([(k,DBInfo.fromData(dbDirPath, v,
default_email_config))
for k,v in data['databases'].items()]))
- def __init__(self, name, zorgURL, dbDir, tempDir, databases):
+ def __init__(self, name, zorgURL, dbDir, tempDir, secretKey, databases):
self.name = name
self.zorgURL = zorgURL
self.dbDir = dbDir
self.tempDir = tempDir
+ self.secretKey = secretKey
while self.zorgURL.endswith('/'):
self.zorgURL = zorgURL[:-1]
self.databases = databases
Modified: lnt/trunk/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/app.py?rev=154548&r1=154547&r2=154548&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/app.py (original)
+++ lnt/trunk/lnt/server/ui/app.py Wed Apr 11 18:14:27 2012
@@ -44,6 +44,13 @@
# Utility Methods
def get_db(self):
+ """
+ get_db() -> <db instance>
+
+ Get the active database and add a logging handler if part of the request
+ arguments.
+ """
+
if self.db is None:
echo = bool(self.args.get('db_log') or self.form.get('db_log'))
@@ -61,6 +68,12 @@
return self.db
def get_testsuite(self):
+ """
+ get_testsuite() -> server.db.testsuite.TestSuite
+
+ Get the active testsuite.
+ """
+
if self.testsuite is None:
testsuites = self.get_db().testsuite
if g.testsuite_name not in testsuites:
@@ -119,6 +132,9 @@
lnt.server.ui.globals.register(self)
+ # Set the application secret key.
+ self.secret_key = self.old_config.secretKey
+
def get_db_summary(self, db_name, db):
# FIXME/v3removal: Eliminate this, V4DB style has no need for summary
# abstraction.
@@ -126,4 +142,3 @@
if db_summary is None or not db_summary.is_up_to_date(db):
self.db_summaries[db_name] = db_summary = db.get_db_summary()
return db_summary
-
More information about the llvm-commits
mailing list