From 9b263f9859bb8eed1fdde2f9cd8ae9a8edf7afdc Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 7 Jul 2015 13:18:22 -0700 Subject: [PATCH] outline init path --- letsencrypt_apache/parser.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/letsencrypt_apache/parser.py b/letsencrypt_apache/parser.py index 4a37bc484..f02b34889 100644 --- a/letsencrypt_apache/parser.py +++ b/letsencrypt_apache/parser.py @@ -14,12 +14,17 @@ logger = logging.getLogger(__name__) class ApacheParser(object): """Class handles the fine details of parsing the Apache Configuration. - :ivar str root: Normalized abosulte path to the server root + :ivar str root: Normalized absolute path to the server root directory. Without trailing slash. + .. todo:: Handle UnDefine Directive + .. todo:: Handle Define directive for parameters within find_dirs + """ def __init__(self, aug, root, ssl_options, ctl): # This uses the binary, so it can be done first. + # https://httpd.apache.org/docs/2.4/mod/core.html#ifdefine + # This only handles invocation parameters... not Define directive params self.parameters = self._init_parameters(ctl) # Find configuration root and make sure augeas can parse it. @@ -36,9 +41,15 @@ class ApacheParser(object): self.standardize_excl() # Temporarily set modules to be empty, so that find_dirs can work + # https://httpd.apache.org/docs/2.4/mod/core.html#ifmodule self.modules = set() self._init_modules() + # Set Apache variables + # https://httpd.apache.org/docs/2.4/mod/core.html#define + self.variables = set() + self._init_variables() + def _init_modules(self): """Iterates on the configuration until no new modules are loaded.""" matches = self.find_dir(case_i("LoadModule")) @@ -81,6 +92,14 @@ class ApacheParser(object): matches.remove("DUMP_RUN_CFG") return set(matches) + def _init_variables(self): + #print "Define Directive:", self.find_dir(case_i("Define")) + # This works + #matches = self.aug.match("/files/etc/apache2/apache2.conf/*/* [count(arg) = 2]") + matches = self.aug.match("/files/etc/apache2/apache2.conf/*[self::directive=~regexp('Define')]/arg") + for match in matches: + print match, self.aug.get(match) + def add_dir_to_ifmodssl(self, aug_conf_path, directive, val): """Adds directive and value to IfMod ssl block.