]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
Merge remote-tracking branch 'origin/master' into kernel-update
authorArne Fitzenreiter <arne_f@ipfire.org>
Sat, 21 Jul 2012 21:54:31 +0000 (23:54 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sat, 21 Jul 2012 21:54:31 +0000 (23:54 +0200)
13 files changed:
config/calamaris/mkreport
config/rootfiles/common/misc-progs
config/rootfiles/core/61/filelists/files
html/cgi-bin/connections.cgi
html/cgi-bin/credits.cgi
html/cgi-bin/index.cgi
html/cgi-bin/ovpnmain.cgi
html/cgi-bin/proxy.cgi [changed mode: 0644->0755]
html/cgi-bin/services.cgi
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl
src/misc-progs/Makefile
src/misc-progs/getconntracktable.c [new file with mode: 0644]

index 53db9d5715d3c4cc064ad218267f2420b32213df..ee831624cc5d750a9797b9ed334f34b7682382c3 100644 (file)
@@ -94,7 +94,7 @@ sub processlogfiles
                {
                        if ($filestr =~ /access\.log/) {
                                open (LOG,"gzip -dc $filestr |");
-                               foreach (<LOG>) {
+                               while (<LOG>) {
                                        if (substr($_,0,10) >= $date_from) { if (substr($_,0,10) <= $date_to) { print TMPLOG "$_"; } }
                                }
                                close(LOG);
@@ -106,7 +106,7 @@ sub processlogfiles
        {
                if ($filestr =~ /access\.log/) {
                        open (LOG,$filestr);
-                       foreach (<LOG>) {
+                       while (<LOG>) {
                                if (substr($_,0,10) >= $date_from) { if (substr($_,0,10) <= $date_to) { print TMPLOG "$_"; } }
                        }
                        close(LOG);
index adab51bc1eea62f39c70c0e8101a43476534b5ed..3c0b398d3aaf3270193dae2d9299103c12f14bb1 100644 (file)
@@ -5,6 +5,7 @@ usr/local/bin/backupctrl
 usr/local/bin/dhcpctrl
 usr/local/bin/extrahdctrl
 usr/local/bin/fireinfoctrl
+usr/local/bin/getconntracktable
 usr/local/bin/getipstat
 usr/local/bin/getiptstate
 #usr/local/bin/iowrap
index 1624d83b54cff03f690c77b9e490c4ee9c1cda36..55fbcf19f36207aaeec96f37a00679dcdb94bc7a 100644 (file)
@@ -2,9 +2,14 @@ etc/system-release
 etc/issue
 etc/rc.d/init.d/collectd
 opt/pakfire/lib/functions.sh
+srv/web/ipfire/cgi-bin/credits.cgi
 srv/web/ipfire/cgi-bin/index.cgi
+srv/web/ipfire/cgi-bin/connections.cgi
 srv/web/ipfire/cgi-bin/ovpnmain.cgi
 srv/web/ipfire/cgi-bin/proxy.cgi
+srv/web/ipfire/cgi-bin/services.cgi
 var/ipfire/general-functions.pl
 var/ipfire/langs
+var/ipfire/proxy/calamaris/bin/mkreport
+usr/local/bin/getconntracktable
 usr/sbin/redirect_wrapper
index 14ee20910509b0e9633e6b5d586039d7cda7d12e..21f66d7b2c7a06315309f1bbefb0c35a133b2377 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2011  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2012  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
 #                                                                             #
 ###############################################################################
 
-my @network=();
-my @masklen=();
-my @colour=();
+use strict;
 
 use Net::IPv4Addr qw( :all );
-
-use strict;
+use Switch;
 
 # enable only the following on debugging purpose
 #use warnings;
@@ -35,42 +32,62 @@ require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+&Header::showhttpheaders();
+
+my @network=();
+my @masklen=();
+my @colour=();
+
+my %netsettings=();
+&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
+
 #workaround to suppress a warning when a variable is used only once
 my @dummy = ( ${Header::table1colour} );
 undef (@dummy);
 
-# Read various files
+# Read the connection tracking table.
+open(CONNTRACK, "/usr/local/bin/getconntracktable | sort -k 5,5 --numeric-sort --reverse |") or die "Unable to read conntrack table";
+my @conntrack = <CONNTRACK>;
+close(CONNTRACK);
 
-my %netsettings=();
-&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
+# Collect data for the @network array.
 
-open (ACTIVE, '/usr/local/bin/getiptstate |') or die 'Unable to open ip_conntrack';
-my @active = <ACTIVE>;
-close (ACTIVE);
+# Add Firewall Localhost 127.0.0.1
+push(@network, '127.0.0.1');
+push(@masklen, '255.255.255.255');
+push(@colour, ${Header::colourfw});
 
 if (open(IP, "${General::swroot}/red/local-ipaddress")) {
-        my $redip = <IP>;
-        close(IP);
-        chomp $redip;
-        push(@network, $redip);
-        push(@masklen, '255.255.255.255' );
-        push(@colour, ${Header::colourfw} );
+       my $redip = <IP>;
+       close(IP);
+
+       chomp $redip;
+       push(@network, $redip);
+       push(@masklen, '255.255.255.255');
+       push(@colour, ${Header::colourfw});
 }
 
-my @vpn = `/usr/local/bin/ipsecctrl I 2>/dev/null|grep erouted|cut -d"]" -f3|cut -d"=" -f4|cut -d";" -f1| sed "s|/| |g"`;
-  foreach my $route (@vpn) {
-                chomp($route);
-                my @temp = split(/[\t ]+/, $route);
-                if ( $temp[0] eq '$redip' ){next;}
-                push(@network, $temp[0]);
-                push(@masklen, $temp[1]);
-                push(@colour, ${Header::colourvpn} );
-        }
-
-my $aliasfile = "${General::swroot}/ethernet/aliases";
-open(ALIASES, $aliasfile) or die 'Unable to open aliases file.';
-my @aliases = <ALIASES>;
-close(ALIASES);
+# Add STATIC RED aliases
+if ($netsettings{'RED_DEV'}) {
+       my $aliasfile = "${General::swroot}/ethernet/aliases";
+       open(ALIASES, $aliasfile) or die 'Unable to open aliases file.';
+       my @aliases = <ALIASES>;
+       close(ALIASES);
+
+       # We have a RED eth iface
+       if ($netsettings{'RED_TYPE'} eq 'STATIC') {
+               # We have a STATIC RED eth iface
+               foreach my $line (@aliases) {
+                       chomp($line);
+                       my @temp = split(/\,/,$line);
+                       if ($temp[0]) {
+                               push(@network, $temp[0]);
+                               push(@masklen, $netsettings{'RED_NETMASK'} );
+                               push(@colour, ${Header::colourfw} );
+                       }
+               }
+       }
+}
 
 # Add Green Firewall Interface
 push(@network, $netsettings{'GREEN_ADDRESS'});
@@ -85,32 +102,11 @@ push(@colour, ${Header::colourgreen} );
 # Add Green Routes to Array
 my @routes = `/sbin/route -n | /bin/grep $netsettings{'GREEN_DEV'}`;
 foreach my $route (@routes) {
-        chomp($route);
-        my @temp = split(/[\t ]+/, $route);
-        push(@network, $temp[0]);
-        push(@masklen, $temp[2]);
-        push(@colour, ${Header::colourgreen} );
-}
-
-# Add Firewall Localhost 127.0.0.1
-push(@network, '127.0.0.1');
-push(@masklen, '255.255.255.255' );
-push(@colour, ${Header::colourfw} );
-
-# Add Orange Network
-if ($netsettings{'ORANGE_DEV'}) {
-        push(@network, $netsettings{'ORANGE_NETADDRESS'});
-        push(@masklen, $netsettings{'ORANGE_NETMASK'} );
-        push(@colour, ${Header::colourorange} );
-        # Add Orange Routes to Array
-        @routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
-        foreach my $route (@routes) {
-                  chomp($route);
-                my @temp = split(/[\t ]+/, $route);
-                push(@network, $temp[0]);
-                push(@masklen, $temp[2]);
-                push(@colour, ${Header::colourorange} );
-        }
+       chomp($route);
+       my @temp = split(/[\t ]+/, $route);
+       push(@network, $temp[0]);
+       push(@masklen, $temp[2]);
+       push(@colour, ${Header::colourgreen} );
 }
 
 # Add Blue Firewall Interface
@@ -120,304 +116,357 @@ push(@colour, ${Header::colourfw} );
 
 # Add Blue Network
 if ($netsettings{'BLUE_DEV'}) {
-        push(@network, $netsettings{'BLUE_NETADDRESS'});
-        push(@masklen, $netsettings{'BLUE_NETMASK'} );
-        push(@colour, ${Header::colourblue} );
-        # Add Blue Routes to Array
-        @routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
-        foreach my $route (@routes) {
-                  chomp($route);
-                my @temp = split(/[\t ]+/, $route);
-                push(@network, $temp[0]);
-                push(@masklen, $temp[2]);
-                push(@colour, ${Header::colourblue} );
-        }
+       push(@network, $netsettings{'BLUE_NETADDRESS'});
+       push(@masklen, $netsettings{'BLUE_NETMASK'} );
+       push(@colour, ${Header::colourblue} );
+
+       # Add Blue Routes to Array
+       @routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
+       foreach my $route (@routes) {
+               chomp($route);
+               my @temp = split(/[\t ]+/, $route);
+               push(@network, $temp[0]);
+               push(@masklen, $temp[2]);
+               push(@colour, ${Header::colourblue} );
+       }
+}
+
+# Add Orange Network
+if ($netsettings{'ORANGE_DEV'}) {
+       push(@network, $netsettings{'ORANGE_NETADDRESS'});
+       push(@masklen, $netsettings{'ORANGE_NETMASK'} );
+       push(@colour, ${Header::colourorange} );
+       # Add Orange Routes to Array
+       @routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
+       foreach my $route (@routes) {
+               chomp($route);
+               my @temp = split(/[\t ]+/, $route);
+               push(@network, $temp[0]);
+               push(@masklen, $temp[2]);
+               push(@colour, ${Header::colourorange} );
+       }
 }
 
 # Add OpenVPN net and RED/BLUE/ORANGE entry (when appropriate)
 if (-e "${General::swroot}/ovpn/settings") {
-    my %ovpnsettings = ();    
-    &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
-    my @tempovpnsubnet = split("\/",$ovpnsettings{'DOVPN_SUBNET'});
-
-    # add OpenVPN net
-                push(@network, $tempovpnsubnet[0]);
-                push(@masklen, $tempovpnsubnet[1]);
-                push(@colour, ${Header::colourovpn} );
-
-
-    if ( ($ovpnsettings{'ENABLED_BLUE'} eq 'on') && $netsettings{'BLUE_DEV'} ) {
-      # add BLUE:port / proto
-            push(@network, $netsettings{'BLUE_ADDRESS'} );
-            push(@masklen, '255.255.255.255' );
-                  push(@colour, ${Header::colourovpn} );
-    }
-    if ( ($ovpnsettings{'ENABLED_ORANGE'} eq 'on') && $netsettings{'ORANGE_DEV'} ) {
-      # add ORANGE:port / proto
-            push(@network, $netsettings{'ORANGE_ADDRESS'} );
-            push(@masklen, '255.255.255.255' );
-                  push(@colour, ${Header::colourovpn} );
-    }
-}
+       my %ovpnsettings = ();
+       &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
+       my @tempovpnsubnet = split("\/",$ovpnsettings{'DOVPN_SUBNET'});
+
+       # add OpenVPN net
+       push(@network, $tempovpnsubnet[0]);
+       push(@masklen, $tempovpnsubnet[1]);
+       push(@colour, ${Header::colourovpn} );
+
+       # add BLUE:port / proto
+       if (($ovpnsettings{'ENABLED_BLUE'} eq 'on') && $netsettings{'BLUE_DEV'}) {
+               push(@network, $netsettings{'BLUE_ADDRESS'} );
+               push(@masklen, '255.255.255.255' );
+               push(@colour, ${Header::colourovpn});
+       }
 
-# Add STATIC RED aliases
-if ($netsettings{'RED_DEV'}) {
-        # We have a RED eth iface
-        if ($netsettings{'RED_TYPE'} eq 'STATIC') {
-                # We have a STATIC RED eth iface
-                foreach my $line (@aliases)
-                {
-                        chomp($line);
-                        my @temp = split(/\,/,$line);
-                        if ( $temp[0] ) {
-                                push(@network, $temp[0]);
-                                push(@masklen, $netsettings{'RED_NETMASK'} );
-                                push(@colour, ${Header::colourfw} );
-                        }
-                }
-        }
+       # add ORANGE:port / proto
+       if (($ovpnsettings{'ENABLED_ORANGE'} eq 'on') && $netsettings{'ORANGE_DEV'}) {
+               push(@network, $netsettings{'ORANGE_ADDRESS'} );
+               push(@masklen, '255.255.255.255' );
+               push(@colour, ${Header::colourovpn} );
+       }
 }
 
-# Add VPNs
-if ( $vpn[0] ne 'none' ) {
-        foreach my $line (@vpn) {
-                my @temp = split(/[\t ]+/,$line);
-                my @temp1 = split(/[\/:]+/,$temp[3]);
-                push(@network, $temp1[0]);
-                push(@masklen, ipv4_cidr2msk($temp1[1]));
-                push(@colour, ${Header::colourvpn} );
-        }
-}
+open(IPSEC, "${General::swroot}/var/ipfire/vpn/config");
+my @ipsec = <IPSEC>;
+close(IPSEC);
 
-#Establish simple filtering&sorting boxes on top of table
+foreach my $line (@ipsec) {
+       my @vpn = split(',', $line);
+       my ($network, $mask) = split("/", $vpn[12]);
 
-our %cgiparams;
-&Header::getcgihash(\%cgiparams);
+       if (!&General::validip($mask)) {
+               $mask = ipv4_cidr2msk($mask);
+       }
 
-my @list_proto = ($Lang::tr{'all'}, 'icmp', 'udp', 'tcp');
-my @list_state = ($Lang::tr{'all'}, 'SYN_SENT', 'SYN_RECV', 'ESTABLISHED', 'FIN_WAIT',
-                    'CLOSE_WAIT', 'LAST_ACK', 'TIME_WAIT', 'CLOSE', 'LISTEN');
-my @list_mark = ($Lang::tr{'all'}, '[ASSURED]', '[UNREPLIED]');
-my @list_sort = ('orgsip','protocol', 'expires', 'status', 'orgdip', 'orgsp',
-                    'orgdp', 'exsip', 'exdip', 'exsp', 'exdp', 'marked');
+       push(@network, $network);
+       push(@masklen, $mask);
+       push(@colour, ${Header::colourvpn});
+}
 
-# init or silently correct unknown value...
-if ( ! grep ( /^$cgiparams{'SEE_PROTO'}$/ , @list_proto )) { $cgiparams{'SEE_PROTO'} = $list_proto[0] };
-if ( ! grep ( /^$cgiparams{'SEE_STATE'}$/ , @list_state )) { $cgiparams{'SEE_STATE'} = $list_state[0] };
-if ( ($cgiparams{'SEE_MARK'} ne $Lang::tr{'all'}) &&   # ok the grep should work but it doesn't because of
-     ($cgiparams{'SEE_MARK'} ne '[ASSURED]') &&                # the '[' & ']' interpreted as list separator.
-     ($cgiparams{'SEE_MARK'} ne '[UNREPLIED]')         # So, explicitly enumerate items.
-   )  { $cgiparams{'SEE_MARK'}  = $list_mark[0] };
-if ( ! grep ( /^$cgiparams{'SEE_SORT'}$/  , @list_sort ))  { $cgiparams{'SEE_SORT'}  = $list_sort[0] };
-# *.*.*.* or a valid IP
-if ( $cgiparams{'SEE_SRC'}  !~ /^(\*\.\*\.\*\.\*\.|\d+\.\d+\.\d+\.\d+)$/) {  $cgiparams{'SEE_SRC'} = '*.*.*.*' };
-if ( $cgiparams{'SEE_DEST'} !~ /^(\*\.\*\.\*\.\*\.|\d+\.\d+\.\d+\.\d+)$/) {  $cgiparams{'SEE_DEST'} = '*.*.*.*' };
+if (-e "${General::swroot}/ovpn/n2nconf") {
+       open(OVPNN2N, "${General::swroot}/ovpn/ovpnconfig");
+       my @ovpnn2n = <OVPNN2N>;
+       close(OVPNN2N);
 
+       foreach my $line (@ovpnn2n) {
+               my @ovpn = split(',', $line);
+               next if ($ovpn[4] ne 'net');
 
-our %entries = ();     # will hold the lines analyzed correctly
-my $unknownlines = ''; # should be empty all the time...
-my $index = 0;         # just a counter to make unique entryies in entries
+               my ($network, $mask) = split("/", $ovpn[12]);
+               if (!&General::validip($mask)) {
+                       $mask = ipv4_cidr2msk($mask);
+               }
 
-&Header::showhttpheaders();
+               push(@network, $network);
+               push(@masklen, $mask);
+               push(@colour, ${Header::colourovpn});
+       }
+}
+
+# Show the page.
 &Header::openpage($Lang::tr{'connections'}, 1, '');
 &Header::openbigbox('100%', 'left');
 &Header::openbox('100%', 'left', $Lang::tr{'connection tracking'});
 
-# Build listbox objects
-my $menu_proto = &make_select ('SEE_PROTO', $cgiparams{'SEE_PROTO'}, @list_proto);
-my $menu_state = &make_select ('SEE_STATE', $cgiparams{'SEE_STATE'}, @list_state);
-
-print <<END
-<form method='post' action='$ENV{'SCRIPT_NAME'}'>
-<table width='100%'>
-<tr><td align='center'><b>$Lang::tr{'legend'} : </b></td>
-    <td align='center' bgcolor='${Header::colourgreen}'><b><font color='#FFFFFF'>$Lang::tr{'lan'}</font></b></td>
-    <td align='center' bgcolor='${Header::colourred}'><b><font color='#FFFFFF'>$Lang::tr{'internet'}</font></b></td>
-    <td align='center' bgcolor='${Header::colourorange}'><b><font color='#FFFFFF'>$Lang::tr{'dmz'}</font></b></td>
-    <td align='center' bgcolor='${Header::colourblue}'><b><font color='#FFFFFF'>$Lang::tr{'wireless'}</font></b></td>
-    <td align='center' bgcolor='${Header::colourfw}'><b><font color='#FFFFFF'>IPFire</font></b></td>
-    <td align='center' bgcolor='${Header::colourvpn}'><b><font color='#FFFFFF'>$Lang::tr{'vpn'}</font></b></td>
-    <td align='center' bgcolor='${Header::colourovpn}'><b><font color='#FFFFFF'>$Lang::tr{'OpenVPN'}</font></b></td>
-</tr>
-</table>
-<br />
-<table width='100%'>
-<tr><td align='center'><font size=2>$Lang::tr{'source ip and port'}</font></td>
-               <td>&nbsp;</td>
-               <td align='center'><font size=2>$Lang::tr{'dest ip and port'}</font></td>
-               <td>&nbsp;</td>
-               <td align='center'><font size=2>$Lang::tr{'protocol'}</font></td>
-               <td align='center'><font size=2>$Lang::tr{'connection'}<br></br>$Lang::tr{'status'}</font></td>
-    <td align='center'><font size=2>$Lang::tr{'expires'}<br></br>($Lang::tr{'seconds'})</font></td>
-    
-</tr>
-<tr><td colspan='4'>&nbsp;</td>
-               <td align='center'>$menu_proto</td>
-    <td align='center'>$menu_state</td>
-    <td>&nbsp;</td>
-</tr>
-<tr>
-    <td align='center' colspan='7'></td>
-</tr>
-<tr>
-    <td align='center' colspan='7'><input type='submit' value="$Lang::tr{'update'}" /></td>
-</tr>
+# Print legend.
+print <<END;
+       <table width='100%'>
+               <tr>
+                       <td align='center'>
+                               <b>$Lang::tr{'legend'} : </b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourgreen}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'lan'}</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourred}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'internet'}</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourorange}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'dmz'}</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourblue}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'wireless'}</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourfw}'>
+                               <b><font color='#FFFFFF'>IPFire</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourvpn}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'vpn'}</font></b>
+                       </td>
+                       <td align='center' bgcolor='${Header::colourovpn}'>
+                               <b><font color='#FFFFFF'>$Lang::tr{'OpenVPN'}</font></b>
+                       </td>
+               </tr>
+       </table>
+       <br>
+END
 
+# Print table header.
+print <<END;
+       <table width='100%'>
+               <tr>
+                       <th align='center'>
+                               $Lang::tr{'protocol'}
+                       </th>
+                       <th align='center'>
+                               $Lang::tr{'source ip and port'}
+                       </th>
+                       <th>&nbsp;</th>
+                       <th align='center'>
+                               $Lang::tr{'dest ip and port'}
+                       </th>
+                       <th>&nbsp;</th>
+                       <th align='center'>
+                               $Lang::tr{'download'} /
+                               <br>$Lang::tr{'upload'}
+                       </th>
+                       <th align='center'>
+                               $Lang::tr{'connection'}<br>$Lang::tr{'status'}
+                       </th>
+                       <th align='center'>
+                               $Lang::tr{'expires'}<br>($Lang::tr{'seconds'})
+                       </th>
+               </tr>
 END
-;
-
-my $i=0;
-foreach my $line (@active) {
-    $i++;
-    if ($i < 3) {
-                       next;
-    }
-    chomp($line);
-    my @temp = split(' ',$line);
-
-    my ($sip, $sport) = split(':', $temp[0]);
-    my ($dip, $dport) = split(':', $temp[1]);
-    my $proto = $temp[2];
-    my $state; my $ttl;
-    if ( $proto eq "esp" ){$state = "";$ttl = $temp[3];}
-    elsif ( $proto eq "icmp" ){$state = "";$ttl = $temp[4];}
-    else{$state = $temp[3];$ttl = $temp[4];}
-    
-    next if( !(
-                       (($cgiparams{'SEE_PROTO'}  eq $Lang::tr{'all'}) || ($proto  eq $cgiparams{'SEE_PROTO'} ))
-                && (($cgiparams{'SEE_STATE'}  eq $Lang::tr{'all'}) || ($state  eq $cgiparams{'SEE_STATE'} ))
-               && (($cgiparams{'SEE_SRC'}    eq "*.*.*.*")        || ($sip    eq $cgiparams{'SEE_SRC'}   ))
-               && (($cgiparams{'SEE_DEST'}   eq "*.*.*.*")       || ($dip    eq $cgiparams{'SEE_DEST'}  ))
-              ));
-
-    if (($proto eq 'udp') && ($ttl eq '')) {
-                       $ttl = $state;
-                       $state = '&nbsp;';      
-    }
-
-    my $sipcol = ipcolour($sip);
-    my $dipcol = ipcolour($dip);
-
-    my $sserv = '';
-    if ($sport < 1024) {
-       $sserv = uc(getservbyport($sport, lc($proto)));
-       if ($sserv ne '') {
-           $sserv = "&nbsp;($sserv)";
+
+foreach my $line (@conntrack) {
+       my @conn = split(' ', $line);
+
+       # The first bit is the l3 protocol.
+       my $l3proto = $conn[0];
+
+       # Skip everything that is not IPv4.
+       if ($l3proto ne 'ipv4') {
+               next;
+       }
+
+       # L4 protocol (tcp, udp, ...).
+       my $l4proto = $conn[2];
+
+       # Translate unknown protocols.
+       if ($l4proto eq 'unknown') {
+               my $l4protonum = $conn[3];
+               if ($l4protonum eq '2') {
+                       $l4proto = 'IGMP';
+               } elsif ($l4protonum eq '4') {
+                       $l4proto = 'IPv4 Encap';
+               } elsif ($l4protonum eq '33') {
+                       $l4proto = 'DCCP';
+               } elsif ($l4protonum eq '41') {
+                       $l4proto = 'IPv6 Encap';
+               } elsif ($l4protonum eq '50') {
+                       $l4proto = 'ESP';
+               } elsif ($l4protonum eq '51') {
+                       $l4proto = 'AH';
+               } elsif ($l4protonum eq '132') {
+                       $l4proto = 'SCTP';
+               } else {
+                       $l4proto = $l4protonum;
+               }
+       } else {
+               $l4proto = uc($l4proto);
        }
-    }
 
-    my $dserv = '';
-    if ($dport < 1024) {
-       $dserv = uc(getservbyport($dport, lc($proto)));
-       if ($dserv ne '') {
-           $dserv = "&nbsp;($dserv)";
+       # Source and destination.
+       my $sip;
+       my $dip;
+       my $sport;
+       my $dport;
+       my @packets;
+       my @bytes;
+
+       my $ttl = $conn[4];
+       my $state;
+       if ($l4proto eq 'TCP') {
+               $state = $conn[5];
        }
-    }
-
-    print <<END
-    <tr >
-      <td align='center' bgcolor='$sipcol'>
-        <a href='/cgi-bin/ipinfo.cgi?ip=$sip'>
-          <font color='#FFFFFF'>$sip</font>
-        </a>
-      </td>
-      <td align='center' bgcolor='$sipcol'>
-        <a href='http://isc.sans.org/port_details.php?port=$sport' target='top'>
-          <font color='#FFFFFF'>$sport$sserv</font>
-        </a>
-      </td>
-      <td align='center' bgcolor='$dipcol'>
-        <a href='/cgi-bin/ipinfo.cgi?ip=$dip'>
-          <font color='#FFFFFF'>$dip</font>
-        </a>
-      </td>
-      <td align='center' bgcolor='$dipcol'>
-        <a href='http://isc.sans.org/port_details.php?port=$dport' target='top'>
-          <font color='#FFFFFF'>$dport$dserv</font>
-        </a>
-      </td>
-      <td align='center'>$proto</td>
-      <td align='center'>$state</td>
-      <td align='center'>$ttl</td>
-    </tr>
+
+       # Kick out everything that is not IPv4.
+       foreach my $item (@conn) {
+               my ($key, $val) = split('=', $item);
+
+               switch ($key) {
+                       case "src" {
+                               $sip = $val;
+                       }
+                       case "dst" {
+                               $dip = $val;
+                       }
+                       case "sport" {
+                               $sport = $val;
+                       }
+                       case "dport" {
+                               $dport = $val;
+                       }
+                       case "packets" {
+                               push(@packets, $val);
+                       }
+                       case "bytes" {
+                               push(@bytes, $val);
+                       }
+               }
+       }
+
+       my $sip_colour = ipcolour($sip);
+       my $dip_colour = ipcolour($dip);
+
+       my $sserv = '';
+       if ($sport < 1024) {
+               $sserv = uc(getservbyport($sport, lc($l4proto)));
+               if ($sserv ne '') {
+                       $sserv = "&nbsp;($sserv)";
+               }
+       }
+
+       my $dserv = '';
+       if ($dport < 1024) {
+               $dserv = uc(getservbyport($dport, lc($l4proto)));
+               if ($dserv ne '') {
+                       $dserv = "&nbsp;($dserv)";
+               }
+       }
+
+       my $bytes_in = format_bytes($bytes[0]);
+       my $bytes_out = format_bytes($bytes[1]);
+
+       # Format TTL
+       $ttl = format_time($ttl);
+
+       print <<END;
+       <tr>
+               <td align='center'>$l4proto</td>
+               <td align='center' bgcolor='$sip_colour'>
+                       <a href='/cgi-bin/ipinfo.cgi?ip=$sip'>
+                               <font color='#FFFFFF'>$sip</font>
+                       </a>
+               </td>
+               <td align='center' bgcolor='$sip_colour'>
+                       <a href='http://isc.sans.org/port_details.php?port=$sport' target='top'>
+                               <font color='#FFFFFF'>$sport$sserv</font>
+                       </a>
+               </td>
+               <td align='center' bgcolor='$dip_colour'>
+                       <a href='/cgi-bin/ipinfo.cgi?ip=$dip'>
+                               <font color='#FFFFFF'>$dip</font>
+                       </a>
+               </td>
+               <td align='center' bgcolor='$dip_colour'>
+                       <a href='http://isc.sans.org/port_details.php?port=$dport' target='top'>
+                               <font color='#FFFFFF'>$dport$dserv</font>
+                       </a>
+               </td>
+               <td align='center'>
+                       $bytes_in / $bytes_out
+               </td>
+               <td align='center'>$state</td>
+               <td align='center'>$ttl</td>
+       </tr>
 END
-;
 }
 
-print "</table></form>";
+# Close the main table.
+print "</table>";
 
 &Header::closebox();
 &Header::closebigbox();
 &Header::closepage();
 
-sub ipcolour($) {
-        my $id = 0;
-        my $line;
-        my $colour = ${Header::colourred};
-        my ($ip) = $_[0];
-        my $found = 0;
-        foreach $line (@network) {
-                                       if ($network[$id] eq '') {
-                                               $id++;
-                                       } else {
-                                               if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) ) {
-                                                       $found = 1;
-                                                       $colour = $colour[$id];
-                                               }
-                                               $id++;
-                                       }
-        }
-        return $colour
-}
+sub format_bytes($) {
+       my $bytes = shift;
+       my @units = ("B", "k", "M", "G", "T");
+
+       foreach my $unit (@units) {
+               if ($bytes < 1024) {
+                       return sprintf("%d%s", $bytes, $unit);
+               }
 
-# Create a string containing a complete SELECT html object 
-# param1: name
-# param2: current value selected
-# param3: field list
-sub make_select ($,$,$) {
-        my $select_name = shift;
-        my $selected    = shift;
-        my $select = "<select name='$select_name'>";
-
-        foreach my $value (@_) {
-                    my $check = $selected eq $value ? "selected='selected'" : '';
-                    $select .= "<option $check value='$value'>$value</option>";
-        }
-        $select .= "</select>";
-        return $select;
+               $bytes /= 1024;
+       }
+
+       return sprintf("%d%s", $bytes, $units[$#units]);
 }
 
-# Build a list of IP obtained from the %entries hash
-# param1: IP field name
-sub get_known_ips ($) {
-        my $field = shift;
-        my $qs = $cgiparams{'SEE_SORT'};       # switch the sort order
-        $cgiparams{'SEE_SORT'} = $field;
+sub format_time($) {
+       my $time = shift;
 
-        my @liste=('*.*.*.*');
-        foreach my $entry ( sort sort_entries keys %entries) {
-                    push (@liste, $entries{$entry}->{$field}) if (! grep (/^$entries{$entry}->{$field}$/,@liste) );
-        }
+       my $seconds = $time % 60;
+       my $minutes = $time / 60;
 
-        $cgiparams{'SEE_SORT'} = $qs;  #restore sort order
-        return @liste;
+       my $hours = 0;
+       if ($minutes >= 60) {
+               $hours = $minutes / 60;
+               $minutes %= 60;
+       }
+
+       return sprintf("%3d:%02d:%02d", $hours, $minutes, $seconds);
 }
 
-# Used to sort the table containing the lines displayed.
-sub sort_entries { #Reverse is not implemented
-        my $qs=$cgiparams{'SEE_SORT'};
-        if ($qs =~ /orgsip|orgdip|exsip|exdip/) {
-                my @a = split(/\./,$entries{$a}->{$qs});
-                my @b = split(/\./,$entries{$b}->{$qs});
-                ($a[0]<=>$b[0]) ||
-                ($a[1]<=>$b[1]) ||
-                ($a[2]<=>$b[2]) ||
-                ($a[3]<=>$b[3]);
-        } elsif ($qs =~ /expire|orgsp|orgdp|exsp|exdp/) {
-                    $entries{$a}->{$qs} <=> $entries{$b}->{$qs};
-        } else {
-                    $entries{$a}->{$qs} cmp $entries{$b}->{$qs};
-        }
+sub ipcolour($) {
+       my $id = 0;
+       my $colour = ${Header::colourred};
+       my ($ip) = $_[0];
+       my $found = 0;
+
+       foreach my $line (@network) {
+               if ($network[$id] eq '') {
+                       $id++;
+               } else {
+                       if (!$found && ipv4_in_network($network[$id], $masklen[$id], $ip) ) {
+                               $found = 1;
+                               $colour = $colour[$id];
+                       }
+                       $id++;
+               }
+       }
+
+       return $colour;
 }
 
 1;
index 7375afdb8471576b0677c86453c1b23e52511b6b..75e59b18d66be403ae59721690a22257c2ad9b2b 100644 (file)
@@ -35,6 +35,24 @@ require "${General::swroot}/header.pl";
 
 &Header::openbigbox('100%', 'center');
 
+&Header::openbox('100%', 'left', $Lang::tr{'donation'});
+
+print <<END
+<p>$Lang::tr{'donation-text'}</p>
+       <div align="center">
+               <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+                       <input type="hidden" name="cmd" value="_s-xclick">
+                       <input type="hidden" name="hosted_button_id" value="10781833">
+                       <input type="image" src=$Lang::tr{'donation-link'} border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
+                       <img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1">
+               </form>
+       </div>
+<br />
+
+END
+;
+&Header::closebox();
+
 &Header::openbox('100%', 'left', $Lang::tr{'credits'});
 
 print <<END
index 01bb3d6850c13f25f5de12f6f8c94b348ed69353..04a87cf63087e4f65236099bc9c93fd5b2a82c2e 100644 (file)
@@ -394,48 +394,52 @@ END
        }
 
 ###
-# m.a.d n2n
+# Print the OpenVPN N2N connection status.
 ###
-
 if ( -d "${General::swroot}/ovpn/n2nconf") {
-my %confighash=();
-my $display = '';
-
-&General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
-foreach my $dkey (keys %confighash) {
-if ($confighash{$dkey}[3] eq 'net') {
-
-
-          if (-e "/var/run/$confighash{$dkey}[1]n2n.pid") {
-          my @output = "";
-          my @tustate = "";
-          my $tport = $confighash{$dkey}[22];
-          my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); 
-          if ($tport ne '') {
-          $tnet->open('127.0.0.1');
-          @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
-          @tustate = split(/\,/, $output[1]);
-         if ( $tustate[1] eq 'CONNECTED')
-          { $display = "<font color=$Header::colourgreen>$Lang::tr{'capsopen'}</font>";
-          } else {
-          $display = "<font color=$Header::colourred>$tustate[1]</font>"; }
+       my %confighash=();
+
+       &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
+       foreach my $dkey (keys %confighash) {
+               if (($confighash{$dkey}[3] eq 'net') && (-e "/var/run/$confighash{$dkey}[1]n2n.pid")) {
+                       my $tport = $confighash{$dkey}[22];
+                       next if ($tport eq '');
+
+                       my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); 
+                       $tnet->open('127.0.0.1');
+                       my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
+                       my @tustate = split(/\,/, $output[1]);
+
+                       my $display;
+                       my $display_colour = $Header::colourred;
+                       if ( $tustate[1] eq 'CONNECTED') {
+                               $display_colour = $Header::colourgreen;
+                               $display = $Lang::tr{'capsopen'};
+                       } else {
+                               $display = $tustate[1];
+                       }
  
-       print <<END;
-       <tr><td align='center' bgcolor='$Header::colourovpn' width='25%'><a href="/cgi-bin/ovpnmain.cgi"><font size='2' color='white'><b>OpenVPN n2n</b></font></a><br>
-  <td width='30%' align='center'> $confighash{$dkey}[10]<td width='45%' align='center'> $display 
-
+                       print <<END;
+                       <tr>
+                               <td align='left' nowrap='nowrap' bgcolor='$color{'color22'}'>
+                                       $confighash{$dkey}[1]
+                               </td>
+                               <td align='center'>
+                                       $confighash{$dkey}[11]
+                               </td>
+                               <td align='center' bgcolor='$display_colour'>
+                                       <b>
+                                               <font color='#FFFFFF'>
+                                                       $display
+                                               </font>
+                                       </b>
+                               </td>
+                       </tr>
 END
-;
-}
-}
-}
-}
+               }
+       }
 }
 
-###
-# m.a.d n2n end
-###
-
 # Fireinfo
 if ( ! -e "/var/ipfire/main/send_profile") {
        $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>";
index 92bab473243cac4b8d2f7fa392e6389741e54df9..f91adf1f4a48a9702844d93befb0201944e1e96b 100644 (file)
@@ -356,11 +356,14 @@ sub writeserverconf {
     if ($sovpnsettings{CLIENT2CLIENT} eq 'on') {
        print CONF "client-to-client\n";
     }
-    if ($sovpnsettings{MSSFIX} eq 'on') {
-       print CONF "mssfix\n";
-    }
-    if (($sovpnsettings{FRAGMENT} ne '' && $sovpnsettings{FRAGMENT} ne 0) && $sovpnsettings{'DPROTOCOL'} ne 'tcp') {
-       print CONF "fragment $sovpnsettings{'FRAGMENT'}\n";
+    if ($sovpnsettings{'DPROTOCOL'} eq 'udp') {
+        if ($sovpnsettings{MSSFIX} eq 'on') {
+           print CONF "mssfix\n";
+        }
+        if ($sovpnsettings{'FRAGMENT'} eq '' || $sovpnsettings{'FRAGMENT'} eq 0) {
+               $sovpnsettings{'FRAGMENT'} = '1300';
+        }
+        print CONF "fragment $sovpnsettings{'FRAGMENT'}\n";
     }
     if ($sovpnsettings{KEEPALIVE_1} > 0 && $sovpnsettings{KEEPALIVE_2} > 0) {  
        print CONF "keepalive $sovpnsettings{'KEEPALIVE_1'} $sovpnsettings{'KEEPALIVE_2'}\n";
@@ -529,7 +532,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save-adv-options'}) {
        }
     }
     if ($cgiparams{'MSSFIX'} ne 'on') {
-       delete $vpnsettings{'MSSFIX'};
+       $vpnsettings{'MSSFIX'} = 'off';
     } else {
        $vpnsettings{'MSSFIX'} = $cgiparams{'MSSFIX'};
     }
@@ -1894,7 +1897,6 @@ ADV_ERROR:
     if ($cgiparams{'MAX_CLIENTS'} eq '') {
        $cgiparams{'MAX_CLIENTS'} =  '100';     
     }
-    
     if ($cgiparams{'KEEPALIVE_1'} eq '') {
        $cgiparams{'KEEPALIVE_1'} =  '10';     
     }
@@ -1902,7 +1904,13 @@ ADV_ERROR:
        $cgiparams{'KEEPALIVE_2'} =  '60';     
     }
     if ($cgiparams{'LOG_VERB'} eq '') {
-       $cgiparams{'LOG_VERB'} =  '3';     
+       $cgiparams{'LOG_VERB'} =  '3';
+    }
+    if ($cgiparams{'MSSFIX'} eq '') {
+        $cgiparams{'MSSFIX'} = 'on';
+    }
+    if ($cgiparams{'FRAGMENT'} eq '') {
+        $cgiparams{'FRAGMENT'} = '1300';
     }
     $checked{'CLIENT2CLIENT'}{'off'} = '';
     $checked{'CLIENT2CLIENT'}{'on'} = '';
old mode 100644 (file)
new mode 100755 (executable)
index 8c9574c..015502a
@@ -353,6 +353,13 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'}
                $errormessage = $Lang::tr{'advproxy errmsg invalid proxy port'};
                goto ERROR;
        }
+       if (!($proxysettings{'UPSTREAM_PROXY'} eq '')) {
+         my @temp = split(/:/,$proxysettings{'UPSTREAM_PROXY'});
+         if (!(&General::validip($temp[0]))) {
+           $errormessage = $Lang::tr{'advproxy errmsg invalid upstream proxy'};
+           goto ERROR;
+          }
+        }
        if (!($proxysettings{'CACHE_SIZE'} =~ /^\d+/) ||
                ($proxysettings{'CACHE_SIZE'} < 10))
        {
@@ -984,7 +991,7 @@ print <<END
 <tr><td class='base' >$Lang::tr{'processes'}<input type='text' name='CHILDREN' value='$proxysettings{'CHILDREN'}' size='5' /></td>
 END
 ;
-my $count = `arp -a | wc -l`;
+my $count = `ip n| wc -l`;
 if ( $count < 1 ){$count = 1;}
 if ( -e "/usr/bin/squidclamav" ) {
        print "<td class='base'><b>".$Lang::tr{'advproxy squidclamav'}."</b><br />";
@@ -3013,7 +3020,7 @@ sub writeconfig
        }
 
        $_ = $proxysettings{'UPSTREAM_PROXY'};
-       my ($remotehost, $remoteport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
+        my ($remotehost, $remoteport) = split(/:/,$_);
 
        if ($remoteport eq '') { $remoteport = 80; }
 
@@ -3923,6 +3930,11 @@ END
                print FILE "url_rewrite_program /usr/sbin/redirect_wrapper\n";
                print FILE "url_rewrite_children $proxysettings{'CHILDREN'}\n\n";
        }
+
+       # Include file with user defined settings.
+       if (-e "/etc/squid/squid.conf.local") {
+               print FILE "include /etc/squid/squid.conf.local\n";
+       }
        close FILE;
 }
 
index 58d0a1dbcf23e31a432417a32c325585bbbddd19..22a9ac707cce13d072c261398fae6c9ed8a25234 100644 (file)
@@ -240,7 +240,7 @@ sub isrunning{
        my $pid = '';
        my $testcmd = '';
        my $exename;
-       my @memory;
+       my $memory;
 
        $cmd =~ /(^[a-z]+)/;
        $exename = $1;
@@ -256,13 +256,18 @@ sub isrunning{
                        }
                        close FILE;
                }
-               if (open(FILE, "/proc/${pid}/statm")){
-                               my $temp = <FILE>;
-                               @memory = split(/ /,$temp);
+               if (open(FILE, "/proc/${pid}/status")) {
+                       while (<FILE>) {
+                               my ($key, $val) = split(":", $_, 2);
+                               if ($key eq 'VmRSS') {
+                                       $memory = $val;
+                                       last;
+                               }
+                       }
+                       close(FILE);
                }
-               close FILE;
                if ($testcmd =~ /$exename/){
-                       $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td><td align='center'>$pid</td><td align='center'>$memory[0] KB</td>";
+                       $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td><td align='center'>$pid</td><td align='center'>$memory</td>";
                }
        }
        return $status;
index c7f254ae64ee87fd35c4a0dc615311e8ea658ece..3ec57ebb99b841b4f5ece52de198550ea96e3e87 100644 (file)
 'advproxy errmsg invalid pdc' => 'Ungültiger Hostname für den Primary Domain Controller',
 'advproxy errmsg invalid proxy port' => 'Ungültiger Proxy-Port',
 'advproxy errmsg invalid upstream proxy username or password setting' => 'Ungültiger Benutzername oder ungültiges Kennwort für Upstream Proxy',
+'advproxy errmsg invalid upstream proxy' => 'Ungültige IP für Upstream-Proxy',
 'advproxy errmsg invalid user' => 'Benutzername existiert nicht',
 'advproxy errmsg ldap base dn' => 'LDAP base DN erforderlich',
 'advproxy errmsg ldap bind dn' => 'LDAP bind DN Benutzername und Passwort erforderlich',
index 52872f49ac9d6c9a9dd21060ad959260fab1dc83..003056f9ee5a04aa624d214974dfcf9f36f478ca 100644 (file)
 'advproxy errmsg invalid pdc' => 'Invalid hostname for primary domain controller',
 'advproxy errmsg invalid proxy port' => 'Invalid proxy port',
 'advproxy errmsg invalid upstream proxy username or password setting' => 'Invalid upstream proxy username or password setting',
+'advproxy errmsg invalid upstream proxy' => 'Invalid upstream proxy IP',
 'advproxy errmsg invalid user' => 'Username does not exist',
 'advproxy errmsg ldap base dn' => 'LDAP base DN required',
 'advproxy errmsg ldap bind dn' => 'LDAP bind DN username and password required',
index 9f1e3f0006d16b3dac3ac93e8bc95af8fbd2c191..300e9ecbb244caabd7fb447a82259b92d764d6e8 100644 (file)
@@ -32,7 +32,8 @@ SUID_PROGS = setdmzholes setportfw setxtaccess \
        wirelessctrl getipstat getiptstate qosctrl launch-ether-wake \
        redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \
        smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \
-       setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes
+       setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes \
+       getconntracktable
 SUID_UPDX = updxsetperms
 
 install : all
@@ -160,3 +161,6 @@ fireinfoctrl: fireinfoctrl.c setuid.o ../install+setup/libsmooth/varval.o
 
 rebuildroutes: rebuildroutes.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ rebuildroutes.c setuid.o ../install+setup/libsmooth/varval.o -o $@
+
+getconntracktable: getconntracktable.c setuid.o ../install+setup/libsmooth/varval.o
+       $(COMPILE) -I../install+setup/libsmooth/ getconntracktable.c setuid.o ../install+setup/libsmooth/varval.o -o $@
diff --git a/src/misc-progs/getconntracktable.c b/src/misc-progs/getconntracktable.c
new file mode 100644 (file)
index 0000000..674b211
--- /dev/null
@@ -0,0 +1,31 @@
+/* IPFire helper program - getconntracktable\r
+ *\r
+ * This program is distributed under the terms of the GNU General Public\r
+ * Licence.  See the file COPYING for details.\r
+ *\r
+ * The kernel's connection tracking table is not readable by\r
+ * non-root users. So this helper will just read and output it.\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include "setuid.h"\r
+\r
+int main(void) {\r
+       if (!(initsetuid()))\r
+               exit(1);\r
+\r
+       FILE *fp = fopen("/proc/net/nf_conntrack", "r");\r
+       if (fp == NULL) {\r
+               exit(1);\r
+       }\r
+\r
+       /* Read content line by line and write it to stdout. */\r
+       char linebuf[STRING_SIZE];\r
+       while (fgets(linebuf, STRING_SIZE, fp)) {\r
+               printf("%s", linebuf);\r
+       }\r
+\r
+       fclose(fp);\r
+       return 0;\r
+}\r