2015-04-22 04:32:34 -04:00
|
|
|
"""Apache plugin constants."""
|
|
|
|
|
import pkg_resources
|
2016-04-13 19:30:57 -04:00
|
|
|
from certbot import le_util
|
2015-04-22 04:32:34 -04:00
|
|
|
|
|
|
|
|
|
2015-12-03 07:14:02 -05:00
|
|
|
CLI_DEFAULTS_DEBIAN = dict(
|
2015-05-08 17:32:13 -04:00
|
|
|
server_root="/etc/apache2",
|
2015-12-06 15:40:51 -05:00
|
|
|
vhost_root="/etc/apache2/sites-available",
|
2015-12-28 05:56:44 -05:00
|
|
|
vhost_files="*",
|
2015-12-25 03:18:24 -05:00
|
|
|
version_cmd=['apache2ctl', '-v'],
|
|
|
|
|
define_cmd=['apache2ctl', '-t', '-D', 'DUMP_RUN_CFG'],
|
2015-12-28 06:47:14 -05:00
|
|
|
restart_cmd=['apache2ctl', 'graceful'],
|
|
|
|
|
conftest_cmd=['apache2ctl', 'configtest'],
|
2015-05-08 17:32:13 -04:00
|
|
|
enmod="a2enmod",
|
2015-07-30 02:40:07 -04:00
|
|
|
dismod="a2dismod",
|
2015-05-22 03:28:21 -04:00
|
|
|
le_vhost_ext="-le-ssl.conf",
|
2015-12-07 04:07:31 -05:00
|
|
|
handle_mods=True,
|
2015-12-07 05:42:40 -05:00
|
|
|
handle_sites=True,
|
2016-01-26 13:17:34 -05:00
|
|
|
challenge_location="/etc/apache2",
|
2016-01-26 13:39:54 -05:00
|
|
|
MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
|
2016-04-13 19:30:57 -04:00
|
|
|
"certbot_apache", "options-ssl-apache.conf")
|
2015-05-08 17:32:13 -04:00
|
|
|
)
|
2015-12-03 07:14:02 -05:00
|
|
|
CLI_DEFAULTS_CENTOS = dict(
|
|
|
|
|
server_root="/etc/httpd",
|
2015-12-06 15:40:51 -05:00
|
|
|
vhost_root="/etc/httpd/conf.d",
|
2015-12-28 05:56:44 -05:00
|
|
|
vhost_files="*.conf",
|
2015-12-25 03:18:24 -05:00
|
|
|
version_cmd=['apachectl', '-v'],
|
|
|
|
|
define_cmd=['apachectl', '-t', '-D', 'DUMP_RUN_CFG'],
|
2015-12-28 06:47:14 -05:00
|
|
|
restart_cmd=['apachectl', 'graceful'],
|
|
|
|
|
conftest_cmd=['apachectl', 'configtest'],
|
2015-12-03 07:14:02 -05:00
|
|
|
enmod=None,
|
|
|
|
|
dismod=None,
|
|
|
|
|
le_vhost_ext="-le-ssl.conf",
|
2015-12-07 04:07:31 -05:00
|
|
|
handle_mods=False,
|
2015-12-07 05:42:40 -05:00
|
|
|
handle_sites=False,
|
2016-01-26 13:17:34 -05:00
|
|
|
challenge_location="/etc/httpd/conf.d",
|
2016-01-26 13:39:54 -05:00
|
|
|
MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
|
2016-04-13 19:30:57 -04:00
|
|
|
"certbot_apache", "centos-options-ssl-apache.conf")
|
2015-12-03 07:14:02 -05:00
|
|
|
)
|
2015-12-14 02:27:16 -05:00
|
|
|
CLI_DEFAULTS_GENTOO = dict(
|
|
|
|
|
server_root="/etc/apache2",
|
|
|
|
|
vhost_root="/etc/apache2/vhosts.d",
|
2015-12-28 05:56:44 -05:00
|
|
|
vhost_files="*.conf",
|
2015-12-25 03:18:24 -05:00
|
|
|
version_cmd=['/usr/sbin/apache2', '-v'],
|
2016-03-23 12:12:07 -04:00
|
|
|
define_cmd=['apache2ctl', 'virtualhosts'],
|
2015-12-28 06:47:14 -05:00
|
|
|
restart_cmd=['apache2ctl', 'graceful'],
|
|
|
|
|
conftest_cmd=['apache2ctl', 'configtest'],
|
2015-12-14 02:27:16 -05:00
|
|
|
enmod=None,
|
|
|
|
|
dismod=None,
|
|
|
|
|
le_vhost_ext="-le-ssl.conf",
|
|
|
|
|
handle_mods=False,
|
|
|
|
|
handle_sites=False,
|
2016-01-26 13:17:34 -05:00
|
|
|
challenge_location="/etc/apache2/vhosts.d",
|
2016-01-26 13:39:54 -05:00
|
|
|
MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
|
2016-04-13 19:30:57 -04:00
|
|
|
"certbot_apache", "options-ssl-apache.conf")
|
2015-12-14 02:27:16 -05:00
|
|
|
)
|
2016-02-11 17:09:50 -05:00
|
|
|
CLI_DEFAULTS_DARWIN = dict(
|
|
|
|
|
server_root="/etc/apache2",
|
|
|
|
|
vhost_root="/etc/apache2/other",
|
|
|
|
|
vhost_files="*.conf",
|
|
|
|
|
version_cmd=['/usr/sbin/httpd', '-v'],
|
|
|
|
|
define_cmd=['/usr/sbin/httpd', '-t', '-D', 'DUMP_RUN_CFG'],
|
|
|
|
|
restart_cmd=['apachectl', 'graceful'],
|
|
|
|
|
conftest_cmd=['apachectl', 'configtest'],
|
|
|
|
|
enmod=None,
|
|
|
|
|
dismod=None,
|
|
|
|
|
le_vhost_ext="-le-ssl.conf",
|
|
|
|
|
handle_mods=False,
|
|
|
|
|
handle_sites=False,
|
|
|
|
|
challenge_location="/etc/apache2/other",
|
|
|
|
|
MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
|
2016-04-13 19:30:57 -04:00
|
|
|
"certbot_apache", "options-ssl-apache.conf")
|
2016-02-11 17:09:50 -05:00
|
|
|
)
|
2015-12-03 07:14:02 -05:00
|
|
|
CLI_DEFAULTS = {
|
|
|
|
|
"debian": CLI_DEFAULTS_DEBIAN,
|
|
|
|
|
"ubuntu": CLI_DEFAULTS_DEBIAN,
|
2015-12-05 12:10:40 -05:00
|
|
|
"centos": CLI_DEFAULTS_CENTOS,
|
2015-12-07 07:22:56 -05:00
|
|
|
"centos linux": CLI_DEFAULTS_CENTOS,
|
2015-12-10 11:17:12 -05:00
|
|
|
"fedora": CLI_DEFAULTS_CENTOS,
|
2015-12-21 15:52:32 -05:00
|
|
|
"red hat enterprise linux server": CLI_DEFAULTS_CENTOS,
|
2016-02-11 17:09:50 -05:00
|
|
|
"gentoo base system": CLI_DEFAULTS_GENTOO,
|
|
|
|
|
"darwin": CLI_DEFAULTS_DARWIN,
|
2015-12-03 07:14:02 -05:00
|
|
|
}
|
2015-05-08 17:32:13 -04:00
|
|
|
"""CLI defaults."""
|
2015-04-22 04:32:34 -04:00
|
|
|
|
2015-06-01 20:14:10 -04:00
|
|
|
MOD_SSL_CONF_DEST = "options-ssl-apache.conf"
|
|
|
|
|
"""Name of the mod_ssl config file as saved in `IConfig.config_dir`."""
|
2015-04-22 04:32:34 -04:00
|
|
|
|
2015-11-04 15:12:39 -05:00
|
|
|
AUGEAS_LENS_DIR = pkg_resources.resource_filename(
|
2016-04-13 19:30:57 -04:00
|
|
|
"certbot_apache", "augeas_lens")
|
2015-11-04 15:12:39 -05:00
|
|
|
"""Path to the Augeas lens directory"""
|
2015-11-02 19:22:58 -05:00
|
|
|
|
2015-04-22 04:32:34 -04:00
|
|
|
REWRITE_HTTPS_ARGS = [
|
2015-07-21 20:16:46 -04:00
|
|
|
"^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[L,QSA,R=permanent]"]
|
2016-01-14 06:25:15 -05:00
|
|
|
"""Apache version<2.3.9 rewrite rule arguments used for redirections to
|
|
|
|
|
https vhost"""
|
2015-11-06 17:31:30 -05:00
|
|
|
|
2015-12-01 19:05:15 -05:00
|
|
|
REWRITE_HTTPS_ARGS_WITH_END = [
|
2015-12-01 20:37:07 -05:00
|
|
|
"^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[END,QSA,R=permanent]"]
|
2015-12-01 19:16:13 -05:00
|
|
|
"""Apache version >= 2.3.9 rewrite rule arguments used for redirections to
|
2015-12-01 19:05:15 -05:00
|
|
|
https vhost"""
|
2015-11-07 23:37:57 -05:00
|
|
|
|
|
|
|
|
HSTS_ARGS = ["always", "set", "Strict-Transport-Security",
|
2016-01-14 06:25:15 -05:00
|
|
|
"\"max-age=31536000\""]
|
2015-11-06 17:31:30 -05:00
|
|
|
"""Apache header arguments for HSTS"""
|
|
|
|
|
|
2015-11-07 23:37:57 -05:00
|
|
|
UIR_ARGS = ["always", "set", "Content-Security-Policy",
|
2016-01-14 06:25:15 -05:00
|
|
|
"upgrade-insecure-requests"]
|
2015-11-07 23:37:57 -05:00
|
|
|
|
2015-11-08 10:21:36 -05:00
|
|
|
HEADER_ARGS = {"Strict-Transport-Security": HSTS_ARGS,
|
2016-01-14 06:25:15 -05:00
|
|
|
"Upgrade-Insecure-Requests": UIR_ARGS}
|
2015-11-07 23:37:57 -05:00
|
|
|
|
2015-12-07 06:37:58 -05:00
|
|
|
|
2015-12-03 07:14:02 -05:00
|
|
|
def os_constant(key):
|
2015-12-07 05:01:35 -05:00
|
|
|
"""Get a constant value for operating system
|
|
|
|
|
:param key: name of cli constant
|
|
|
|
|
:return: value of constant for active os
|
|
|
|
|
"""
|
2015-12-03 07:14:02 -05:00
|
|
|
os_info = le_util.get_os_info()
|
|
|
|
|
try:
|
|
|
|
|
constants = CLI_DEFAULTS[os_info[0].lower()]
|
|
|
|
|
except KeyError:
|
|
|
|
|
constants = CLI_DEFAULTS["debian"]
|
|
|
|
|
return constants[key]
|