mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-26 02:42:58 +02:00
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next-suricata
This commit is contained in:
@@ -24,6 +24,7 @@ use strict;
|
||||
#use warnings;
|
||||
#use CGI::Carp 'fatalsToBrowser';
|
||||
use File::Copy;
|
||||
use File::Basename;
|
||||
|
||||
require '/var/ipfire/general-functions.pl';
|
||||
require "${General::swroot}/lang.pl";
|
||||
@@ -58,44 +59,25 @@ system("/usr/local/bin/backupctrl makedirs >/dev/null 2>&1 ") unless ( -e '/var/
|
||||
############################################################################################################################
|
||||
############################################## System calls ohne Http Header ###############################################
|
||||
|
||||
# Replace slashes from filename
|
||||
$cgiparams{'FILE'} =~ s/\///;
|
||||
if ($cgiparams{'ACTION'} eq "download") {
|
||||
my $file = &sanitise_file($cgiparams{'FILE'});
|
||||
exit(1) unless defined($file);
|
||||
|
||||
if ( $cgiparams{'ACTION'} eq "download" )
|
||||
{
|
||||
open(DLFILE, "</var/ipfire/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/x-download\n";
|
||||
my @fileinfo = stat("/var/ipfire/backup/$cgiparams{'FILE'}");
|
||||
print "Content-Length:$fileinfo[7]\n";
|
||||
print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
|
||||
print @fileholder;
|
||||
exit (0);
|
||||
}
|
||||
if ( $cgiparams{'ACTION'} eq "downloadiso" )
|
||||
{
|
||||
open(DLFILE, "</var/tmp/backupiso/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/x-download\n";
|
||||
my @fileinfo = stat("/var/tmp/backupiso/$cgiparams{'FILE'}");
|
||||
print "Content-Length:$fileinfo[7]\n";
|
||||
print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
|
||||
print @fileholder;
|
||||
exit (0);
|
||||
}
|
||||
if ( $cgiparams{'ACTION'} eq "downloadaddon" )
|
||||
{
|
||||
open(DLFILE, "</var/ipfire/backup/addons/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
|
||||
my @fileholder = <DLFILE>;
|
||||
print "Content-Type:application/x-download\n";
|
||||
my @fileinfo = stat("/var/ipfire/backup/addons/backup/$cgiparams{'FILE'}");
|
||||
print "Content-Length:$fileinfo[7]\n";
|
||||
print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
|
||||
print @fileholder;
|
||||
exit (0);
|
||||
}
|
||||
elsif ( $cgiparams{'ACTION'} eq "restore" )
|
||||
{
|
||||
&deliver_file($file);
|
||||
exit(0);
|
||||
} elsif ($cgiparams{'ACTION'} eq "downloadiso") {
|
||||
my $file = &sanitise_file($cgiparams{'FILE'});
|
||||
exit(1) unless defined($file);
|
||||
|
||||
&deliver_file($file);
|
||||
exit(0);
|
||||
} elsif ($cgiparams{'ACTION'} eq "downloadaddon") {
|
||||
my $file = &sanitise_file($cgiparams{'FILE'});
|
||||
exit(1) unless defined($file);
|
||||
|
||||
&deliver_file($file);
|
||||
exit(0);
|
||||
} elsif ( $cgiparams{'ACTION'} eq "restore") {
|
||||
my $upload = $a->param("UPLOAD");
|
||||
open UPLOADFILE, ">/tmp/restore.ipf";
|
||||
binmode $upload;
|
||||
@@ -142,11 +124,20 @@ if ( $cgiparams{'ACTION'} eq "backup" )
|
||||
}
|
||||
if ( $cgiparams{'ACTION'} eq "addonbackup" )
|
||||
{
|
||||
# Exit if there is any dots or slashes in the addon name
|
||||
exit(1) if ($cgiparams{'ADDON'} =~ /(\.|\/)/);
|
||||
|
||||
# Check if the addon exists
|
||||
exit(1) unless (-e "/var/ipfire/backup/addons/includes/$cgiparams{'ADDON'}");
|
||||
|
||||
system("/usr/local/bin/backupctrl addonbackup $cgiparams{'ADDON'} >/dev/null 2>&1");
|
||||
}
|
||||
elsif ( $cgiparams{'ACTION'} eq "delete" )
|
||||
{
|
||||
system("/usr/local/bin/backupctrl $cgiparams{'FILE'} >/dev/null 2>&1");
|
||||
my $file = &sanitise_file($cgiparams{'FILE'});
|
||||
exit(1) unless defined($file);
|
||||
|
||||
system("/usr/local/bin/backupctrl $file >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
############################################################################################################################
|
||||
@@ -273,7 +264,7 @@ print <<END
|
||||
<td align='right' width='5'>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<input type='hidden' name='ACTION' value='delete' />
|
||||
<input type='hidden' name='FILE' value='addons//backup/$_.ipf' />
|
||||
<input type='hidden' name='FILE' value='$_.ipf' />
|
||||
<input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
|
||||
</form>
|
||||
</td>
|
||||
@@ -312,7 +303,7 @@ print <<END
|
||||
<td align='right' width='5'>
|
||||
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
|
||||
<input type='hidden' name='ACTION' value='delete' />
|
||||
<input type='hidden' name='FILE' value='addons//backup/$_.ipf' />
|
||||
<input type='hidden' name='FILE' value='$_.ipf' />
|
||||
<input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
|
||||
</form>
|
||||
</td>
|
||||
@@ -340,3 +331,41 @@ END
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
|
||||
sub sanitise_file() {
|
||||
my $file = shift;
|
||||
|
||||
# Filenames cannot contain any slashes
|
||||
return undef if ($file =~ /\//);
|
||||
|
||||
# File must end with .ipf or .iso
|
||||
return undef unless ($file =~ /\.(ipf|iso)$/);
|
||||
|
||||
# Convert to absolute path
|
||||
if (-e "/var/ipfire/backup/$file") {
|
||||
return "/var/ipfire/backup/$file";
|
||||
} elsif (-e "/var/ipfire/backup/addons/backup/$file") {
|
||||
return "/var/ipfire/backup/addons/backup/$file";
|
||||
} elsif (-e "/var/tmp/backupiso/$file") {
|
||||
return "/var/tmp/backupiso/$file";
|
||||
}
|
||||
|
||||
# File does not seem to exist
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub deliver_file() {
|
||||
my $file = shift;
|
||||
my @stat = stat($file);
|
||||
|
||||
# Print headers
|
||||
print "Content-Disposition: attachment; filename=" . &File::Basename::basename($file) . "\n";
|
||||
print "Content-Type: application/octet-stream\n";
|
||||
print "Content-Length: $stat[7]\n";
|
||||
print "\n";
|
||||
|
||||
# Deliver content
|
||||
open(FILE, "<$file") or die "Unable to open $file: $!";
|
||||
print <FILE>;
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
@@ -1258,6 +1258,7 @@ if ($fwhostsettings{'ACTION'} eq 'changegrpname')
|
||||
}
|
||||
&General::writehasharray("$configgrp", \%customgrp );
|
||||
#change name in FW Rules
|
||||
&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},4);
|
||||
&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
|
||||
}
|
||||
}
|
||||
@@ -1282,6 +1283,7 @@ if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
|
||||
&General::writehasharray("$configgeoipgrp", \%customgeoipgrp );
|
||||
#change name in FW Rules
|
||||
&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},4,"geoip");
|
||||
&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6,"geoip");
|
||||
}
|
||||
}
|
||||
&addgeoipgrp;
|
||||
|
||||
@@ -465,6 +465,10 @@ END
|
||||
|
||||
my $activecolor = $Header::colourred;
|
||||
my $activestatus = $Lang::tr{'capsclosed'};
|
||||
if ($vpnconfig{$key}[33] eq "add") {
|
||||
$activecolor = ${Header::colourorange};
|
||||
$activestatus = $Lang::tr{'vpn wait'};
|
||||
}
|
||||
if ($vpnconfig{$key}[0] eq 'off') {
|
||||
$activecolor = $Header::colourblue;
|
||||
$activestatus = $Lang::tr{'capsclosed'};
|
||||
@@ -479,9 +483,6 @@ END
|
||||
} elsif ($line =~ /$vpnconfig{$key}[1]\{.*ROUTED/) {
|
||||
$activecolor = $Header::colourorange;
|
||||
$activestatus = $Lang::tr{'vpn on-demand'};
|
||||
} elsif ($vpnconfig{$key}[33] eq "add") {
|
||||
$activecolor = ${Header::colourorange};
|
||||
$activestatus = $Lang::tr{'vpn wait'};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ $pakfiresettings{'VALID'} = '';
|
||||
$pakfiresettings{'INSPAKS'} = '';
|
||||
$pakfiresettings{'DELPAKS'} = '';
|
||||
$pakfiresettings{'AUTOUPDATE'} = 'off';
|
||||
$pakfiresettings{'HEALTHCHECK'} = 'on';
|
||||
$pakfiresettings{'UUID'} = 'on';
|
||||
|
||||
sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();}
|
||||
@@ -163,9 +162,6 @@ my %checked=();
|
||||
$checked{'AUTOUPDATE'}{'off'} = '';
|
||||
$checked{'AUTOUPDATE'}{'on'} = '';
|
||||
$checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
|
||||
$checked{'HEALTHCHECK'}{'off'} = '';
|
||||
$checked{'HEALTHCHECK'}{'on'} = '';
|
||||
$checked{'HEALTHCHECK'}{$pakfiresettings{'HEALTHCHECK'}} = "checked='checked'";
|
||||
$checked{'UUID'}{'off'} = '';
|
||||
$checked{'UUID'}{'on'} = '';
|
||||
$checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
|
||||
@@ -292,13 +288,6 @@ print <<END;
|
||||
<tr><td align='left' width='45%'>$Lang::tr{'pakfire update daily'}</td><td width="55%" align="left">
|
||||
on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} /> |
|
||||
<input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr>
|
||||
<tr><td align='left' width='45%'>$Lang::tr{'pakfire health check'}</td><td align="left">
|
||||
on <input type='radio' name='HEALTHCHECK' value='on' $checked{'HEALTHCHECK'}{'on'} /> |
|
||||
<input type='radio' name='HEALTHCHECK' value='off' $checked{'HEALTHCHECK'}{'off'} /> off </td></tr>
|
||||
<tr><td align='left' width='45%'>$Lang::tr{'pakfire register'}</td><td align="left">
|
||||
on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} /> |
|
||||
<input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr>
|
||||
<tr><td colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
END
|
||||
|
||||
@@ -2844,8 +2844,11 @@ END
|
||||
}
|
||||
print "<td align='center' $col>$confighash{$key}[25]</td>";
|
||||
my $col1="bgcolor='${Header::colourred}'";
|
||||
# get real state
|
||||
my $active = "<b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b>";
|
||||
if ($confighash{$key}[33] eq "add") {
|
||||
$col1="bgcolor='${Header::colourorange}'";
|
||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'vpn wait'}</font></b>";
|
||||
}
|
||||
foreach my $line (@status) {
|
||||
if (($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) ||
|
||||
($line =~ /$confighash{$key}[1]\{.*INSTALLED/)) {
|
||||
@@ -2857,9 +2860,6 @@ END
|
||||
} elsif ($line =~ /$confighash{$key}[1]\{.*ROUTED/) {
|
||||
$col1="bgcolor='${Header::colourorange}'";
|
||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'vpn on-demand'}</font></b>";
|
||||
} elsif ($confighash{$key}[33] eq "add") {
|
||||
$col1="bgcolor='${Header::colourorange}'";
|
||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'vpn wait'}</font></b>";
|
||||
}
|
||||
}
|
||||
# move to blue if really down
|
||||
|
||||
Reference in New Issue
Block a user