Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-08-12 12:02:34 +0300
committerGitHub <noreply@github.com>2022-08-12 12:02:34 +0300
commit478690b58fa8bfb491f1f7e304f231cbe6defa1b (patch)
treeb4a0c5d0ad4b310e5fc146381f59a02801f52c7b
parent7391c8149540d16fb9ecc12568e7b8ebfcdec35c (diff)
parent33d7a9624cd0c0760f5980f605d6d34cee6218f5 (diff)
Merge pull request #33513 from nextcloud/bugfix/noid/recover-installation-when-creating-the-user-failed
Recover installation when creating the database user fails and improve password strength
-rw-r--r--lib/private/Setup/MySQL.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index e878ed4d9aa..e3004c269bc 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -129,6 +129,7 @@ class MySQL extends AbstractDatabase {
'exception' => $ex,
'app' => 'mysql.setup',
]);
+ throw $ex;
}
}
@@ -137,6 +138,19 @@ class MySQL extends AbstractDatabase {
* @param IDBConnection $connection
*/
private function createSpecificUser($username, $connection): void {
+ $rootUser = $this->dbUser;
+ $rootPassword = $this->dbPassword;
+
+ //create a random password so we don't need to store the admin password in the config file
+ $saveSymbols = str_replace(['\"', '\\', '\'', '`'], '', ISecureRandom::CHAR_SYMBOLS);
+ $password = $this->random->generate(22, ISecureRandom::CHAR_ALPHANUMERIC . $saveSymbols)
+ . $this->random->generate(2, ISecureRandom::CHAR_UPPER)
+ . $this->random->generate(2, ISecureRandom::CHAR_LOWER)
+ . $this->random->generate(2, ISecureRandom::CHAR_DIGITS)
+ . $this->random->generate(2, $saveSymbols)
+ ;
+ $this->dbPassword = str_shuffle($password);
+
try {
//user already specified in config
$oldUser = $this->config->getValue('dbuser', false);
@@ -159,10 +173,6 @@ class MySQL extends AbstractDatabase {
if (count($data) === 0) {
//use the admin login data for the new database user
$this->dbUser = $adminUser;
-
- //create a random password so we don't need to store the admin password in the config file
- $this->dbPassword = $this->random->generate(30, ISecureRandom::CHAR_ALPHANUMERIC);
-
$this->createDBUser($connection);
break;
@@ -179,6 +189,9 @@ class MySQL extends AbstractDatabase {
'exception' => $ex,
'app' => 'mysql.setup',
]);
+ // Restore the original credentials
+ $this->dbUser = $rootUser;
+ $this->dbPassword = $rootPassword;
}
$this->config->setValues([