Revision: 7891
          http://sourceforge.net/p/ipcop/svn/7891
Author:   owes
Date:     2015-02-15 17:02:35 +0000 (Sun, 15 Feb 2015)
Log Message:
-----------
Use restartopenvpn SUID helper to fetch server status

Modified Paths:
--------------
    ipcop/trunk/html/cgi-bin/openvpn.cgi

Modified: ipcop/trunk/html/cgi-bin/openvpn.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/openvpn.cgi        2015-02-15 17:01:39 UTC (rev 
7890)
+++ ipcop/trunk/html/cgi-bin/openvpn.cgi        2015-02-15 17:02:35 UTC (rev 
7891)
@@ -116,6 +116,8 @@
     $confighash{$key}[25] = '' unless (defined($confighash{$key}[25]));
 }
 
+my @serverstatus = `/usr/local/bin/restartopenvpn --status`;
+
 # prepare openvpn config file
 ###
 ### Useful functions
@@ -872,10 +874,7 @@
 </tr>
 END
 ;
-    my $filename = "/var/log/openvpnserver.log";
-    open(FILE, $filename) or die 'Unable to open config file.';
-    my @current = <FILE>;
-    close(FILE);
+
     my @users =();
     my $status;
     my $uid = 0;
@@ -884,7 +883,7 @@
     my $proto = "udp";
     my $address;
     my %userlookup = ();
-    foreach my $line (@current) {
+    foreach my $line (@serverstatus) {
         chomp($line);
         if ( $line =~ /^Updated,(.+)/) {
             @match = split( /^Updated,(.+)/, $line);
@@ -1684,7 +1683,6 @@
 &General::readhash('/var/ipcop/openvpn/settings', \%cgiparams);
 &General::readhasharray('/var/ipcop/vpn/caconfig', \%cahash);
 
-my @status = `/bin/cat /var/log/openvpnserver.log`;
 my $disableadvanced = '';
 
 # Defaults for several settings
@@ -1934,7 +1932,7 @@
         else {
             my $cn;
             my @match = ();
-            foreach my $line (@status) {
+            foreach my $line (@serverstatus) {
                 chomp($line);
                 if ( $line =~ 
/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/) {
                     @match = 
split(m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/, $line);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to