Skip to content

Commit fd046ed

Browse files
committed
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 <micha@dietpi.com>
1 parent e761005 commit fd046ed

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/private/Setup/MySQL.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ private function createSpecificUser(string $username, IDBConnection $connection)
142142

143143
//we don't have a dbuser specified in config
144144
if ($this->dbUser !== $oldUser) {
145-
//add prefix to the admin username to prevent collisions
146-
$adminUser = substr('oc_' . $username, 0, 16);
145+
//cap to 16 characters
146+
$adminUser = substr($username, 0, 16);
147147

148148
$i = 1;
149149
while (true) {
@@ -169,7 +169,7 @@ private function createSpecificUser(string $username, IDBConnection $connection)
169169
} else {
170170
//repeat with different username
171171
$length = strlen((string)$i);
172-
$adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
172+
$adminUser = substr($username, 0, 16 - $length) . $i;
173173
$i++;
174174
}
175175
}

0 commit comments

Comments
 (0)