Project

General

Profile

« Previous | Next » 

Revision 0b1c5ff5

Added by Scott Ullrich over 17 years ago

The original code did a mixed work: the part in interfaces_assign.php first renamed the interfaces, and then called cleanup_opt_interfaces_after_removal(). The latter didn't do anything at all: it never entered the loop, it didn't save the result of str_replace, it didn't save the resulting config after the processing. And if it had worked, it would have renamed the interfaces a second time as a side effect, completely messing-up the config.

Ticket #1532

View differences:

etc/inc/pfsense-utils.inc
2452 2452
	unlink_if_exists("{$g['tmp_path']}/config.cache");
2453 2453
	$config_file = file_get_contents("/cf/conf/config.xml");
2454 2454
	/* loop through and reassign deleted items */
2455
	for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) {
2456
		if ($i < $opt_interface_num)
2457
			break;
2458
		if ($i == $opt_interface_num) {
2459
			/* item should be deleted */
2460
			str_replace("opt" . $i, "optXXXX", $config_file);
2461
		}
2462
	}
2463
	/* loop through and reassign optional items */
2464
	for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) {
2465
		if ($i < $opt_interface_num)
2466
			break;
2467
		/* replace opt$i with $i -1 */
2468
		str_replace("opt" . $i, "opt" . ($i -1), $config_file);
2469
	}
2455
	$orig = array('opt'.$opt_interface_num,'OPT'.$opt_interface_num);
2456
	$repl = array('optXXXX','OPTXXXX');
2457
	for ($i = $opt_interface_num+1; isset ($config['interfaces']['opt' . $i]); $i++) {
2458
		array_push($orig,'opt'.$i);
2459
		array_push($repl,'opt'.($i -1));
2460
		array_push($orig,'OPT'.$i);
2461
		array_push($repl,'OPT'.($i -1));
2462
	}
2463
	$config_file = str_replace($orig, $repl, $config_file);
2470 2464
	$fd = fopen("/cf/conf/config.xml", "w");
2471 2465
	fwrite($fd, $config_file);
2472 2466
	fclose($fd);
......
2490 2484
			if($config['nat']['rule'][$x]['interface'] == "optXXXX")
2491 2485
		 		unset($config['nat']['rule'][$x]['interface']);
2492 2486
	}
2487
	write_config();
2493 2488
	conf_mount_ro();
2494 2489
	config_unlock();
2495 2490
	return true;
......
3622 3617
	return false;
3623 3618
}
3624 3619

  
3625
?>
3620
?>

Also available in: Unified diff