]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/remote.cgi
remote.cgi: Fix splitting output from ssh-keygen.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / remote.cgi
index 31e4f40854486a99000ea90d3ade312b9c74517b..2bb85851d2891883d388facd033a90f41403741d 100644 (file)
@@ -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,7 +65,7 @@ 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
        {
@@ -85,8 +85,8 @@ if ( (($remotesettings{'ACTION'} eq $Lang::tr{'save'}) || ($remotesettings{'ACTI
 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;}
@@ -185,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>
@@ -213,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">
@@ -254,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";
@@ -264,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;
@@ -273,7 +275,7 @@ 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...
@@ -295,7 +297,7 @@ sub printactivelogins()
                        my $rdns = gethostbyaddr($iaddr, AF_INET);
                        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'>