From 6f973a2e4be79c5f3e6aefd2251af6dfbce52bae Mon Sep 17 00:00:00 2001 From: Igor Rzegocki Date: Tue, 7 May 2019 11:42:08 +0200 Subject: [PATCH 1/3] Fixed hardcoded antispam and antivirus host addresses Fixes #978 --- CHANGELOG.md | 1 + core/dovecot/conf/bin/ham | 4 ++-- core/dovecot/conf/bin/spam | 4 ++-- docs/configuration.rst | 1 + docs/kubernetes/mailu/configmap.yaml | 1 + services/rspamd/conf/antivirus.conf | 2 +- services/rspamd/start.py | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96426b67..35e597e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ v1.6.1 - unreleased - Enhancement: Create an Authentication Token with IPv6 address restriction ([#829](https://github.com/Mailu/Mailu/issues/829)) - Enhancement: Automatically create admin user on container startup if given appropriate environment variables - Enhancement: Missing wildcard option in alias flask command ([#869](https://github.com/Mailu/Mailu/issues/869)) +- Enhancement: Fixed hardcoded antispam and antivirus host addresses ([#978](https://github.com/Mailu/Mailu/issues/978)) - Bug: Fix creating new fetched accounts - Bug: Fix poor performance if ANTIVIRUS is configured to none. - Bug: Implement mailustart to resolve webmail in admin ([#716](https://github.com/Mailu/Mailu/issues/716)) diff --git a/core/dovecot/conf/bin/ham b/core/dovecot/conf/bin/ham index c74a97bd..0d56bf0f 100755 --- a/core/dovecot/conf/bin/ham +++ b/core/dovecot/conf/bin/ham @@ -1,4 +1,4 @@ #!/bin/bash -tee >(rspamc -h antispam:11334 -P mailu learn_ham /dev/stdin) \ - | rspamc -h antispam:11334 -P mailu -f 13 fuzzy_add /dev/stdin \ No newline at end of file +tee >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu learn_ham /dev/stdin) \ + | rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu -f 13 fuzzy_add /dev/stdin diff --git a/core/dovecot/conf/bin/spam b/core/dovecot/conf/bin/spam index e6a66f89..78ede011 100755 --- a/core/dovecot/conf/bin/spam +++ b/core/dovecot/conf/bin/spam @@ -1,4 +1,4 @@ #!/bin/bash -tee >(rspamc -h antispam:11334 -P mailu learn_spam /dev/stdin) \ - >(rspamc -h antispam:11334 -P mailu -f 11 fuzzy_add /dev/stdin) \ No newline at end of file +tee >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu learn_spam /dev/stdin) \ + >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu -f 11 fuzzy_add /dev/stdin) diff --git a/docs/configuration.rst b/docs/configuration.rst index 2116888b..18e8b75b 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -147,6 +147,7 @@ optional port number. Those variables are: - ``HOST_AUTHSMTP``: the container that is running the authenticated SMTP server for the webnmail (default: ``smtp``, port 10025) - ``HOST_ADMIN``: the container that is running the admin interface (default: ``admin``) - ``HOST_ANTISPAM``: the container that is running the antispam service (default: ``antispam:11334``) +- ``HOST_ANTIVIRUS``: the container that is running the antivirus service (default: ``antivirus:3310``) - ``HOST_WEBMAIL``: the container that is running the webmail (default: ``webmail``) - ``HOST_WEBDAV``: the container that is running the webdav server (default: ``webdav:5232``) - ``HOST_REDIS``: the container that is running the redis daemon (default: ``redis``) diff --git a/docs/kubernetes/mailu/configmap.yaml b/docs/kubernetes/mailu/configmap.yaml index 8a24ee5d..a950c732 100644 --- a/docs/kubernetes/mailu/configmap.yaml +++ b/docs/kubernetes/mailu/configmap.yaml @@ -165,4 +165,5 @@ HOST_ADMIN: "admin.mailu-mailserver.svc.cluster.local" HOST_WEBDAV: "webdav.mailu-mailserver.svc.cluster.local:5232" HOST_ANTISPAM: "antispam.mailu-mailserver.svc.cluster.local:11332" + HOST_ANTIVIRUS: "antivirus.mailu-mailserver.svc.cluster.local:3310" HOST_REDIS: "redis.mailu-mailserver.svc.cluster.local" diff --git a/services/rspamd/conf/antivirus.conf b/services/rspamd/conf/antivirus.conf index 7bf646b8..a39d7228 100644 --- a/services/rspamd/conf/antivirus.conf +++ b/services/rspamd/conf/antivirus.conf @@ -3,6 +3,6 @@ clamav { attachments_only = true; symbol = "CLAM_VIRUS"; type = "clamav"; - servers = "antivirus:3310"; + servers = "{{ HOST_ANTIVIRUS }}"; } {% endif %} diff --git a/services/rspamd/start.py b/services/rspamd/start.py index f62dc651..592eb609 100755 --- a/services/rspamd/start.py +++ b/services/rspamd/start.py @@ -9,11 +9,12 @@ from socrate import system, conf log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) # Actual startup script + os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front")) if "HOST_REDIS" not in os.environ: os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_REDIS", "redis")) - +os.environ["HOST_ANTIVIRUS"] = system.resolve_address(os.environ.get("HOST_ANTIVIRUS", "antivirus:3310")) for rspamd_file in glob.glob("/conf/*"): conf.jinja(rspamd_file, os.environ, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file))) From 5b07da7f7c0412d82bc419079e71ea9fcc4cf4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Thu, 22 Aug 2019 11:46:06 +0300 Subject: [PATCH 2/3] Changelog to towncrier --- CHANGELOG.md | 1 - towncrier/newsfragments/979.feature | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 towncrier/newsfragments/979.feature diff --git a/CHANGELOG.md b/CHANGELOG.md index 35e597e1..96426b67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,6 @@ v1.6.1 - unreleased - Enhancement: Create an Authentication Token with IPv6 address restriction ([#829](https://github.com/Mailu/Mailu/issues/829)) - Enhancement: Automatically create admin user on container startup if given appropriate environment variables - Enhancement: Missing wildcard option in alias flask command ([#869](https://github.com/Mailu/Mailu/issues/869)) -- Enhancement: Fixed hardcoded antispam and antivirus host addresses ([#978](https://github.com/Mailu/Mailu/issues/978)) - Bug: Fix creating new fetched accounts - Bug: Fix poor performance if ANTIVIRUS is configured to none. - Bug: Implement mailustart to resolve webmail in admin ([#716](https://github.com/Mailu/Mailu/issues/716)) diff --git a/towncrier/newsfragments/979.feature b/towncrier/newsfragments/979.feature new file mode 100644 index 00000000..b547ee3e --- /dev/null +++ b/towncrier/newsfragments/979.feature @@ -0,0 +1 @@ +Fixed hardcoded antispam and antivirus host addresses \ No newline at end of file From 05ea4474e7cd245af9e8c431e061ab7eb58b5d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Thu, 22 Aug 2019 13:08:43 +0300 Subject: [PATCH 3/3] make `ANTIVIRUS_ADDRESS` consistent with #940 --- core/dovecot/conf/bin/ham | 4 ++-- core/dovecot/conf/bin/spam | 4 ++-- core/dovecot/start.py | 1 + services/rspamd/conf/antivirus.conf | 2 +- services/rspamd/start.py | 4 +++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/dovecot/conf/bin/ham b/core/dovecot/conf/bin/ham index 0d56bf0f..becc304d 100755 --- a/core/dovecot/conf/bin/ham +++ b/core/dovecot/conf/bin/ham @@ -1,4 +1,4 @@ #!/bin/bash -tee >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu learn_ham /dev/stdin) \ - | rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu -f 13 fuzzy_add /dev/stdin +tee >(rspamc -h ${ANTISPAM_ADDRESS} -P mailu learn_ham /dev/stdin) \ + | rspamc -h ${ANTISPAM_ADDRESS} -P mailu -f 13 fuzzy_add /dev/stdin diff --git a/core/dovecot/conf/bin/spam b/core/dovecot/conf/bin/spam index 78ede011..035706b6 100755 --- a/core/dovecot/conf/bin/spam +++ b/core/dovecot/conf/bin/spam @@ -1,4 +1,4 @@ #!/bin/bash -tee >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu learn_spam /dev/stdin) \ - >(rspamc -h ${HOST_ANTISPAM:-antispam:11334} -P mailu -f 11 fuzzy_add /dev/stdin) +tee >(rspamc -h ${ANTISPAM_ADDRESS} -P mailu learn_spam /dev/stdin) \ + >(rspamc -h ${ANTISPAM_ADDRESS} -P mailu -f 11 fuzzy_add /dev/stdin) diff --git a/core/dovecot/start.py b/core/dovecot/start.py index 6f011c74..ae429748 100755 --- a/core/dovecot/start.py +++ b/core/dovecot/start.py @@ -24,6 +24,7 @@ def start_podop(): os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front")) os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_REDIS", "redis")) os.environ["ADMIN_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ADMIN", "admin")) +os.environ["ANTISPAM_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ANTISPAM", "antispam:11334")) if os.environ["WEBMAIL"] != "none": os.environ["WEBMAIL_ADDRESS"] = system.resolve_address(os.environ.get("HOST_WEBMAIL", "webmail")) diff --git a/services/rspamd/conf/antivirus.conf b/services/rspamd/conf/antivirus.conf index a39d7228..a0582a0d 100644 --- a/services/rspamd/conf/antivirus.conf +++ b/services/rspamd/conf/antivirus.conf @@ -3,6 +3,6 @@ clamav { attachments_only = true; symbol = "CLAM_VIRUS"; type = "clamav"; - servers = "{{ HOST_ANTIVIRUS }}"; + servers = "{{ ANTIVIRUS_ADDRESS }}"; } {% endif %} diff --git a/services/rspamd/start.py b/services/rspamd/start.py index 592eb609..354b14b7 100755 --- a/services/rspamd/start.py +++ b/services/rspamd/start.py @@ -14,7 +14,9 @@ os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT" if "HOST_REDIS" not in os.environ: os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_REDIS", "redis")) -os.environ["HOST_ANTIVIRUS"] = system.resolve_address(os.environ.get("HOST_ANTIVIRUS", "antivirus:3310")) + +if os.environ.get("ANTIVIRUS") == 'clamav': + os.environ["ANTIVIRUS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ANTIVIRUS", "antivirus:3310")) for rspamd_file in glob.glob("/conf/*"): conf.jinja(rspamd_file, os.environ, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file)))