Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent installation of incompatible extensions #533

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ An installer which deploy a complete mail server based on Modoboa.

This tool is still in beta stage, it has been tested on:

* Debian Buster (10) / Bullseye (11)
* Debian 10 and upper
* Ubuntu Bionic Beaver (18.04) and upper
* CentOS 7

.. warning::

``/tmp`` partition must be mounted without the ``noexec`` option.

.. note::
Expand Down Expand Up @@ -92,8 +91,8 @@ You can activate it as follows::

It will automatically install latest versions of modoboa and its plugins.

Backup mode
------------
Backup mode
-----------

An experimental backup mode is available.

Expand Down
11 changes: 6 additions & 5 deletions modoboa_installer/compatibility_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"modoboa-sievefilters": ">=1.1.1",
"modoboa-webmail": ">=1.2.0",
},
"2.1.0": {
"modoboa-pdfcredentials": None,
"modoboa-dmarc": None,
"modoboa-imap-migration": None,
},
}

EXTENSIONS_AVAILABILITY = {
"modoboa-contacts": "1.7.4",
}

REMOVED_EXTENSIONS = {
"modoboa-pdfcredentials": "2.1.0",
"modoboa-dmarc": "2.1.0",
"modoboa-imap-migration": "2.1.0"
}
21 changes: 16 additions & 5 deletions modoboa_installer/scripts/modoboa.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ def __init__(self, *args, **kwargs):

def is_extension_ok_for_version(self, extension, version):
"""Check if extension can be installed with this modo version."""
if extension not in compatibility_matrix.EXTENSIONS_AVAILABILITY:
return True
version = utils.convert_version_to_int(version)
min_version = compatibility_matrix.EXTENSIONS_AVAILABILITY[extension]
min_version = utils.convert_version_to_int(min_version)
return version >= min_version
if extension in compatibility_matrix.EXTENSIONS_AVAILABILITY:
min_version = compatibility_matrix.EXTENSIONS_AVAILABILITY[extension]
min_version = utils.convert_version_to_int(min_version)
return version >= min_version
if extension in compatibility_matrix.REMOVED_EXTENSIONS:
max_version = compatibility_matrix.REMOVED_EXTENSIONS[extension]
max_version = utils.convert_version_to_int(max_version)
return version < max_version
return True

def _setup_venv(self):
"""Prepare a dedicated virtualenv."""
Expand All @@ -80,6 +84,13 @@ def _setup_venv(self):
version = self.config.get("modoboa", "version")
if version == "latest":
packages += ["modoboa"] + self.extensions
for extension in list(self.extensions):
if extension in compatibility_matrix.REMOVED_EXTENSIONS.keys():
self.extensions.remove(extension)
self.extensions = [
extension for extension in self.extensions
if extension not in compatibility_matrix.REMOVED_EXTENSIONS
]
else:
matrix = compatibility_matrix.COMPATIBILITY_MATRIX[version]
packages.append("modoboa=={}".format(version))
Expand Down
8 changes: 7 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
def installation_disclaimer(args, config):
"""Display installation disclaimer."""
hostname = config.get("general", "hostname")
utils.printcolor(
"Notice:\n"
"It is recommanded to run this installer on a FRESHLY installed server.\n"
"(ie. with nothing special already installed on it)\n",
utils.CYAN
)
utils.printcolor(
"Warning:\n"
"Before you start the installation, please make sure the following "
Expand All @@ -47,7 +53,7 @@ def installation_disclaimer(args, config):
hostname.replace(".{}".format(args.domain), ""),
hostname
),
utils.CYAN
utils.YELLOW
)
utils.printcolor(
"Your mail server will be installed with the following components:",
Expand Down