aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Dalton <aaron@daltons.ca>2019-02-17 11:39:16 -0700
committerAaron Dalton <aaron@daltons.ca>2019-02-17 11:39:16 -0700
commitec790a9cd311a2d9e0459bceea027dec24c6f009 (patch)
tree66e5082b6329b5ce738e3b8de29699fa900d5e0c /src
parent3281aced6d0468a00788ff7a8dd3a68da66823c1 (diff)
downloadsvg.js-ec790a9cd311a2d9e0459bceea027dec24c6f009.tar.gz
svg.js-ec790a9cd311a2d9e0459bceea027dec24c6f009.zip
Changed all PolyLine to Polyline, as requested
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions
ine'>automated/noid/master-update-psalm-baseline Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/SetupChecks/DataDirectoryProtected.php
blob: 5afdfaaddd557076e63f73c6fcb1cc99ec9de007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Settings\SetupChecks;

use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
use Psr\Log\LoggerInterface;

/**
 * Checks if the data directory can not be accessed from outside
 */
class DataDirectoryProtected implements ISetupCheck {
	use CheckServerResponseTrait;

	public function __construct(
		protected IL10N $l10n,
		protected IConfig $config,
		protected IURLGenerator $urlGenerator,
		protected IClientService $clientService,
		protected LoggerInterface $logger,
	) {
	}

	public function getCategory(): string {
		return 'network';
	}

	public function getName(): string {
		return $this->l10n->t('Data directory protected');
	}

	public function run(): SetupResult {
		$datadir = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''));

		$dataUrl = $this->urlGenerator->getWebroot() . '/' . $datadir . '/.ocdata';

		$noResponse = true;
		foreach ($this->runHEAD($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.'));
			} else {
				$this->logger->debug('[expected] Could not access data directory from outside.', ['url' => $dataUrl]);
			}
		}

		if ($noResponse) {
			return SetupResult::warning($this->l10n->t('Could not check that the data directory is protected. Please check manually that your server does not allow access to the data directory.') . "\n" . $this->serverConfigHelp());
		}
		return SetupResult::success();
		
	}
}