Skip to content

Commit

Permalink
htaccess_works() can't use var/tmp anymore because that's locked down.
Browse files Browse the repository at this point in the history
So just create var/security_test and delete it when we're done.
  • Loading branch information
bharat committed Jan 31, 2010
1 parent ee35b0a commit c5471a7
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions modules/gallery/helpers/access.php
Expand Up @@ -663,23 +663,28 @@ static function private_key() {
* working and our permission system works.
*/
static function htaccess_works() {
$success_url = url::file("var/tmp/security_test/success");
$success_url = url::file("var/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);
}
@mkdir(VARPATH . "security_test");
try {
if ($fp = @fopen(VARPATH . "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);
}
if ($fp = @fopen(VARPATH . "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");
list ($response) = remote::do_request(url::abs_file("var/security_test/verify"));
$works = $response == "HTTP/1.1 200 OK";
} catch (Exception $e) {
@dir::unlink(VARPATH . "security_test");
throw $e;
}
@dir::unlink(VARPATH . "security_test");

return $works;
}
Expand Down

0 comments on commit c5471a7

Please sign in to comment.