From 05aa136d470ead91d6846aeb9a66fbbe882cf23e Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Wed, 11 Mar 2020 17:15:46 -0700 Subject: [PATCH] normalize ssl_module_location path to account for being relative to server root --- .../certbot_apache/_internal/configurator.py | 1 + .../certbot_apache/_internal/parser.py | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/certbot-apache/certbot_apache/_internal/configurator.py b/certbot-apache/certbot_apache/_internal/configurator.py index fcf81ab5b..521dc5f18 100644 --- a/certbot-apache/certbot_apache/_internal/configurator.py +++ b/certbot-apache/certbot_apache/_internal/configurator.py @@ -259,6 +259,7 @@ class ApacheConfigurator(common.Installer): if not ssl_module_location: logger.warning("Could not find ssl_module; not disabling session tickets.") return None + ssl_module_location = self.parser.standard_path_from_server_root(ssl_module_location) # Step 2. Grep in the .so for openssl version contents = self._open_module_file(ssl_module_location) if not contents: diff --git a/certbot-apache/certbot_apache/_internal/parser.py b/certbot-apache/certbot_apache/_internal/parser.py index 4d5f2fda4..82d7df6aa 100644 --- a/certbot-apache/certbot_apache/_internal/parser.py +++ b/certbot-apache/certbot_apache/_internal/parser.py @@ -661,6 +661,25 @@ class ApacheParser(object): return True + def standard_path_from_server_root(self, arg): + """Ensure paths are consistent and absolute + + :param str arg: Argument of directive + + :returns: Standardized argument path + :rtype: str + """ + # Remove beginning and ending quotes + arg = arg.strip("'\"") + + # Standardize the include argument based on server root + if not arg.startswith("/"): + # Normpath will condense ../ + arg = os.path.normpath(os.path.join(self.root, arg)) + else: + arg = os.path.normpath(arg) + return arg + def _get_include_path(self, arg): """Converts an Apache Include directive into Augeas path. @@ -681,16 +700,7 @@ class ApacheParser(object): # if matchObj.group() != arg: # logger.error("Error: Invalid regexp characters in %s", arg) # return [] - - # Remove beginning and ending quotes - arg = arg.strip("'\"") - - # Standardize the include argument based on server root - if not arg.startswith("/"): - # Normpath will condense ../ - arg = os.path.normpath(os.path.join(self.root, arg)) - else: - arg = os.path.normpath(arg) + arg = self.standard_path_from_server_root(arg) # Attempts to add a transform to the file if one does not already exist if os.path.isdir(arg):