]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Merge remote-tracking branch 'ms/dhcp' into next
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 Mar 2019 09:53:56 +0000 (09:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 11 Mar 2019 09:53:56 +0000 (09:53 +0000)
html/cgi-bin/dhcp.cgi

index 3eb5349a9f70ec7efee12ff0a40f2f5ae11041c7..675d8001200aa37eb8bfda4c2187f65b51b4cf49 100644 (file)
@@ -446,15 +446,17 @@ if ($dhcpsettings{'ACTION'} eq $Lang::tr{'add'}.'2') {
            &General::log($Lang::tr{'fixed ip lease added'});
 
            # Enter edit mode
-           $dhcpsettings{'KEY2'} = $key;
+           $dhcpsettings{'KEY2'} = 0;
        } else {
            @current2[$dhcpsettings{'KEY2'}] = "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_ADDR'},$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},$dhcpsettings{'FIX_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FIX_REMARK'}\n";
            $dhcpsettings{'KEY2'} = '';       # End edit mode
            &General::log($Lang::tr{'fixed ip lease modified'});
+
+           # sort newly added/modified entry
+           &sortcurrent2;
        }
 
         #Write changes to dhcpd.conf.
-        &sortcurrent2;    # sort newly added/modified entry
         &buildconf;       # before calling buildconf which use fixed lease file !
     }
 }
@@ -1272,7 +1274,7 @@ sub buildconf {
            print FILE ", " . $dhcpsettings{"WINS2_${itf}"}                            if ($dhcpsettings{"WINS2_${itf}"});
            print FILE ";\n"                                                           if ($dhcpsettings{"WINS1_${itf}"});
            print FILE "\tnext-server " . $dhcpsettings{"NEXT_${itf}"} . ";\n" if ($dhcpsettings{"NEXT_${itf}"});
-           print FILE "\tfilename \"" . $dhcpsettings{"FILE_${itf}"} . "\";\n" if ($dhcpsettings{"FILE_${itf}"});
+           print FILE "\tfilename \"" . &EscapeFilename($dhcpsettings{"FILE_${itf}"}) . "\";\n" if ($dhcpsettings{"FILE_${itf}"});
            print FILE "\tdefault-lease-time " . ($dhcpsettings{"DEFAULT_LEASE_TIME_${itf}"} * 60). ";\n";
            print FILE "\tmax-lease-time "     . ($dhcpsettings{"MAX_LEASE_TIME_${itf}"} * 60)    . ";\n";
            print FILE "\tallow bootp;\n" if ($dhcpsettings{"ENABLEBOOTP_${itf}"} eq 'on');
@@ -1325,7 +1327,7 @@ sub buildconf {
            print FILE "\thardware ethernet $temp[0];\n";
            print FILE "\tfixed-address $temp[1];\n";
            print FILE "\tnext-server $temp[3];\n"          if ($temp[3]);
-           print FILE "\tfilename \"$temp[4]\";\n"         if ($temp[4]);
+           print FILE "\tfilename \"" . &EscapeFilename($temp[4]) . "\";\n" if ($temp[4]);
            print FILE "\toption root-path \"$temp[5]\";\n" if ($temp[5]);
            print FILE "}\n";
            $key++;
@@ -1335,7 +1337,7 @@ sub buildconf {
     close FILE;
     if ( $dhcpsettings{"ENABLE_GREEN"} eq 'on' || $dhcpsettings{"ENABLE_BLUE"} eq 'on' ) {system '/usr/local/bin/dhcpctrl enable >/dev/null 2>&1';}
     else {system '/usr/local/bin/dhcpctrl disable >/dev/null 2>&1';}
-    system '/usr/local/bin/dhcpctrl restart >/dev/null 2>&1';
+    system '/usr/local/bin/dhcpctrl restart >/dev/null 2>&1 &';
 }
 
 #
@@ -1392,3 +1394,12 @@ sub IsUsedNewOptionDefinition {
     }
     return 0;
 }
+
+sub EscapeFilename($) {
+       my $filename = shift;
+
+       # Replace all single / by \/
+       $filename =~ s/\//\\\//g;
+
+       return $filename;
+}