postinstall: raise a proper error when trying to use e.g. 'admin' as the first username which will conflict with the admins group mail aliases

This commit is contained in:
Alexandre Aubin 2023-02-17 16:37:00 +01:00
parent 58ac633d80
commit 475c93d582

View file

@ -161,7 +161,7 @@ def tools_postinstall(
assert_password_is_compatible,
)
from yunohost.domain import domain_main_domain
from yunohost.user import user_create
from yunohost.user import user_create, ADMIN_ALIASES
import psutil
# Do some checks at first
@ -174,6 +174,9 @@ def tools_postinstall(
raw_msg=True,
)
if username in ADMIN_ALIASES:
raise YunohostValidationError(f"Unfortunately, {username} cannot be used as a username", raw_msg=True)
# Check there's at least 10 GB on the rootfs...
disk_partitions = sorted(
psutil.disk_partitions(all=True), key=lambda k: k.mountpoint