We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't install new certificates with certbot-apache under Gentoo since version 0.20.0
It seems that version 0.20.0 has a major architecture revision from 0.19.0, in particular regarding OS specific overrides. But the Gentoo overrides have a flaw when trying to install a new certificate : at one point it tries to run "apache2ctl -t -D DUMP_MODULES", which is no good at all under Gentoo because apache2ctl is a dummy script redirecting to /etc/init.d/apache2. It generates this error :

`Error in checking parameter list: /etc/init.d/apache2: invalid option -- 't'`

## My operating system is (include version):
Gentoo

## I installed Certbot with (certbot-auto, OS package manager, pip, etc):
OS package manager (emerge) with testing (~amd64) flag

## I ran this command and it produced this output:
```
certbot -d test.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for test.example.com
Waiting for verification...
Cleaning up challenges
Error in checking parameter list: /etc/init.d/apache2: invalid option -- 't'

Apache is unable to check whether or not the module is loaded because Apache is misconfigured.
```

## Certbot's behavior differed from what I expected because:
Certbot did not install the certificate because it failed to run apache2ctl -t -D DUMP_MODULES

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `certbot-apache/certbot_apache/override_gentoo.py`
Content:
```
1 """ Distribution specific override class for Gentoo Linux """
2 import pkg_resources
3 
4 import zope.interface
5 
6 from certbot import interfaces
7 
8 from certbot_apache import apache_util
9 from certbot_apache import configurator
10 from certbot_apache import parser
11 
12 @zope.interface.provider(interfaces.IPluginFactory)
13 class GentooConfigurator(configurator.ApacheConfigurator):
14     """Gentoo specific ApacheConfigurator override class"""
15 
16     OS_DEFAULTS = dict(
17         server_root="/etc/apache2",
18         vhost_root="/etc/apache2/vhosts.d",
19         vhost_files="*.conf",
20         logs_root="/var/log/apache2",
21         version_cmd=['/usr/sbin/apache2', '-v'],
22         apache_cmd="apache2ctl",
23         restart_cmd=['apache2ctl', 'graceful'],
24         conftest_cmd=['apache2ctl', 'configtest'],
25         enmod=None,
26         dismod=None,
27         le_vhost_ext="-le-ssl.conf",
28         handle_mods=False,
29         handle_sites=False,
30         challenge_location="/etc/apache2/vhosts.d",
31         MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
32             "certbot_apache", "options-ssl-apache.conf")
33     )
34 
35     def get_parser(self):
36         """Initializes the ApacheParser"""
37         return GentooParser(
38             self.aug, self.conf("server-root"), self.conf("vhost-root"),
39             self.version, configurator=self)
40 
41 
42 class GentooParser(parser.ApacheParser):
43     """Gentoo specific ApacheParser override class"""
44     def __init__(self, *args, **kwargs):
45         # Gentoo specific configuration file for Apache2
46         self.apacheconfig_filep = "/etc/conf.d/apache2"
47         super(GentooParser, self).__init__(*args, **kwargs)
48 
49     def update_runtime_variables(self):
50         """ Override for update_runtime_variables for custom parsing """
51         self.parse_sysconfig_var()
52 
53     def parse_sysconfig_var(self):
54         """ Parses Apache CLI options from Gentoo configuration file """
55         defines = apache_util.parse_define_file(self.apacheconfig_filep,
56                                                 "APACHE2_OPTS")
57         for k in defines.keys():
58             self.variables[k] = defines[k]
59
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/certbot-apache/certbot_apache/override_gentoo.py b/certbot-apache/certbot_apache/override_gentoo.py
--- a/certbot-apache/certbot_apache/override_gentoo.py
+++ b/certbot-apache/certbot_apache/override_gentoo.py
@@ -49,6 +49,7 @@
     def update_runtime_variables(self):
         """ Override for update_runtime_variables for custom parsing """
         self.parse_sysconfig_var()
+        self.update_modules()
 
     def parse_sysconfig_var(self):
         """ Parses Apache CLI options from Gentoo configuration file """
@@ -56,3 +57,10 @@
                                                 "APACHE2_OPTS")
         for k in defines.keys():
             self.variables[k] = defines[k]
+
+    def update_modules(self):
+        """Get loaded modules from httpd process, and add them to DOM"""
+        mod_cmd = [self.configurator.constant("apache_cmd"), "modules"]
+        matches = self.parse_from_subprocess(mod_cmd, r"(.*)_module")
+        for mod in matches:
+            self.add_mod(mod.strip())

{"golden_diff": "diff --git a/certbot-apache/certbot_apache/override_gentoo.py b/certbot-apache/certbot_apache/override_gentoo.py\n--- a/certbot-apache/certbot_apache/override_gentoo.py\n+++ b/certbot-apache/certbot_apache/override_gentoo.py\n@@ -49,6 +49,7 @@\n     def update_runtime_variables(self):\n         \"\"\" Override for update_runtime_variables for custom parsing \"\"\"\n         self.parse_sysconfig_var()\n+        self.update_modules()\n \n     def parse_sysconfig_var(self):\n         \"\"\" Parses Apache CLI options from Gentoo configuration file \"\"\"\n@@ -56,3 +57,10 @@\n                                                 \"APACHE2_OPTS\")\n         for k in defines.keys():\n             self.variables[k] = defines[k]\n+\n+    def update_modules(self):\n+        \"\"\"Get loaded modules from httpd process, and add them to DOM\"\"\"\n+        mod_cmd = [self.configurator.constant(\"apache_cmd\"), \"modules\"]\n+        matches = self.parse_from_subprocess(mod_cmd, r\"(.*)_module\")\n+        for mod in matches:\n+            self.add_mod(mod.strip())\n", "issue": "Can't install new certificates with certbot-apache under Gentoo since version 0.20.0\nIt seems that version 0.20.0 has a major architecture revision from 0.19.0, in particular regarding OS specific overrides. But the Gentoo overrides have a flaw when trying to install a new certificate : at one point it tries to run \"apache2ctl -t -D DUMP_MODULES\", which is no good at all under Gentoo because apache2ctl is a dummy script redirecting to /etc/init.d/apache2. It generates this error :\r\n\r\n`Error in checking parameter list: /etc/init.d/apache2: invalid option -- 't'`\r\n\r\n## My operating system is (include version):\r\nGentoo\r\n\r\n## I installed Certbot with (certbot-auto, OS package manager, pip, etc):\r\nOS package manager (emerge) with testing (~amd64) flag\r\n\r\n## I ran this command and it produced this output:\r\n```\r\ncertbot -d test.example.com\r\nSaving debug log to /var/log/letsencrypt/letsencrypt.log\r\nPlugins selected: Authenticator apache, Installer apache\r\nObtaining a new certificate\r\nPerforming the following challenges:\r\ntls-sni-01 challenge for test.example.com\r\nWaiting for verification...\r\nCleaning up challenges\r\nError in checking parameter list: /etc/init.d/apache2: invalid option -- 't'\r\n\r\nApache is unable to check whether or not the module is loaded because Apache is misconfigured.\r\n```\r\n\r\n## Certbot's behavior differed from what I expected because:\r\nCertbot did not install the certificate because it failed to run apache2ctl -t -D DUMP_MODULES\n", "before_files": [{"content": "\"\"\" Distribution specific override class for Gentoo Linux \"\"\"\nimport pkg_resources\n\nimport zope.interface\n\nfrom certbot import interfaces\n\nfrom certbot_apache import apache_util\nfrom certbot_apache import configurator\nfrom certbot_apache import parser\n\n@zope.interface.provider(interfaces.IPluginFactory)\nclass GentooConfigurator(configurator.ApacheConfigurator):\n    \"\"\"Gentoo specific ApacheConfigurator override class\"\"\"\n\n    OS_DEFAULTS = dict(\n        server_root=\"/etc/apache2\",\n        vhost_root=\"/etc/apache2/vhosts.d\",\n        vhost_files=\"*.conf\",\n        logs_root=\"/var/log/apache2\",\n        version_cmd=['/usr/sbin/apache2', '-v'],\n        apache_cmd=\"apache2ctl\",\n        restart_cmd=['apache2ctl', 'graceful'],\n        conftest_cmd=['apache2ctl', 'configtest'],\n        enmod=None,\n        dismod=None,\n        le_vhost_ext=\"-le-ssl.conf\",\n        handle_mods=False,\n        handle_sites=False,\n        challenge_location=\"/etc/apache2/vhosts.d\",\n        MOD_SSL_CONF_SRC=pkg_resources.resource_filename(\n            \"certbot_apache\", \"options-ssl-apache.conf\")\n    )\n\n    def get_parser(self):\n        \"\"\"Initializes the ApacheParser\"\"\"\n        return GentooParser(\n            self.aug, self.conf(\"server-root\"), self.conf(\"vhost-root\"),\n            self.version, configurator=self)\n\n\nclass GentooParser(parser.ApacheParser):\n    \"\"\"Gentoo specific ApacheParser override class\"\"\"\n    def __init__(self, *args, **kwargs):\n        # Gentoo specific configuration file for Apache2\n        self.apacheconfig_filep = \"/etc/conf.d/apache2\"\n        super(GentooParser, self).__init__(*args, **kwargs)\n\n    def update_runtime_variables(self):\n        \"\"\" Override for update_runtime_variables for custom parsing \"\"\"\n        self.parse_sysconfig_var()\n\n    def parse_sysconfig_var(self):\n        \"\"\" Parses Apache CLI options from Gentoo configuration file \"\"\"\n        defines = apache_util.parse_define_file(self.apacheconfig_filep,\n                                                \"APACHE2_OPTS\")\n        for k in defines.keys():\n            self.variables[k] = defines[k]\n", "path": "certbot-apache/certbot_apache/override_gentoo.py"}], "after_files": [{"content": "\"\"\" Distribution specific override class for Gentoo Linux \"\"\"\nimport pkg_resources\n\nimport zope.interface\n\nfrom certbot import interfaces\n\nfrom certbot_apache import apache_util\nfrom certbot_apache import configurator\nfrom certbot_apache import parser\n\n@zope.interface.provider(interfaces.IPluginFactory)\nclass GentooConfigurator(configurator.ApacheConfigurator):\n    \"\"\"Gentoo specific ApacheConfigurator override class\"\"\"\n\n    OS_DEFAULTS = dict(\n        server_root=\"/etc/apache2\",\n        vhost_root=\"/etc/apache2/vhosts.d\",\n        vhost_files=\"*.conf\",\n        logs_root=\"/var/log/apache2\",\n        version_cmd=['/usr/sbin/apache2', '-v'],\n        apache_cmd=\"apache2ctl\",\n        restart_cmd=['apache2ctl', 'graceful'],\n        conftest_cmd=['apache2ctl', 'configtest'],\n        enmod=None,\n        dismod=None,\n        le_vhost_ext=\"-le-ssl.conf\",\n        handle_mods=False,\n        handle_sites=False,\n        challenge_location=\"/etc/apache2/vhosts.d\",\n        MOD_SSL_CONF_SRC=pkg_resources.resource_filename(\n            \"certbot_apache\", \"options-ssl-apache.conf\")\n    )\n\n    def get_parser(self):\n        \"\"\"Initializes the ApacheParser\"\"\"\n        return GentooParser(\n            self.aug, self.conf(\"server-root\"), self.conf(\"vhost-root\"),\n            self.version, configurator=self)\n\n\nclass GentooParser(parser.ApacheParser):\n    \"\"\"Gentoo specific ApacheParser override class\"\"\"\n    def __init__(self, *args, **kwargs):\n        # Gentoo specific configuration file for Apache2\n        self.apacheconfig_filep = \"/etc/conf.d/apache2\"\n        super(GentooParser, self).__init__(*args, **kwargs)\n\n    def update_runtime_variables(self):\n        \"\"\" Override for update_runtime_variables for custom parsing \"\"\"\n        self.parse_sysconfig_var()\n        self.update_modules()\n\n    def parse_sysconfig_var(self):\n        \"\"\" Parses Apache CLI options from Gentoo configuration file \"\"\"\n        defines = apache_util.parse_define_file(self.apacheconfig_filep,\n                                                \"APACHE2_OPTS\")\n        for k in defines.keys():\n            self.variables[k] = defines[k]\n\n    def update_modules(self):\n        \"\"\"Get loaded modules from httpd process, and add them to DOM\"\"\"\n        mod_cmd = [self.configurator.constant(\"apache_cmd\"), \"modules\"]\n        matches = self.parse_from_subprocess(mod_cmd, r\"(.*)_module\")\n        for mod in matches:\n            self.add_mod(mod.strip())\n", "path": "certbot-apache/certbot_apache/override_gentoo.py"}]}