From f9a57e42934720c20a6a1310ca8f4908a43896bc Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 7 Feb 2019 13:55:52 -0800 Subject: [PATCH] monkeysphere: Fix regression with reading new apache domain config Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/monkeysphere | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/actions/monkeysphere b/actions/monkeysphere index bf7f2b1d3..7b4586cab 100755 --- a/actions/monkeysphere +++ b/actions/monkeysphere @@ -105,8 +105,11 @@ def get_https_keys(fingerprint_hash): aug.set('/augeas/load/Httpd/lens', 'Httpd.lns') aug.set('/augeas/load/Httpd/incl[last() + 1]', '/etc/apache2/sites-available/*') + aug.set('/augeas/load/Httpd/incl[last() + 1]', + '/etc/apache2/conf-available/*') aug.load() + # Read from default-tls.conf and default-ssl.conf keys = {} path = '/files/etc/apache2/sites-available//VirtualHost' for match in aug.match(path): @@ -123,6 +126,23 @@ def get_https_keys(fingerprint_hash): host['key_file'], fingerprint_hash) keys[host['ssh_fingerprint']] = host + # Read from FreedomBox configured domains with proper SSL certs. + path = "/files/etc/apache2/sites-available//" \ + "directive[. = 'Use'][arg[1] = 'FreedomBoxTLSSiteMacro']" + key_file = "/files/etc/apache2//Macro[arg[1] = 'FreedomBoxTLSSiteMacro']//"\ + "VirtualHost/directive[. = 'GnuTLSKeyFile']/arg" + key_file = aug.get(key_file) + for match in aug.match(path): + domain = aug.get(match + '/arg[2]') + host = { + 'available_domains': [domain], + 'service': 'https', + 'key_file': key_file.replace('$domain', domain) + } + host['ssh_fingerprint'] = get_pem_ssh_fingerprint( + host['key_file'], fingerprint_hash) + keys[host['ssh_fingerprint']] = host + return keys