From 06a6db0d0dc921527c4667037d7cc9fa000645d5 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Thu, 2 Feb 2017 16:08:24 +0100 Subject: Added tools for getting and generating global config --- tools/readconfig.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tools/readconfig.py') 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) -- cgit v1.1