@@ -164,16 +164,19 @@ public static function createConfig(IOInterface $io = null, $cwd = null)
164164 'data-dir ' => self ::getDataDir ($ home ),
165165 )));
166166
167- // Protect directory against web access. Since HOME could be
168- // the www-data's user home and be web-accessible it is a
169- // potential security risk
170- $ dirs = array ($ config ->get ('home ' ), $ config ->get ('cache-dir ' ), $ config ->get ('data-dir ' ));
171- foreach ($ dirs as $ dir ) {
172- if (!file_exists ($ dir . '/.htaccess ' )) {
173- if (!is_dir ($ dir )) {
174- Silencer::call ('mkdir ' , $ dir , 0777 , true );
167+ $ htaccessProtect = (bool ) $ config ->get ('htaccess-protect ' );
168+ if ($ htaccessProtect ) {
169+ // Protect directory against web access. Since HOME could be
170+ // the www-data's user home and be web-accessible it is a
171+ // potential security risk
172+ $ dirs = array ($ config ->get ('home ' ), $ config ->get ('cache-dir ' ), $ config ->get ('data-dir ' ));
173+ foreach ($ dirs as $ dir ) {
174+ if (!file_exists ($ dir . '/.htaccess ' )) {
175+ if (!is_dir ($ dir )) {
176+ Silencer::call ('mkdir ' , $ dir , 0777 , true );
177+ }
178+ Silencer::call ('file_put_contents ' , $ dir . '/.htaccess ' , 'Deny from all ' );
175179 }
176- Silencer::call ('file_put_contents ' , $ dir . '/.htaccess ' , 'Deny from all ' );
177180 }
178181 }
179182
0 commit comments