From 6603622a61c1b389cff41d9171f2b963de4cb9c5 Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon@praetorius.me>
Date: Sun, 10 Sep 2017 13:41:59 +0200
Subject: [PATCH] [TASK] Add main admin to system maintainers during first
 install

Resolves: #82439
Related: #82319
Releases: master
Change-Id: Ieabaf1e7a230ce82206ffea30efded9ba821d50f
Reviewed-on: https://review.typo3.org/54099
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Sommer <markus.sommer@typo3.org>
Tested-by: Markus Sommer <markus.sommer@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../install/Classes/Controller/InstallerController.php   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/install/Classes/Controller/InstallerController.php b/typo3/sysext/install/Classes/Controller/InstallerController.php
index c6457c54b2be..bf7e245ca8d5 100644
--- a/typo3/sysext/install/Classes/Controller/InstallerController.php
+++ b/typo3/sysext/install/Classes/Controller/InstallerController.php
@@ -633,6 +633,7 @@ class InstallerController
         $databaseConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('be_users');
         try {
             $databaseConnection->insert('be_users', $adminUserFields);
+            $adminUserUid = (int)$databaseConnection->lastInsertId('be_users');
         } catch (DBALException $exception) {
             $messages[] = new FlashMessage(
                 'The administrator account could not be created. The following error occurred:' . LF
@@ -645,9 +646,11 @@ class InstallerController
                 'status' => $messages,
             ]);
         }
-        // Set password as install tool password
-        $configurationManager->setLocalConfigurationValueByPath('BE/installToolPassword', $this->getHashedPassword($password));
-
+        // Set password as install tool password, add admin user to system maintainers
+        $configurationManager->setLocalConfigurationValuesByPathValuePairs([
+            'BE/installToolPassword' => $this->getHashedPassword($password),
+            'SYS/systemMaintainers' => [$adminUserUid]
+        ]);
         return new JsonResponse([
             'success' => true,
             'status' => $messages,
-- 
GitLab