]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
kleine Korrektur in der Samba CGI
authormaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 11 Jul 2007 20:30:21 +0000 (20:30 +0000)
committermaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 11 Jul 2007 20:30:21 +0000 (20:30 +0000)
IPFire Backup Loesung weiter gebaut
kleiner fix im dhcp init Skript

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@676 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

config/backup/backup.pl
config/backup/exclude
config/backup/include
html/cgi-bin/backup.cgi
html/cgi-bin/samba.cgi
src/initscripts/init.d/dhcp
src/misc-progs/Makefile
src/misc-progs/backupctrl.c [new file with mode: 0644]

index ae9fec08acaf4fcf5981b3b9f23976a93afdbda6..f0ae002c4423531510957bc46195ad9587587303 100644 (file)
@@ -14,23 +14,48 @@ $Stunden = sprintf("%02d", $Stunden);
 $Minuten = sprintf("%02d", $Minuten);
 
 if ($ARGV[0] eq 'include') {
+  &createinclude;
+    my @files = `find / -name *.log`;
+    foreach (@files){
+      push(@include,$_);
+     }
+  open(DATEI, ">/tmp/include") || die "Could not save temp include file";
+  print DATEI @include;
+  close(DATEI);
+  system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf  --files-from=/tmp/include --exclude-from=/var/ipfire/backup/exclude");
+  system("rm /tmp/include");
+}
+
+if ($ARGV[0] eq 'exclude') {
   &createinclude;
   open(DATEI, ">/tmp/include") || die "Could not save temp include file";
   print DATEI @include;
   close(DATEI);
-  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf  --files-from=/tmp/include --exclude-from=/var/ipfire/backup/exclude");
+  system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'");
   system("rm /tmp/include");
 }
 
+if ($ARGV[0] eq 'restore') {
+  system("tar -xvz --preserve -f /tmp/restore.ipf");
+}
+
 if ($ARGV[0] eq 'exclude') {
   &createinclude;
   open(DATEI, ">/tmp/include") || die "Could not save temp include file";
   print DATEI @include;
   close(DATEI);
-  system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'");
+  system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'");
   system("rm /tmp/include");
 }
 
+if ($ARGV[0] eq 'cli') {
+  system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten-$ARGV[1].ipf --files-from='$ARGV[2]' --exclude-from='$ARGV[3]'");
+}
+
+if ($ARGV[0] eq '') {
+ printf "No argument given, please use <include><exclude>\n"
+}
+
 sub createinclude(){
 
   open(DATEI, "<${General::swroot}/backup/include") || die "Can not open include file";
@@ -42,8 +67,8 @@ sub createinclude(){
     my @files = `ls $_`;
     foreach (@files){
       push(@include,$_);
-      }
-    }
+     }
+   }
   else {push(@include,$_);}
   }
 }
index 1944fd61e7c53bcc19e6f3eb94cc800508944a25..4c8c09b7f9fe214812786bd3e0a1b88c2c7fd688 100644 (file)
@@ -1 +1,2 @@
 *.tmp
+/var/ipfire/ethernet/settings
index 49fce8f20e8dd070f24bcc232fbfddd2dbae8620..802ebc25c446e42b50616ff837b3014aaa7d8432 100644 (file)
@@ -1,3 +1,7 @@
 /var/ipfire/*/settings
 /var/ipfire/*/*.conf
 /var/ipfire/*/*.pem
+/etc/passwd
+/etc/shadow
+/etc/group
+
index 372d9080c5f18281b8a2f6d8ba9172b7992f6e9b..fbc96271b984db3b5c0d18b10dbd647d719bbc03 100644 (file)
@@ -10,6 +10,7 @@ use strict;
 # enable only the following on debugging purpose
 use warnings;
 use CGI::Carp 'fatalsToBrowser';
+use File::Copy;
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -17,45 +18,74 @@ require "${General::swroot}/header.pl";
 
 my %color = ();
 my %mainsettings = ();
-my %backupsettings = ();
+my %cgiparams=();
 my %checked = ();
 my $message = "";
 my $errormessage = "";
-my @backups = `cd /var/ipfire/backup/ && ls *.ipf`;
+my @backups = `cd /srv/web/ipfire/html/backup && ls *.ipf`;
 
+$a = new CGI;
 
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
 
-&Header::showhttpheaders();
-&Header::getcgihash(\%backupsettings);
-
-&Header::openpage($Lang::tr{'backup'}, 1, "");
-&Header::openbigbox('100%', 'left', '', $errormessage);
+$cgiparams{'ACTION'} = '';
+$cgiparams{'FILE'} = '';
+$cgiparams{'UPLOAD'} = '';
+$cgiparams{'BACKUPLOGS'} = '';
+&Header::getcgihash(\%cgiparams);
 
 ############################################################################################################################
 ######################################## Scanne Verzeichnisse nach Mp3 Dateien #############################################
 
-if ( $backupsettings{'ACTION'} eq "backup" )
+if ( $cgiparams{'ACTION'} eq "backup" )
 {
- if ( $backupsettings{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include");}
+ if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include");}
  else {system("/usr/local/bin/backupctrl exclude");}
 }
+elsif ( $cgiparams{'ACTION'} eq "download" )
+{
+    open(DLFILE, "</srv/web/ipfire/html/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
+    my @fileholder = <DLFILE>;
+    print "Content-Type:application/x-download\n";
+    print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
+    print @fileholder;
+    exit (0);
+}
+elsif ( $cgiparams{'ACTION'} eq "restore" )
+{
+  my $upload = $a->param("UPLOAD");
+  open UPLOADFILE, ">/tmp/restore.ipf";
+  binmode $upload;
+  while ( <$upload> ) {
+  print UPLOADFILE;
+  }
+  close UPLOADFILE;
+  system("/usr/local/bin/backupctrl restore");
+}
 
 ############################################################################################################################
 ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค
 
-if ( $message ne "" )  {       print "<font color='red'>$message</font>"; }
+&Header::showhttpheaders();
+&Header::openpage($Lang::tr{'backup'}, 1, "");
+&Header::openbigbox('100%', 'left', '', $errormessage);
+
+if ( $message ne "" ){
+       &Header::openbox('100%','left',$Lang::tr{'error messages'});
+       print "<font color='red'>$message</font>\n";
+       &Header::closebox();
+}
 
 &Header::openbox('100%', 'center', $Lang::tr{'backup'});
 
 print <<END
 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='95%' cellspacing='0'>
-<tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles <input type='radio' name='BACKUPLOGS' value='include' checked='checked'/>/
-                                                                                                                                                                                                                                              <input type='radio' name='BACKUPLOGS' value='exclude'/> exclude Logfiles</td></tr>
+<tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles <input type='radio' name='BACKUPLOGS' value='include'/>/
+                                                                                                                                                                                                                                              <input type='radio' name='BACKUPLOGS' value='exclude' checked='checked'/> exclude Logfiles</td></tr>
 <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='backup' />
-                              <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/edit-find.png' /></td></tr>                                                                                                                                                               
+                              <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/document-save.png' /></td></tr>
 </table>
 </form>
 END
@@ -65,16 +95,29 @@ END
 &Header::openbox('100%', 'center', $Lang::tr{'backups'});
 
 print <<END
-<form method='post' action='$ENV{'SCRIPT_NAME'}'>
 <table width='95%' cellspacing='0'>
 END
 ;
 foreach (@backups){
-print "<tr><td align='left' width='40%'>$Lang::tr{'backup from'}</td><td align='left'>$_</td></tr>";
+chomp($_);
+my $Datei = "/srv/web/ipfire/html/backup/".$_;
+my @Info = stat($Datei);
+my $Size = $Info[7] / 1024;
+$Size = sprintf("%02d", $Size);
+print "<tr><td align='left'><form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB <input type='hidden' name='ACTION' value='download' /><input type='hidden' name='FILE' value='$_' /><input type='image' src='/images/package-x-generic.png' /></form></td></tr>";
 }
 print <<END                                                                                                    
 </table>
-</form>
+END
+;
+&Header::closebox();
+
+&Header::openbox('100%', 'center', $Lang::tr{'restore'});
+
+print <<END
+<table width='95%' cellspacing='0'>
+<tr><td align='left'><form method='post' enctype='multipart/form-data' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'backup'}</td><td align='left'><input type="file" size='50' name="UPLOAD" /><input type='submit' name='ACTION' value='restore' /></form></td></tr>
+</table>
 END
 ;
 &Header::closebox();
index 6c52a8457907072054eec17e60ad9d90f2b0823e..0d506dea65403b0dabb486bb06454b17f413c93c 100644 (file)
@@ -205,7 +205,7 @@ $sambasettings{'INTERFACES'} = '';
 if ($sambasettings{'GREEN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'GREEN_DEV'}";}
 if ($sambasettings{'BLUE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'BLUE_DEV'}";}
 if ($sambasettings{'ORANGE'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $netsettings{'ORANGE_DEV'}";}
-if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DDEVICE'}";}
+if ($sambasettings{'VPN'} eq 'on'){ $sambasettings{'INTERFACES'} .= " $ovpnsettings{'DOVPN_SUBNET'}";}
 if ($sambasettings{'OTHERINTERFACES'} ne ''){ $sambasettings{'INTERFACES'} .= " $sambasettings{'OTHERINTERFACES'}";}
 
 ############################################################################################################################
@@ -407,7 +407,7 @@ print <<END
 <tr><td align='left' width='40%'>$Lang::tr{'log level'}</td><td align='left'><input type='text' name='LOGLEVEL' value='$sambasettings{'LOGLEVEL'}' size="30" /></td></tr>
 <tr><td align='left' width='40%'>$Lang::tr{'interfaces'}</td><td align='left'>on <input type='radio' name='VPN' value='on' $checked{'VPN'}{'on'} />/
                                                                                                                                                                                <input type='radio' name='VPN' value='off' $checked{'VPN'}{'off'} /> off |
-                                                                                                                                                                               <font size='2' color='$Header::colourovpn'><b>   OpenVpn  -  $ovpnsettings{'DDEVICE'}</b></font></td></tr>
+                                                                                                                                                                               <font size='2' color='$Header::colourovpn'><b>   OpenVpn  -  $ovpnsettings{'DOVPN_SUBNET'}</b></font></td></tr>
 <tr><td align='left' width='40%'></td><td align='left'>on <input type='radio' name='GREEN' value='on' $checked{'GREEN'}{'on'} />/
                                                                                                                                        <input type='radio' name='GREEN' value='off' $checked{'GREEN'}{'off'} /> off |
                                                                                                                                        <font size='2' color='$Header::colourgreen'><b>   $Lang::tr{'green'}  -  $netsettings{'GREEN_DEV'}</b></font></td></tr>
index 2da8d64dfc081726d4db84cd42ad420e4fd8a9f8..8a1f69e36da7fd4cd6929e61c58d805ea6066683 100644 (file)
@@ -16,7 +16,7 @@ case "$1" in
                        devices="${GREEN_DEV}"
                fi
                if [ -e /var/ipfire/dhcp/enable_blue ]; then
-                       devices=+" ${BLUE_DEV}"
+                       devices+=" ${BLUE_DEV}"
                        
                        iptables -A DHCPBLUEINPUT -p tcp --source-port 68 --destination-port 67 -i ${BLUE_DEV} -j ACCEPT > /dev/null 2>&1
                        iptables -A DHCPBLUEINPUT -p udp --source-port 68 --destination-port 67 -i ${BLUE_DEV} -j ACCEPT > /dev/null 2>&1
index 46fb4c91db556fcd130659eb0e7ba6c0a4d63890..4170e7b72d2f0b9e0ab39c4e8e250f5e4b2705ab 100644 (file)
@@ -7,7 +7,7 @@ PROGS = iowrap
 SUID_PROGS = setdmzholes setportfw setfilters setxtaccess \
        squidctrl restartssh ipfirereboot setaliases \
        ipsecctrl timectrl dhcpctrl snortctrl \
-       applejuicectrl rebuildhosts \
+       applejuicectrl rebuildhosts backupctrl\
        restartsyslogd logwatch openvpnctrl outgoingfwctrl \
        restartwireless getipstat qosctrl launch-ether-wake \
        redctrl extrahdctrl sambactrl upnpctrl tripwirectrl \
@@ -123,3 +123,6 @@ pakfire: pakfire.c setuid.o ../install+setup/libsmooth/varval.o
 
 mpfirectrl: mpfirectrl.c setuid.o ../install+setup/libsmooth/varval.o
        $(COMPILE) -I../install+setup/libsmooth/ mpfirectrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
+
+backupctrl: backupctrl.c setuid.o ../install+setup/libsmooth/varval.o
+       $(COMPILE) -I../install+setup/libsmooth/ backupctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
diff --git a/src/misc-progs/backupctrl.c b/src/misc-progs/backupctrl.c
new file mode 100644 (file)
index 0000000..26d840f
--- /dev/null
@@ -0,0 +1,44 @@
+/* This file is part of the IPFire Firewall.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "setuid.h"
+
+int main(int argc, char *argv[]) {
+       int i;
+       char command[1024];
+       char add[STRING_SIZE];
+       
+       if (!(initsetuid()))
+               exit(1);
+
+       snprintf(command, STRING_SIZE, "/var/ipfire/backup/bin/backup.pl");
+
+       for (i = 1; i < argc; i++) {
+    if (strstr(argv[i], "&&")){
+             fprintf (stderr, "Bad Argument!\n");
+        exit (1);
+    }
+               if (strstr(argv[i], "|")){
+                   fprintf (stderr, "Bad Argument!\n");
+                   exit (1);
+               }
+               if (argc > 2){
+                   fprintf (stderr, "Too Many Arguments!\n");
+                   exit (1);
+               }
+               sprintf(add, " %s", argv[i]);
+               strcat(command, add);
+       }
+       
+       return safe_system(command);
+}