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 <coding@schilljs.com>2022-08-12 11:03:19 +0300
committerJoas Schilling <coding@schilljs.com>2022-08-12 11:03:19 +0300
commit33d7a9624cd0c0760f5980f605d6d34cee6218f5 (patch)
treeb4a0c5d0ad4b310e5fc146381f59a02801f52c7b
parentd275c930356fd4203c0cf9e2850c8e92f3d0c2b9 (diff)
Create more secure passwords by default
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/Setup/MySQL.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index 7788e3e006c..e3004c269bc 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -141,6 +141,16 @@ class MySQL extends AbstractDatabase {
$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);
@@ -163,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;