From 47a5d29043019fac5264a17f0350e53a7638414c Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 22 Sep 2022 10:52:41 +0200 Subject: [PATCH 1/6] Fixed opendkim dsn syntax. fix #2602 --- modoboa_installer/scripts/files/opendkim/opendkim.conf.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modoboa_installer/scripts/files/opendkim/opendkim.conf.tpl b/modoboa_installer/scripts/files/opendkim/opendkim.conf.tpl index c38b94c..4c59370 100644 --- a/modoboa_installer/scripts/files/opendkim/opendkim.conf.tpl +++ b/modoboa_installer/scripts/files/opendkim/opendkim.conf.tpl @@ -18,8 +18,8 @@ UMask 007 #KeyFile /etc/dkimkeys/dkim.key #Selector 2007 -KeyTable dsn:%{db_driver}://%{db_user}:%{db_password}@%{dbhost}:%{dbport}/%{db_name}/table=dkim?keycol=id?datacol=domain_name,selector,private_key_path -SigningTable dsn:%db_driver://%{db_user}:%{db_password}@%{dbhost}:%{dbport}/%{db_name}/table=dkim?keycol=domain_name?datacol=id +KeyTable dsn:%{db_driver}://%{db_user}:%{db_password}@%{dbport}+%{dbhost}/%{db_name}/table=dkim?keycol=id?datacol=domain_name,selector,private_key_path +SigningTable dsn:%db_driver://%{db_user}:%{db_password}@%{dbport}+%{dbhost}/%{db_name}/table=dkim?keycol=domain_name?datacol=id # Commonly-used options; the commented-out versions show the defaults. #Canonicalization simple From 6d7dd9f578fe480547327a820a5854cce0bb0294 Mon Sep 17 00:00:00 2001 From: Spitap Date: Mon, 26 Sep 2022 18:34:47 +0200 Subject: [PATCH 2/6] Add modoboa user to dovecot group upon install --- modoboa_installer/scripts/dovecot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modoboa_installer/scripts/dovecot.py b/modoboa_installer/scripts/dovecot.py index f015a7a..4ef094d 100644 --- a/modoboa_installer/scripts/dovecot.py +++ b/modoboa_installer/scripts/dovecot.py @@ -110,6 +110,11 @@ class Dovecot(base.Installer): self.config.get("dovecot", "mailboxes_owner"), 'dovecot' ) + # Add modoboa to dovecot group for doveadm commands. + system.add_user_to_group( + self.config.get("modoboa", "user"), + 'dovecot' + ) def restart_daemon(self): """Restart daemon process. From 82c4b1033a1ec44d0051abefca570517e107470c Mon Sep 17 00:00:00 2001 From: Spitap Date: Tue, 27 Sep 2022 09:32:55 +0200 Subject: [PATCH 3/6] Better fix --- modoboa_installer/scripts/dovecot.py | 5 ----- .../files/dovecot/conf.d/10-master.conf.tpl | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/modoboa_installer/scripts/dovecot.py b/modoboa_installer/scripts/dovecot.py index 4ef094d..f015a7a 100644 --- a/modoboa_installer/scripts/dovecot.py +++ b/modoboa_installer/scripts/dovecot.py @@ -110,11 +110,6 @@ class Dovecot(base.Installer): self.config.get("dovecot", "mailboxes_owner"), 'dovecot' ) - # Add modoboa to dovecot group for doveadm commands. - system.add_user_to_group( - self.config.get("modoboa", "user"), - 'dovecot' - ) def restart_daemon(self): """Restart daemon process. diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl b/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl index 6c25b8d..eef33a7 100644 --- a/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl +++ b/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl @@ -89,6 +89,21 @@ service postlogin { } } +service stats { + # To allow modoboa to access availible cipher list. + unix_listener stats-reader { + user = vmail + group = vmail + mode = 0660 + } + + unix_listener stats-writer { + user = vmail + group = vmail + mode = 0660 + } +} + service auth { # auth_socket_path points to this userdb socket by default. It's typically # used by dovecot-lda, doveadm, possibly imap process, etc. Users that have From fe6dc8279673bf4410e8415b3d5312a2e06b0682 Mon Sep 17 00:00:00 2001 From: Spitap Date: Mon, 3 Oct 2022 15:13:53 +0200 Subject: [PATCH 4/6] fixed typo --- .../scripts/files/dovecot/conf.d/10-master.conf.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl b/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl index eef33a7..5552396 100644 --- a/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl +++ b/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl @@ -90,7 +90,7 @@ service postlogin { } service stats { - # To allow modoboa to access availible cipher list. + # To allow modoboa to access available cipher list. unix_listener stats-reader { user = vmail group = vmail From dbac16ee1722a67d562b675ad4458f1a9480a876 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 5 Oct 2022 18:08:43 +0200 Subject: [PATCH 5/6] Drop dkim view before upgrade to prevent error. see https://github.com/modoboa/modoboa/issues/2508 --- modoboa_installer/scripts/modoboa.py | 14 ++++++++++++++ modoboa_installer/scripts/opendkim.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modoboa_installer/scripts/modoboa.py b/modoboa_installer/scripts/modoboa.py index ab4becf..ea1320c 100644 --- a/modoboa_installer/scripts/modoboa.py +++ b/modoboa_installer/scripts/modoboa.py @@ -58,6 +58,7 @@ class Modoboa(base.Installer): if not self.config.getboolean("radicale", "enabled"): self.extensions.remove("modoboa-radicale") self.dovecot_enabled = self.config.getboolean("dovecot", "enabled") + self.opendkim_enabled = self.config.getboolean("opendkim", "enabled") def is_extension_ok_for_version(self, extension, version): """Check if extension can be installed with this modo version.""" @@ -163,12 +164,25 @@ class Modoboa(base.Installer): self.config.get("amavis", "dbname") ) ] + if self.upgrade and self.opendkim_enabled and self.dbengine == "postgres": + # Drop dkim view to prevent an error during migration (2.0) + self.backend._exec_query("DROP VIEW IF EXISTS dkim") code, output = utils.exec_cmd( "bash -c '{} modoboa-admin.py deploy instance {}'".format( prefix, " ".join(args)), sudo_user=self.user, cwd=self.home_dir) if code: raise utils.FatalError(output) + if self.upgrade and self.opendkim_enabled and self.dbengine == "postgres": + # Restore view previously deleted + self.backend.load_sql_file( + self.dbname, self.dbuser, self.dbpassword, + self.get_file_path("dkim_view_{}.sql".format(self.dbengine)) + ) + self.backend.grant_right_on_table( + self.dbname, "dkim", self.config.get("opendkim", "dbuser"), + "SELECT" + ) def setup_database(self): """Additional config.""" diff --git a/modoboa_installer/scripts/opendkim.py b/modoboa_installer/scripts/opendkim.py index 62c39fa..9875a93 100644 --- a/modoboa_installer/scripts/opendkim.py +++ b/modoboa_installer/scripts/opendkim.py @@ -97,7 +97,8 @@ class Opendkim(base.Installer): 'SOCKET="inet:12345@localhost"', ])) - """ Make sure opendkim is started after postgresql and mysql, respectively. """ + # Make sure opendkim is started after postgresql and mysql, + # respectively. if (self.dbengine != "postgres" and package.backend.FORMAT == "deb"): dbservice = "mysql.service" elif (self.dbengine != "postgres" and package.backend.FORMAT != "deb"): From b84abbbacc1e1434044dc0590d316aed948b147d Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 5 Oct 2022 18:17:54 +0200 Subject: [PATCH 6/6] python3-certbot-nginx is only available on Debian based systems. see #437 --- modoboa_installer/ssl.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modoboa_installer/ssl.py b/modoboa_installer/ssl.py index a0cd4d0..bd2ef52 100644 --- a/modoboa_installer/ssl.py +++ b/modoboa_installer/ssl.py @@ -92,12 +92,13 @@ class LetsEncryptCertificate(CertificateBackend): else: utils.printcolor("Failed to install certbot, aborting.", utils.RED) sys.exit(1) - #Nginx plugin certbot - if (self.config.has_option("nginx", "enabled") and - self.config.getboolean("nginx", "enabled")): - package.backend.update() - package.backend.install("python3-certbot-nginx") - + # Nginx plugin certbot + if ( + self.config.has_option("nginx", "enabled") and + self.config.getboolean("nginx", "enabled") + ): + if name == "ubuntu" or name.startswith("debian"): + package.backend.install("python3-certbot-nginx") def generate_cert(self): """Create a certificate."""