From 94545631230bc36d62d0f71358afcd7571bec2b0 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 24 Apr 2017 21:29:44 -0400 Subject: [PATCH 1/2] Temporarily store the teleporter file Store under /etc/pihole instead of the web server, and delete after sending. --- scripts/pi-hole/php/teleporter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index 0965d109..5a2258e6 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -148,7 +148,7 @@ if(isset($_POST["action"])) else { $filename = "pi-hole-teleporter_".date("Y-m-d_h-i-s").".zip"; - $archive_file_name = "/var/www/html/".$filename; + $archive_file_name = "/etc/pihole/".$filename; $zip = new ZipArchive(); touch($archive_file_name); $res = $zip->open($archive_file_name, ZipArchive::CREATE | ZipArchive::OVERWRITE); @@ -174,6 +174,8 @@ else header("Expires: 0"); if(ob_get_length() > 0) ob_end_clean(); readfile($archive_file_name); + ignore_user_abort(true); + unlink($archive_file_name); exit; } From 631f0504409b4659880c0a7f1cfeb6e1906eca76 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 29 Apr 2017 13:10:53 +0200 Subject: [PATCH 2/2] Create temporary file with write/read permissions only for the PHP user --- scripts/pi-hole/php/teleporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index 5a2258e6..65701d0f 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -148,7 +148,7 @@ if(isset($_POST["action"])) else { $filename = "pi-hole-teleporter_".date("Y-m-d_h-i-s").".zip"; - $archive_file_name = "/etc/pihole/".$filename; + $archive_file_name = tempnam("/tmp", "Teleporter"); $zip = new ZipArchive(); touch($archive_file_name); $res = $zip->open($archive_file_name, ZipArchive::CREATE | ZipArchive::OVERWRITE);