From fd046edefd8508d27e96ef1267a41890de82b1c3 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Wed, 8 Apr 2026 21:12:11 +0200 Subject: [PATCH] fix(core): remove duplicate MySQL user prefix PR #53212 implemented a hardcoded database username, instead of deriving it from the Nextcloud admin username, to be able to setup Nextcloud without admin user. This has the additional benefit that knowing one of them does not allow to derive the other. However, it used `oc_admin`, while the MySQL database setup adds `oc_` again in the dedicated `createSpecificUser()` function, resulting in `oc_oc_admin`. In case of PostgreSQL, this was done in `setupDatabase()`, replaced with the hardcoded username. Signed-off-by: MichaIng --- lib/private/Setup/MySQL.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index 24093ae97a40c..1396c280e1736 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -142,8 +142,8 @@ private function createSpecificUser(string $username, IDBConnection $connection) //we don't have a dbuser specified in config if ($this->dbUser !== $oldUser) { - //add prefix to the admin username to prevent collisions - $adminUser = substr('oc_' . $username, 0, 16); + //cap to 16 characters + $adminUser = substr($username, 0, 16); $i = 1; while (true) { @@ -169,7 +169,7 @@ private function createSpecificUser(string $username, IDBConnection $connection) } else { //repeat with different username $length = strlen((string)$i); - $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i; + $adminUser = substr($username, 0, 16 - $length) . $i; $i++; } }