Skip to content

Commit 5d9fd7b

Browse files
authored
Merge pull request #16792 from MichaIng/patch-1
Harden data and config protection .htaccess
2 parents 79b9be7 + 4384806 commit 5d9fd7b

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

config/.htaccess

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
# line below if for Apache 2.4
2-
<ifModule mod_authz_core.c>
3-
Require all denied
4-
</ifModule>
1+
# Section for Apache 2.4 to 2.6
2+
<IfModule mod_authz_core.c>
3+
Require all denied
4+
</IfModule>
5+
<IfModule mod_access_compat.c>
6+
Order Allow,Deny
7+
Deny from all
8+
Satisfy All
9+
</IfModule>
510

6-
# line below if for Apache 2.2
7-
<ifModule !mod_authz_core.c>
8-
deny from all
9-
</ifModule>
11+
# Section for Apache 2.2
12+
<IfModule !mod_authz_core.c>
13+
<IfModule !mod_access_compat.c>
14+
<IfModule mod_authz_host.c>
15+
Order Allow,Deny
16+
Deny from all
17+
</IfModule>
18+
Satisfy All
19+
</IfModule>
20+
</IfModule>
1021

11-
# section for Apache 2.2 and 2.4
12-
<ifModule mod_autoindex.c>
13-
IndexIgnore *
14-
</ifModule>
22+
# Section for Apache 2.2 to 2.6
23+
<IfModule mod_autoindex.c>
24+
IndexIgnore *
25+
</IfModule>

lib/private/Setup.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -556,19 +556,29 @@ public static function protectDataDirectory() {
556556
//Require all denied
557557
$now = date('Y-m-d H:i:s');
558558
$content = "# Generated by Nextcloud on $now\n";
559-
$content .= "# line below if for Apache 2.4\n";
560-
$content .= "<ifModule mod_authz_core.c>\n";
561-
$content .= "Require all denied\n";
562-
$content .= "</ifModule>\n\n";
563-
$content .= "# line below if for Apache 2.2\n";
564-
$content .= "<ifModule !mod_authz_core.c>\n";
565-
$content .= "deny from all\n";
566-
$content .= "Satisfy All\n";
567-
$content .= "</ifModule>\n\n";
568-
$content .= "# section for Apache 2.2 and 2.4\n";
569-
$content .= "<ifModule mod_autoindex.c>\n";
570-
$content .= "IndexIgnore *\n";
571-
$content .= "</ifModule>\n";
559+
$content .= "# Section for Apache 2.4 to 2.6\n";
560+
$content .= "<IfModule mod_authz_core.c>\n";
561+
$content .= " Require all denied\n";
562+
$content .= "</IfModule>\n";
563+
$content .= "<IfModule mod_access_compat.c>\n";
564+
$content .= " Order Allow,Deny\n";
565+
$content .= " Deny from all\n";
566+
$content .= " Satisfy All\n";
567+
$content .= "</IfModule>\n\n";
568+
$content .= "# Section for Apache 2.2\n";
569+
$content .= "<IfModule !mod_authz_core.c>\n";
570+
$content .= " <IfModule !mod_access_compat.c>\n";
571+
$content .= " <IfModule mod_authz_host.c>\n";
572+
$content .= " Order Allow,Deny\n";
573+
$content .= " Deny from all\n";
574+
$content .= " <IifModule>\n";
575+
$content .= " Satisfy All\n";
576+
$content .= " </IfModule>\n";
577+
$content .= "</IfModule>\n\n";
578+
$content .= "# Section for Apache 2.2 to 2.6\n";
579+
$content .= "<IfModule mod_autoindex.c>\n";
580+
$content .= " IndexIgnore *\n";
581+
$content .= "</IfModule>";
572582

573583
$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
574584
file_put_contents($baseDir . '/.htaccess', $content);

0 commit comments

Comments
 (0)