From patchwork Sun Jun 28 10:48:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Feddersen X-Patchwork-Id: 3230 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 49vnRw3fg2z3x34 for ; Sun, 28 Jun 2020 10:49:16 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 49vnRv642Lz2Ps; Sun, 28 Jun 2020 10:49:15 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 49vnRs6598z2yZX; Sun, 28 Jun 2020 10:49:13 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 49vnRq5HwQz2yNV for ; Sun, 28 Jun 2020 10:49:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 49vnRn4q9jzxQ; Sun, 28 Jun 2020 10:49:09 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1593341349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=XD4no1fFSZO1UP4BLRn8VvwOHnwvxe0RuVH5NZQkqHg=; b=9xae91aRFqM8oaloVWY/aehLStTYFuFXX8eLmmjne2DdiTJy8Tnvpof0V6/bIOekAXF7XO tDPsGkcjeWojMEBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1593341349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=XD4no1fFSZO1UP4BLRn8VvwOHnwvxe0RuVH5NZQkqHg=; b=fy4s+7JKSmqEB+zDvcFuvqV4l/5/vBIfzri1riuyqp/apo1+8EHlr6gWrOqe2D8AalB/rW a2D9LD9PEKyJr8rka2QMvC6ocTt1+g2TL4b4+r2hQyVTMEnfnxPOlLqIFIw4XfBbSpsE4F g3u/ghbnzNMAe7Cb6gob/Z2hMTpK8EL0H0bmaKnn7w2lDBnkqJpfc0qrn+CwjUIP/kiP4p 20mHwNut/woSxpH9bDGCZnhxCu2gfc5h/jTdSZ+3tHvkmj8ygMd472SF+T4l4eOSA8yn08 VDQMwInQxjF5ujTwaGodOxWKnAPBGDU7OZ5dAxPl6b4/ROr3nInyxPPLV+p1/g== From: Stephan Feddersen To: development@lists.ipfire.org Subject: [PATCH] WIO - shutdown function removed, adjustments to IPsec status display Date: Sun, 28 Jun 2020 12:48:59 +0200 Message-Id: <20200628104859.28878-1-sfeddersen@ipfire.org> Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=sfeddersen@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephan Feddersen Errors-To: development-bounces@lists.ipfire.org Sender: "Development" --- src/wio/main/wiovpn.pl | 50 +++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/wio/main/wiovpn.pl b/src/wio/main/wiovpn.pl index c4c6b5739..22116cd62 100644 --- a/src/wio/main/wiovpn.pl +++ b/src/wio/main/wiovpn.pl @@ -3,7 +3,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2017-2018 Stephan Feddersen # +# Copyright (C) 2017-2020 Stephan Feddersen # # All Rights Reserved. # # # # This program is free software: you can redistribute it and/or modify # @@ -21,14 +21,14 @@ # # ############################################################################### # -# Version: 2018/01/05 12:32:23 +# Version: 2020/05/04 12:02:23 # -# This wioovpn.pl is based on the Code from the IPCop WIO Addon +# This wioovpn.pl is based on the code from the IPCop WIO Addon # and is extremly adapted to work with IPFire. # # Autor: Stephan Feddersen # Co-Autor: Alexander Marx -# Co-Autor: Frank Mainz +# Co-Autor: Frank Mainz (for some code for the IPCop WIO Addon) # # enable only the following on debugging purpose @@ -37,8 +37,6 @@ use strict; use POSIX qw(strftime); -my $logdir = "/var/log/wio"; - require '/var/ipfire/general-functions.pl'; require '/var/ipfire/lang.pl'; require '/usr/lib/wio/wio-lib.pl'; @@ -55,7 +53,7 @@ my ( @ovpnstatus, @ovpncfg, @ovpncache, @ovpnarray, @ovpnmatch, @ovpnwrite ); my $now = strftime "%a, %d.%m.%Y %H:%M:%S", localtime; my $ovpnpid = "/var/run/openvpn.pid"; my $ovpnmailmsg = ''; -my $ovpncache = "$logdir/.ovpncache"; +my $ovpncache = "/var/log/wio/.ovpncache"; my $ovpnconfig = "/var/ipfire/ovpn/ovpnconfig"; my ( $name, $nameul, $ovpnclt, $ovpncltip, $realipadr, $connected ) = ''; @@ -65,10 +63,10 @@ my ( @vpnstatus, @vpncfg, @vpncache, @vpnarray, @vpnwrite ); my $vpnpid = "/var/run/charon.pid"; my $vpnmailmsg = ''; -my $vpncache = "$logdir/.vpncache"; +my $vpncache = "/var/log/wio/.vpncache"; my $vpnconfig = "/var/ipfire/vpn/config"; -my ( $activ, $vpnmailsub, $vpnrwstatus, $status,) = ''; +my ( $vpnmailsub, $vpnrwstatus ) = ''; my $togglestat = 0; @@ -100,9 +98,7 @@ foreach (@ovpncfg) { ( $name, $remark ) = (split (/\,/, $_))[3, 26]; - $status = 'off'; - - unless ( grep (/$name/, @ovpncache) ) { push (@ovpncache, "$name,$remark,$status\n"); } + unless ( grep (/$name/, @ovpncache) ) { push (@ovpncache, "$name,$remark,off\n"); } } foreach (@ovpncache) { @@ -110,7 +106,7 @@ foreach (@ovpncache) { ( $name, $remark, $status ) = split (/\,/, $_); - if ( grep (/,$name,/, @ovpncfg) ) { push (@ovpnarray, "$name,$remark,$status\n"); } + if ( grep (/$name/, @ovpncfg) ) { push (@ovpnarray, "$name,$remark,$status\n"); } } foreach (@ovpnarray) { @@ -118,6 +114,9 @@ foreach (@ovpnarray) { ( $name, $remark, $status ) = split (/\,/, $_); + $remark = `/bin/cat $ovpnconfig | grep '$name' | cut -d "," -f 27`; + chomp ($remark); + if ( $name =~ m/_/ ) { $nameul = $name; } else { ($nameul = $name) =~ s/ /_/g; } @@ -196,15 +195,13 @@ if ( ! -e "$vpnpid" ) { } else { -if ( -e "$vpnpid" ) { - @vpnstatus = `/usr/local/bin/ipsecctrl I`; -} +@vpnstatus = `/usr/local/bin/ipsecctrl I`; open(FILE, "$vpnconfig"); @vpncfg = ; close (FILE); -if ( ! -e "$vpncache" ) { +unless ( -e "$vpncache" ) { open(FILE, ">$vpncache"); close (FILE); } @@ -217,15 +214,9 @@ else { foreach (@vpncfg) { chomp; - ( $activ, $name, $remark ) = (split (/\,/, $_))[1, 2, 26]; + ( $name, $remark ) = (split (/\,/, $_))[2, 26]; - if ( $remark eq 'off' ) { $remark = '-'; } - - $status = 'off'; - - if ( $activ eq "off" ) { next; } - - unless ( grep (/$name/, @vpncache) ) { push (@vpncache, "$name,$remark,$status\n"); } + unless ( grep (/$name/, @vpncache) ) { push (@vpncache, "$name,$remark,off\n"); } } foreach (@vpncache) { @@ -233,7 +224,7 @@ foreach (@vpncache) { ( $name, $remark, $status ) = split (/\,/, $_); - if ( grep (/,$name,/, @vpncfg) ) { push (@vpnarray, "$name,$remark,$status\n"); } + if ( grep (/$name/, @vpncfg) ) { push (@vpnarray, "$name,$remark,$status\n"); } } foreach (@vpnarray) { @@ -241,6 +232,9 @@ foreach (@vpnarray) { ( $name, $remark, $status ) = split (/\,/, $_); + $remark = `/bin/cat $vpnconfig | grep '$name' | cut -d "," -f 27`; + chomp ($remark); + if ( grep (/$name\{.*INSTALLED/ , @vpnstatus) ) { $vpnrwstatus = "$Lang::tr{'wio up'}"; $togglestat = ( $status ne 'on' ) ? 1 : 0; @@ -255,8 +249,8 @@ foreach (@vpnarray) { push (@vpnwrite, "$name,$remark,$status\n"); if ( $togglestat == 1 ) { - $vpnmailsub = "WIO VPN - $name - $vpnrwstatus - $now"; - $logmsg = "Client: WIO VPN $name - Status: $vpnrwstatus $now"; + $vpnmailsub = "WIO IPsec - $name - $vpnrwstatus - $now"; + $logmsg = "Client: WIO IPSec $name - Status: $vpnrwstatus $now"; $vpnmailmsg = "Client : $name\n"; if ( $status eq 'on' ) {