]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/remote.cgi
Early spring clean: Remove trailing whitespaces, and correct licence headers
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / remote.cgi
index 1b3dfed70a881dd3a358327a0666c9945e549d78..38f7599d74255c9d24dbcca6e1b5bd3525bae3d0 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2014  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2020  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        #
@@ -28,7 +28,7 @@ use strict;
 use IO::Socket;
 
 require '/var/ipfire/general-functions.pl';
-require "${General::swroot}/geoip-functions.pl";
+require "${General::swroot}/location-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
@@ -40,7 +40,7 @@ my $errormessage='';
 my $counter = 0;
 
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 &Header::showhttpheaders();
 
@@ -65,14 +65,14 @@ if ( (($remotesettings{'ACTION'} eq $Lang::tr{'save'}) || ($remotesettings{'ACTI
                {
                        $errormessage = $Lang::tr{'ssh no auth'};
                }
-               system ('/usr/bin/touch', "${General::swroot}/remote/enablessh");
+               &General::system('/usr/bin/touch', "${General::swroot}/remote/enablessh");
        }
        else
        {
                &General::log($Lang::tr{'ssh is disabled'});
                unlink "${General::swroot}/remote/enablessh";
        }
-       
+
        if ($remotesettings{'SSH_PORT'} eq 'on')
        {
                &General::log("SSH Port 22");
@@ -81,16 +81,16 @@ if ( (($remotesettings{'ACTION'} eq $Lang::tr{'save'}) || ($remotesettings{'ACTI
        {
                &General::log("SSH Port 222");
        }
-       
+
 if ( $remotesettings{'ACTION'} eq $Lang::tr{'ssh tempstart15'} || $remotesettings{'ACTION'} eq $Lang::tr{'ssh tempstart30'} ){
        if ($remotesettings{'ENABLE_SSH'} eq 'off')
        {
-                       system ('/usr/bin/touch', "${General::swroot}/remote/enablessh");
-                       system('/usr/local/bin/sshctrl');
+                       &General::system('/usr/bin/touch', "${General::swroot}/remote/enablessh");
+                       &General::system('/usr/local/bin/sshctrl');
        }
   if ( $remotesettings{'ACTION'} eq $Lang::tr{'ssh tempstart15'} ) { $counter = 900;}
   elsif ( $remotesettings{'ACTION'} eq $Lang::tr{'ssh tempstart30'} ) { $counter = 1800;}
+
   system("/usr/local/bin/sshctrl tempstart $counter >/dev/null");
  }
 else {
@@ -105,6 +105,7 @@ else {
 # used
        $remotesettings{'ENABLE_SSH_PASSWORDS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_PASSWORDS'};
        $remotesettings{'ENABLE_SSH_KEYS'} = 'on' unless exists $remotesettings{'ENABLE_SSH_KEYS'};
+       $remotesettings{'SSH_AGENT_FORWARDING'} = 'off' unless exists $remotesettings{'SSH_AGENT_FORWARDING'};
 
 $checked{'ENABLE_SSH'}{'off'} = '';
 $checked{'ENABLE_SSH'}{'on'} = '';
@@ -121,6 +122,9 @@ $checked{'ENABLE_SSH_KEYS'}{$remotesettings{'ENABLE_SSH_KEYS'}} = "checked='chec
 $checked{'SSH_PORT'}{'off'} = '';
 $checked{'SSH_PORT'}{'on'} = '';
 $checked{'SSH_PORT'}{$remotesettings{'SSH_PORT'}} = "checked='checked'";
+$checked{'SSH_AGENT_FORWARDING'}{'off'} = '';
+$checked{'SSH_AGENT_FORWARDING'}{'on'} = '';
+$checked{'SSH_AGENT_FORWARDING'}{$remotesettings{'SSH_AGENT_FORWARDING'}} = "checked='checked'";
 
 &Header::openpage($Lang::tr{'remote access'}, 1, '');
 
@@ -141,6 +145,11 @@ print <<END
        <td><input type='checkbox' name='ENABLE_SSH' $checked{'ENABLE_SSH'}{'on'} /></td>
        <td class='base' colspan='2'>$Lang::tr{'ssh access'}</td>
 </tr>
+<tr>
+       <td>&nbsp;</td>
+       <td><input type='checkbox' name='SSH_AGENT_FORWARDING' $checked{'SSH_AGENT_FORWARDING'}{'on'} /></td>
+       <td width='100%' class='base'>$Lang::tr{'ssh agent forwarding'}</td>
+</tr>
 <tr>
        <td>&nbsp;</td>
        <td><input type='checkbox' name='ENABLE_SSH_PORTFW' $checked{'ENABLE_SSH_PORTFW'}{'on'} /></td>
@@ -176,7 +185,7 @@ print "</form>\n";
 
 &Header::openbox('100%', 'center', $Lang::tr{'ssh host keys'});
 
-print "<table class='tbl'>\n";
+print "<table class='tbl' width='100%'>\n";
 
 print <<END
 <thead>
@@ -204,7 +213,7 @@ print "</tbody>\n</table>\n";
 &Header::openbox('100%', 'center', $Lang::tr{'ssh active sessions'});
 
 print <<END;
-               <table class="tbl" width='66%'>
+               <table class="tbl" width="100%">
                        <thead>
                                <tr>
                                        <th align="center">
@@ -245,7 +254,10 @@ sub viewkey
 
   if ( -e $key )
   {
-    my @temp = split(/ /,`/usr/bin/ssh-keygen -l -f $key`);
+    # Use safe system_output function to call ssh-keygen and get the output from the tool.
+    my @ssh_keygen = &General::system_output("/usr/bin/ssh-keygen", "-l", "-f", "$key");
+
+    my @temp = split(/ /, $ssh_keygen[0]);
     my $keysize = &Header::cleanhtml($temp[0],"y");
     my $fingerprint = &Header::cleanhtml($temp[1],"y");
     print "<tr><td><code>$key</code></td><td align='center'>$name</td><td><code>$fingerprint</code></td><td align='center'>$keysize</td></tr>\n";
@@ -255,8 +267,7 @@ sub viewkey
 sub printactivelogins()
 {
        # print active SSH logins (grep outpout of "who -s")
-       my $command = "who -s";
-       my @output = `$command`;
+       my @output = &General::system_output("who", "-s");
        chomp(@output);
 
        my $id = 0;
@@ -264,11 +275,10 @@ sub printactivelogins()
        if ( scalar(@output) == 0 )
        {
                # no logins appeared
-               my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
+               my $table_colour = ($id++ % 2) ? $color{'color20'} : $color{'color22'};
                print "<tr bgcolor='$table_colour'><td colspan='5'>$Lang::tr{'ssh no active logins'}</td></tr>\n";
        } else {
                # list active logins...
-
                foreach my $line (@output)
                {
                        my @arry = split(/\ +/, $line);
@@ -279,15 +289,15 @@ sub printactivelogins()
                        $remoteip =~ s/[()]//g;
 
                        # display more information about that IP adress...
-                       my $ccode = &GeoIP::lookup($remoteip);
-                       my $flag_icon = &GeoIP::get_flag_icon($ccode);
+                       my $ccode = &Location::Functions::lookup_country_code($remoteip);
+                       my $flag_icon = &Location::Functions::get_flag_icon($ccode);
 
                        # get rDNS...
                        my $iaddr = inet_aton($remoteip);
                        my $rdns = gethostbyaddr($iaddr, AF_INET);
-                       if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; };
+                       if (!$rdns) { $rdns = $Lang::tr{'ptr lookup failed'}; };
 
-                       my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
+                       my $table_colour = ($id++ % 2) ? $color{'color20'} : $color{'color22'};
 
                        print <<END;
                        <tr bgcolor='$table_colour'>