diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3652815..efd2cef5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v0.7.17 (Derelict Dermodactylus) +### Fixed +* Limited accounts to 5 API keys at a time. +* Fixes database passwords not being generated with the proper requirements for some MySQL setups. +* Hostnames that are not FQDNs/IP addresses can now be used for connecting to a MySQL host. + ## v0.7.16 (Derelict Dermodactylus) ### Fixed * Fixed the /api/application/servers endpoint erroring when including subusers or egg diff --git a/LICENSE.md b/LICENSE.md index 929536020..11eabac9f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ # The MIT License (MIT) ``` -Copyright (c) 2015 - 2017 Dane Everitt +Copyright (c) 2015 - 2020 Dane Everitt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php new file mode 100644 index 000000000..5de685fe9 --- /dev/null +++ b/app/Helpers/Utilities.php @@ -0,0 +1,35 @@ + 'required|string|max:255', - 'host' => 'required|ip|unique:database_hosts,host', + 'host' => 'required|unique:database_hosts,host', 'port' => 'required|numeric|between:1,65535', 'username' => 'required|string|max:32', 'password' => 'nullable|string', diff --git a/app/Services/Databases/DatabaseManagementService.php b/app/Services/Databases/DatabaseManagementService.php index 456985292..0f07ad704 100644 --- a/app/Services/Databases/DatabaseManagementService.php +++ b/app/Services/Databases/DatabaseManagementService.php @@ -4,6 +4,7 @@ namespace Pterodactyl\Services\Databases; use Exception; use Pterodactyl\Models\Database; +use Pterodactyl\Helpers\Utilities; use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; @@ -70,7 +71,9 @@ class DatabaseManagementService $data['server_id'] = $server; $data['database'] = sprintf('s%d_%s', $server, $data['database']); $data['username'] = sprintf('u%d_%s', $server, str_random(10)); - $data['password'] = $this->encrypter->encrypt(str_random(24)); + $data['password'] = $this->encrypter->encrypt( + Utilities::randomStringWithSpecialCharacters(24) + ); $this->database->beginTransaction(); try { diff --git a/app/Services/Databases/DatabasePasswordService.php b/app/Services/Databases/DatabasePasswordService.php index 71aaf14f2..6abb0a499 100644 --- a/app/Services/Databases/DatabasePasswordService.php +++ b/app/Services/Databases/DatabasePasswordService.php @@ -2,9 +2,8 @@ namespace Pterodactyl\Services\Databases; -use Exception; use Pterodactyl\Models\Database; -use Illuminate\Support\Facades\Log; +use Pterodactyl\Helpers\Utilities; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; @@ -62,19 +61,7 @@ class DatabasePasswordService */ public function handle(Database $database): string { - $password = str_random(24); - // Given a random string of characters, randomly loop through the characters and replace some - // with special characters to avoid issues with MySQL password requirements on some servers. - try { - for ($i = 0; $i < random_int(2, 6); $i++) { - $character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)]; - - $password = substr_replace($password, $character, random_int(0, 23), 1); - } - } catch (Exception $exception) { - // Just log the error and hope for the best at this point. - Log::error($exception); - } + $password = Utilities::randomStringWithSpecialCharacters(24); $this->connection->transaction(function () use ($database, $password) { $this->dynamic->set('dynamic', $database->database_host_id);