Commit 4eb29b22 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: no reason to store packet capture on root partition

If there is not enough space in /tmp, it's really nothing we
can do about here.  This is not an essential file.

(cherry picked from commit 123ed735)
parent 26aeb193
...@@ -106,12 +106,10 @@ function start_capture($options) ...@@ -106,12 +106,10 @@ function start_capture($options)
if (!empty($intf)) { if (!empty($intf)) {
$cmd = '/usr/sbin/tcpdump '; $cmd = '/usr/sbin/tcpdump ';
$cmd .= implode(' ', $cmd_opts); $cmd .= implode(' ', $cmd_opts);
$cmd .= ' -w /root/packetcapture.cap '; $cmd .= ' -w /tmp/packetcapture.cap ';
$cmd .= " ".escapeshellarg(implode(' and ', $filter_opts)); $cmd .= " ".escapeshellarg(implode(' and ', $filter_opts));
//delete previous packet capture if it exists //delete previous packet capture if it exists
if (file_exists('/root/packetcapture.cap')) { @unlink('/tmp/packetcapture.cap');
unlink ('/root/packetcapture.cap');
}
mwexec_bg($cmd); mwexec_bg($cmd);
} }
} }
...@@ -153,8 +151,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -153,8 +151,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// download capture file // download capture file
header("Content-Type: application/octet-stream"); header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=packetcapture.cap"); header("Content-Disposition: attachment; filename=packetcapture.cap");
header("Content-Length: ".filesize("/root/packetcapture.cap")); header("Content-Length: ".filesize("/tmp/packetcapture.cap"));
$file = fopen("/root/packetcapture.cap", "r"); $file = fopen("/tmp/packetcapture.cap", "r");
while(!feof($file)) { while(!feof($file)) {
print(fread($file, 32 * 1024)); print(fread($file, 32 * 1024));
ob_flush(); ob_flush();
...@@ -188,7 +186,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -188,7 +186,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
$result = array(); $result = array();
$dump_output = array(); $dump_output = array();
exec("/usr/sbin/tcpdump {$disabledns} {$detail_args} -r /root/packetcapture.cap", $dump_output); exec("/usr/sbin/tcpdump {$disabledns} {$detail_args} -r /tmp/packetcapture.cap", $dump_output);
// reformat raw output to 1 packet per array item // reformat raw output to 1 packet per array item
foreach ($dump_output as $line) { foreach ($dump_output as $line) {
if ($line[0] == ' ' && count($result) > 0) { if ($line[0] == ' ' && count($result) > 0) {
...@@ -250,9 +248,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -250,9 +248,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} elseif (!empty($pconfig['stop'])) { } elseif (!empty($pconfig['stop'])) {
stop_capture(); stop_capture();
} elseif (!empty($pconfig['remove'])) { } elseif (!empty($pconfig['remove'])) {
if (file_exists('/root/packetcapture.cap')) { @unlink('/tmp/packetcapture.cap');
unlink ('/root/packetcapture.cap');
}
header("Location: diag_packet_capture.php"); header("Location: diag_packet_capture.php");
exit; exit;
} }
...@@ -459,7 +455,7 @@ include("fbegin.inc"); ...@@ -459,7 +455,7 @@ include("fbegin.inc");
else:?> else:?>
<input type="submit" class="btn" name="start" value="<?=gettext("Start");?>"/> <input type="submit" class="btn" name="start" value="<?=gettext("Start");?>"/>
<?php <?php
if (file_exists('/root/packetcapture.cap')):?> if (file_exists('/tmp/packetcapture.cap')):?>
<button type="button" id="view" class="btn"> <?=gettext("View Capture");?> </button> <button type="button" id="view" class="btn"> <?=gettext("View Capture");?> </button>
<a href="?download" type="submit" class="btn"><?=gettext("Download Capture");?></a> <a href="?download" type="submit" class="btn"><?=gettext("Download Capture");?></a>
<input type="submit" class="btn" name="remove" value="<?=gettext("Delete Capture");?>"/> <input type="submit" class="btn" name="remove" value="<?=gettext("Delete Capture");?>"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment