From 04edc3a185315108565ff495cb2d3cae5c99a3b5 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 9 Feb 2021 21:57:15 +0000 Subject: [PATCH] Implement openvpn logging --- includes/openvpn.php | 12 +++++++++++- installers/openvpnlog.sh | 3 +++ installers/raspap.sudoers | 1 + templates/openvpn/logging.php | 23 ++++++++++++++--------- 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100755 installers/openvpnlog.sh diff --git a/includes/openvpn.php b/includes/openvpn.php index 7b54d4de..16954d23 100755 --- a/includes/openvpn.php +++ b/includes/openvpn.php @@ -20,7 +20,9 @@ function DisplayOpenVPNConfig() if (isset($_POST['authPassword'])) { $authPassword = strip_tags(trim($_POST['authPassword'])); } - $return = SaveOpenVPNConfig($status, $_FILES['customFile'], $authUser, $authPassword); + if (is_uploaded_file( $_FILES["customFile"]["tmp_name"])) { + $return = SaveOpenVPNConfig($status, $_FILES['customFile'], $authUser, $authPassword); + } } elseif (isset($_POST['StartOpenVPN'])) { $status->addMessage('Attempting to start OpenVPN', 'info'); exec('sudo /bin/systemctl start openvpn-client@client', $return); @@ -53,11 +55,19 @@ function DisplayOpenVPNConfig() } $clients = preg_grep('~\login.(conf)$~', scandir(pathinfo(RASPI_OPENVPN_CLIENT_LOGIN, PATHINFO_DIRNAME))); + if (isset($_POST['log-openvpn'])) { + $logEnable = 1; + exec("sudo /etc/raspap/openvpn/openvpnlog.sh", $logOutput); + $logOutput = file_get_contents('/tmp/openvpn.log'); + } + echo renderTemplate( "openvpn", compact( "status", "serviceStatus", "openvpnstatus", + "logEnable", + "logOutput", "public_ip", "authUser", "authPassword", diff --git a/installers/openvpnlog.sh b/installers/openvpnlog.sh new file mode 100755 index 00000000..3e2d681c --- /dev/null +++ b/installers/openvpnlog.sh @@ -0,0 +1,3 @@ +#!/bin/bash +touch /tmp/openvpn.log +grep -m 50 openvpn /var/log/syslog | sudo tee /tmp/openvpn.log diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index d141653e..49d4032b 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -36,6 +36,7 @@ www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/servicestart.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/lighttpd/configport.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/configauth.sh +www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/openvpnlog.sh www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/hostapd.log www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/dnsmasq.log www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.d/090_adblock.conf diff --git a/templates/openvpn/logging.php b/templates/openvpn/logging.php index caba8862..4d44cece 100644 --- a/templates/openvpn/logging.php +++ b/templates/openvpn/logging.php @@ -1,11 +1,16 @@ +
-

-
-
- '; - ?> -
-
-
+

+

openvpn activity.") ?>

+ +
+ aria-describedby="log-openvpn"> + +
+
+
+ +
+
+