Skip to content

Commit 67a8c6b

Browse files
feat: add tag to indicate or detect datadirectory .htaccess
Versus the installroot/webroot .htaccess Signed-off-by: Josh <[email protected]>
1 parent 7473f2c commit 67a8c6b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/private/Setup.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public static function updateHtaccess(): bool {
579579
return false;
580580
}
581581

582-
// We're a static method; cannot use DI $this->config
582+
// We're a static method; cannot use $this->config
583583
$config = Server::get(SystemConfig::class);
584584

585585
try {
@@ -588,6 +588,10 @@ public static function updateHtaccess(): bool {
588588
return false;
589589
}
590590

591+
// TODO: Add a check to detect when the .htaccess file isn't the expected one
592+
// (e.g. when it's the datadirectory one due to a misconfiguration) so that we
593+
// don't append to the wrong file (and enable a very problematic configuration).
594+
591595
// Read original content
592596
$original = @file_get_contents($htaccessPath);
593597
// extra check for good measure
@@ -698,6 +702,8 @@ public static function protectDataDirectory(): void {
698702
// Content for the .htaccess file that locks down (most) Apache environments
699703
$now = date('Y-m-d H:i:s');
700704
$content = "# Generated by Nextcloud on $now\n";
705+
$content .= "# Deployed in Nextcloud data directory\n";
706+
$content .= "# Do not change this file\n\n";
701707
$content .= "# Section for Apache 2.4 to 2.6\n";
702708
$content .= "<IfModule mod_authz_core.c>\n";
703709
$content .= " Require all denied\n";

0 commit comments

Comments
 (0)