aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/SetupChecks/DataDirectoryProtected.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/settings/lib/SetupChecks/DataDirectoryProtected.php b/apps/settings/lib/SetupChecks/DataDirectoryProtected.php
index 5afdfaaddd5..447c66d5c5d 100644
--- a/apps/settings/lib/SetupChecks/DataDirectoryProtected.php
+++ b/apps/settings/lib/SetupChecks/DataDirectoryProtected.php
@@ -42,13 +42,21 @@ class DataDirectoryProtected implements ISetupCheck {
public function run(): SetupResult {
$datadir = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''));
- $dataUrl = $this->urlGenerator->getWebroot() . '/' . $datadir . '/.ocdata';
+ $dataUrl = $this->urlGenerator->getWebroot() . '/' . $datadir . '/.ncdata';
$noResponse = true;
- foreach ($this->runHEAD($dataUrl, httpErrors:false) as $response) {
+ foreach ($this->runRequest('GET', $dataUrl, [ 'httpErrors' => false ]) as $response) {
$noResponse = false;
- if ($response->getStatusCode() === 200) {
- return SetupResult::error($this->l10n->t('Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.'));
+ if ($response->getStatusCode() < 400) {
+ // Read the response body
+ $body = $response->getBody();
+ if (is_resource($body)) {
+ $body = stream_get_contents($body, 64);
+ }
+
+ if (str_contains($body, '# Nextcloud data directory')) {
+ return SetupResult::error($this->l10n->t('Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.'));
+ }
} else {
$this->logger->debug('[expected] Could not access data directory from outside.', ['url' => $dataUrl]);
}