diff options
author | Timo Förster <tfoerster@webfoersterei.de> | 2018-07-27 11:20:47 +0200 |
---|---|---|
committer | Timo Förster <tfoerster@webfoersterei.de> | 2018-08-24 23:12:02 +0200 |
commit | 006e150c879312264db10009792c7035be9562dc (patch) | |
tree | 87d2123babd84d3a109d041671c031bdbcda5ce7 /settings | |
parent | 9823c7197150e4134490c043c2e2e53733eae783 (diff) | |
download | nextcloud-server-006e150c879312264db10009792c7035be9562dc.tar.gz nextcloud-server-006e150c879312264db10009792c7035be9562dc.zip |
Change check if secure randomness is possible.
Signed-off-by: Timo Förster <tfoerster@webfoersterei.de>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/Controller/CheckSetupController.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index 747e60c7cb2..9219ca1350c 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -42,6 +42,7 @@ use OC\DB\MissingIndexInformation; use OC\IntegrityCheck\Checker; use OC\Lock\NoopLockingProvider; use OC\MemoryInfo; +use OC\Security\SecureRandom; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataDisplayResponse; use OCP\AppFramework\Http\DataResponse; @@ -86,6 +87,8 @@ class CheckSetupController extends Controller { private $dateTimeFormatter; /** @var MemoryInfo */ private $memoryInfo; + /** @var SecureRandom */ + private $secureRandom; public function __construct($AppName, IRequest $request, @@ -100,7 +103,8 @@ class CheckSetupController extends Controller { IDBConnection $db, ILockingProvider $lockingProvider, IDateTimeFormatter $dateTimeFormatter, - MemoryInfo $memoryInfo) { + MemoryInfo $memoryInfo, + SecureRandom $secureRandom) { parent::__construct($AppName, $request); $this->config = $config; $this->clientService = $clientService; @@ -114,6 +118,7 @@ class CheckSetupController extends Controller { $this->lockingProvider = $lockingProvider; $this->dateTimeFormatter = $dateTimeFormatter; $this->memoryInfo = $memoryInfo; + $this->secureRandom = $secureRandom; } /** @@ -167,20 +172,17 @@ class CheckSetupController extends Controller { } /** - * Whether /dev/urandom is available to the PHP controller + * Whether PHP can generate "secure" pseudorandom integers * * @return bool */ - private function isUrandomAvailable() { - if(@file_exists('/dev/urandom')) { - $file = fopen('/dev/urandom', 'rb'); - if($file) { - fclose($file); - return true; - } + private function isRandomnessSecure() { + try { + $this->secureRandom->generate(1); + } catch (\Exception $ex) { + return false; } - - return false; + return true; } /** @@ -602,7 +604,7 @@ Raw output 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), 'isMemcacheConfigured' => $this->isMemcacheConfigured(), 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), - 'isUrandomAvailable' => $this->isUrandomAvailable(), + 'isRandomnessSecure' => $this->isRandomnessSecure(), 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), 'phpSupported' => $this->isPhpSupported(), |