From 48e488f89ec39fa7df46d3c22c410890c3676b20 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 8 Feb 2023 22:46:03 +0100 Subject: [PATCH] backup: fix full backup restore postinstall calls that now need first username+fullname+password --- src/backup.py | 6 +++++- src/tools.py | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backup.py b/src/backup.py index a3a24aa52..ee961a7bf 100644 --- a/src/backup.py +++ b/src/backup.py @@ -32,6 +32,7 @@ from functools import reduce from packaging import version from moulinette import Moulinette, m18n +from moulinette.utils.text import random_ascii from moulinette.utils.log import getActionLogger from moulinette.utils.filesystem import ( read_file, @@ -936,7 +937,10 @@ class RestoreManager: ) logger.debug("executing the post-install...") - tools_postinstall(domain, "Yunohost", True) + + # Use a dummy password which is not gonna be saved anywhere + # because the next thing to happen should be that a full restore of the LDAP db will happen + tools_postinstall(domain, "admin", "Admin", password=random_ascii(70), ignore_dyndns=True, overwrite_root_password=False) def clean(self): """ diff --git a/src/tools.py b/src/tools.py index dee4c8486..f5a89a22a 100644 --- a/src/tools.py +++ b/src/tools.py @@ -152,6 +152,7 @@ def tools_postinstall( password, ignore_dyndns=False, force_diskspace=False, + overwrite_root_password=True, ): from yunohost.dyndns import _dyndns_available from yunohost.utils.dns import is_yunohost_dyndns_domain @@ -225,10 +226,11 @@ def tools_postinstall( domain_add(domain, dyndns) domain_main_domain(domain) + # First user user_create(username, domain, password, admin=True, fullname=fullname) - # Update LDAP admin and create home dir - tools_rootpw(password) + if overwrite_root_password: + tools_rootpw(password) # Enable UPnP silently and reload firewall firewall_upnp("enable", no_refresh=True)