From 475c93d582c3e17cdf4afd8cb3619f8d9f0f2ecf Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 17 Feb 2023 16:37:00 +0100 Subject: [PATCH] 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 --- src/tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tools.py b/src/tools.py index f5a89a22a..0ff6842ea 100644 --- a/src/tools.py +++ b/src/tools.py @@ -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