summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-21 06:06:08 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-21 06:06:08 +0000
commitc9101bc0868e64fdeb45d13d2e0a7b4cbf17e35c (patch)
tree4adc973c975c5c17dcbb7bc700bd5c3f685d122c /core/helpers
parentcce2f3e77ac0b79b5cc94a5404693e358adf2e54 (diff)
Check to make sure that our permission system is working and report
back to our users in the edit permissions dialog.
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/access.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/helpers/access.php b/core/helpers/access.php
index c766870b..b9472aa0 100644
--- a/core/helpers/access.php
+++ b/core/helpers/access.php
@@ -595,4 +595,32 @@ class access_Core {
static function private_key() {
return module::get_var("core", "private_key");
}
+
+ /**
+ * Verify that our htaccess based permission system actually works. Create a temporary
+ * directory containing an .htaccess file that uses mod_rewrite to redirect /verify to
+ * /success. Then request that url. If we retrieve it successfully, then our redirects are
+ * working and our permission system works.
+ */
+ static function htaccess_works() {
+ $success_url = url::file("var/tmp/security_test/success");
+
+ @mkdir(VARPATH . "tmp/security_test");
+ if ($fp = @fopen(VARPATH . "tmp/security_test/.htaccess", "w+")) {
+ fwrite($fp, "RewriteEngine On\n");
+ fwrite($fp, "RewriteRule verify $success_url [L]\n");
+ fclose($fp);
+ }
+
+ if ($fp = @fopen(VARPATH . "tmp/security_test/success", "w+")) {
+ fwrite($fp, "success");
+ fclose($fp);
+ }
+
+ list ($response) = remote::do_request(url::abs_file("var/tmp/security_test/verify"));
+ $works = $response == "HTTP/1.1 200 OK";
+ @dir::unlink(VARPATH . "tmp/security_test");
+
+ return $works;
+ }
}