Skip to content

Commit 08fc972

Browse files
refactor(setup): Use shared generateDbPassword() in MySQL setup
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent bf2706a commit 08fc972

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

lib/private/Setup/MySQL.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use OC\DB\ConnectionAdapter;
1414
use OC\DB\MySqlTools;
1515
use OCP\IDBConnection;
16-
use OCP\Security\ISecureRandom;
1716

1817
class MySQL extends AbstractDatabase {
1918
public string $dbprettyname = 'MySQL/MariaDB';
@@ -127,14 +126,8 @@ private function createSpecificUser(string $username, IDBConnection $connection)
127126
$rootUser = $this->dbUser;
128127
$rootPassword = $this->dbPassword;
129128

130-
//create a random password so we don't need to store the admin password in the config file
131-
$saveSymbols = str_replace(['\"', '\\', '\'', '`'], '', ISecureRandom::CHAR_SYMBOLS);
132-
$password = $this->random->generate(22, ISecureRandom::CHAR_ALPHANUMERIC . $saveSymbols)
133-
. $this->random->generate(2, ISecureRandom::CHAR_UPPER)
134-
. $this->random->generate(2, ISecureRandom::CHAR_LOWER)
135-
. $this->random->generate(2, ISecureRandom::CHAR_DIGITS)
136-
. $this->random->generate(2, $saveSymbols);
137-
$this->dbPassword = str_shuffle($password);
129+
// Create a random password so we don't need to store the admin password in the config file
130+
$this->dbPassword = $this->generateDbPassword();
138131

139132
try {
140133
//user already specified in config

0 commit comments

Comments
 (0)