summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-05-25 01:33:53 +0000
committerGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-05-25 01:33:53 +0000
commitbe6b7b0f1dcbb861115a385b07f8c814a2b40a1a (patch)
tree9a138b2264dfbfc26e38411b025629574cca5128
parent369c776c4c7a4187a075fafd429e515ba6325e97 (diff)
downloadbrdo-be6b7b0f1dcbb861115a385b07f8c814a2b40a1a.tar.gz
brdo-be6b7b0f1dcbb861115a385b07f8c814a2b40a1a.tar.bz2
prevent execution of scripts from files directory
-rw-r--r--INSTALL.txt7
-rw-r--r--includes/file.inc12
2 files changed, 19 insertions, 0 deletions
diff --git a/INSTALL.txt b/INSTALL.txt
index 61e1b66b3..d13cb101f 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -144,6 +144,13 @@ INSTALLATION
by the Drupal server process. You can change the name of this
subdirectory at "Administer > Settings > File system settings".
+ SECURITY NOTICE: Certain Apache configurations can be vulnerable
+ to a security exploit allowing arbitrary code execution. Drupal
+ will attempt to automatically create a .htaccess file in your
+ "files" directory to protect you. If you already have a .htaccess
+ file in that location, please add the following line:
+ SetHandler This_is_a_Drupal_security_line_do_not_remove
+
You can now launch your browser and point it to your Drupal site.
Create an account and login. The first account will automatically
diff --git a/includes/file.inc b/includes/file.inc
index 51012e45f..802df5656 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -112,6 +112,18 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
}
}
+ if ((file_directory_path() == $directory || file_directory_temp() == $directory) && !is_file("$directory/.htaccess")) {
+ if (($fp = fopen("$directory/.htaccess", 'w')) && fputs($fp, 'SetHandler This_is_a_Drupal_security_line_do_not_remove')) {
+ fclose($fp);
+ }
+ else {
+ $message = t("Security warning: Couldn't write .htaccess. Please create a .htaccess file in your %directory directory which contains the following line: <code>SetHandler This_is_a_Drupal_security_line_do_not_remove</code>", array('%directory' => $directory));
+ form_set_error($form_item, $message);
+ watchdog('file system', $message, WATCHDOG_ERROR);
+ }
+ }
+
+
return true;
}