summaryrefslogtreecommitdiff
path: root/tools/readconfig.py
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2017-02-02 16:08:24 +0100
committerMagnus Ahltorp <map@kth.se>2017-02-02 21:58:38 +0100
commit8a1f3a5f5b1458aceb7567add95e7637e9c2e5fc (patch)
tree188f039cce63266dbe0dcca0477ca63bc983e74d /tools/readconfig.py
parentf481bd4f30a00fa3d4a5b4aecd0f881b1f5b58f5 (diff)
Added tools for getting and generating global config
Diffstat (limited to 'tools/readconfig.py')
-rw-r--r--tools/readconfig.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/readconfig.py b/tools/readconfig.py
index 5079691..69531ca 100644
--- a/tools/readconfig.py
+++ b/tools/readconfig.py
@@ -34,10 +34,7 @@ def errorhandlify(term, filename, path=[]):
print "unknown type", type(term)
sys.exit(1)
-def verify_and_read_config(filename, publickey_base64):
- rawconfig = open(filename).read()
- signature = open(filename + ".sig").read()
-
+def verify_config(rawconfig, signature, publickey_base64, filename):
publickey = base64.decodestring(publickey_base64)
try:
@@ -50,5 +47,13 @@ def verify_and_read_config(filename, publickey_base64):
return errorhandlify(yaml.load(io.BytesIO(rawconfig), yaml.SafeLoader), filename)
+def verify_and_read_config(filename, publickey_base64):
+ rawconfig = open(filename).read()
+ signature = open(filename + ".sig").read()
+
+ verify_config(rawconfig, signature, publickey_base64, filename)
+
+ return errorhandlify(yaml.load(io.BytesIO(rawconfig), yaml.SafeLoader), filename)
+
def read_config(filename):
return errorhandlify(yaml.load(open(filename), yaml.SafeLoader), filename)