From e422b4908e81ff69a6b5f736ad9b4154f2986aa2 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 27 Sep 2022 11:46:59 +0200 Subject: [PATCH] Apply functionality to dnsmasq log --- ajax/logging/clearlog.php | 8 ++++---- app/js/custom.js | 9 ++++++++- installers/raspap.sudoers | 2 +- templates/dhcp/logging.php | 5 +++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ajax/logging/clearlog.php b/ajax/logging/clearlog.php index a798bb3c..cfab253b 100644 --- a/ajax/logging/clearlog.php +++ b/ajax/logging/clearlog.php @@ -3,10 +3,10 @@ require_once '../../includes/config.php'; require_once '../../includes/functions.php'; -if (isset($_POST['svc'])) { - $tmplog = '/tmp/' .$_POST['svc']. '.log'; +if (isset($_POST['logfile'])) { + $logfile = $_POST['logfile']; - // clear log for requested service - exec("sudo truncate -s 0 $tmplog", $return); + // truncate requested log file + exec("sudo truncate -s 0 $logfile", $return); echo json_encode($return); } diff --git a/app/js/custom.js b/app/js/custom.js index f9217a6e..e0ede530 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -123,12 +123,19 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) { }); $(document).on("click", "#js-clearhostapd-log", function(e) { - $.post('ajax/logging/clearlog.php?',{'svc':'hostapd'},function(data){ + $.post('ajax/logging/clearlog.php?',{'logfile':'/tmp/hostapd.log'},function(data){ jsonData = JSON.parse(data); $("#hostapd-log").val(""); }); }); +$(document).on("click", "#js-cleardnsmasq-log", function(e) { + $.post('ajax/logging/clearlog.php?',{'logfile':'/var/log/dnsmasq.log'},function(data){ + jsonData = JSON.parse(data); + $("#dnsmasq-log").val(""); + }); +}); + // Enable Bootstrap tooltips $(function () { $('[data-toggle="tooltip"]').tooltip() diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index 094af055..8e7b3e72 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -63,4 +63,4 @@ www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/wg-*.key www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/*.conf www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/wg-*.key www-data ALL=(ALL) NOPASSWD:/usr/sbin/netplan -www-data ALL=(ALL) NOPASSWD:/bin/truncate -s 0 /tmp/*.log +www-data ALL=(ALL) NOPASSWD:/bin/truncate -s 0 /tmp/*.log,/bin/truncate -s 0 /var/log/dnsmasq.log diff --git a/templates/dhcp/logging.php b/templates/dhcp/logging.php index ca54a30b..0541e592 100644 --- a/templates/dhcp/logging.php +++ b/templates/dhcp/logging.php @@ -9,7 +9,8 @@
aria-describedby="log-dhcp-queries"> - + + " />
@@ -18,7 +19,7 @@ if ($conf['log-dhcp'] == 1 || $conf['log-queries'] == 1) { exec('sudo /bin/chmod o+r '.RASPI_DHCPCD_LOG); $log = file_get_contents(RASPI_DHCPCD_LOG); - echo ''; + echo ''; } else { echo ''; }