From 7905df983103f1288fb22f6db192f3de64a0daa2 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 09:57:17 +0000 Subject: Porvide information for the filter reload status screen. --- etc/rc.filter_synchronize | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'etc/rc.filter_synchronize') diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index af0e5cc..460824b 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -258,8 +258,10 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens log_error($error); file_notice("sync_settings", $error, "Settings Sync", ""); exit; - } else + } else { log_error("XMLRPC sync successfully completed with {$url}:{$port}."); + update_filter_reload_status("XMLRPC sync successfully completed with {$url}:{$port}."); + } $numberofruns = 3; } $numberofruns++; -- cgit v1.1 From fb5830ef33f6e1154f3441d7f13ac90bbe547b3c Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:00:04 +0000 Subject: Actually correct check so it throws some errors during the second try. --- etc/rc.filter_synchronize | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'etc/rc.filter_synchronize') diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index 460824b..c479054 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -104,7 +104,7 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host /* XXX: Configurable from the GUI?! */ $username = "admin"; $cli->setCredentials($username, $password); - if($numberofruns > 1) + if($numberofruns > 0) $cli->setDebug(1); /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "240"); @@ -239,7 +239,7 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens /* XXX: Configurable from the GUI?! */ $username = "admin"; $cli->setCredentials($username, $password); - if($numberofruns > 1) + if($numberofruns > 0) $cli->setDebug(1); /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "240"); -- cgit v1.1 From c333d60986353fd523b2a9380645f0a740ba20c0 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 14:10:32 +0000 Subject: Use the new username field from the GUI or default to admin. --- etc/rc.filter_synchronize | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'etc/rc.filter_synchronize') diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index c479054..9468110 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -87,7 +87,7 @@ function remove_special_characters($string) { return $string; } -function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host_firmware_version') { +function carp_check_version($url, $username, $password, $port = 80, $method = 'pfsense.host_firmware_version') { global $config, $g; if(file_exists("{$g['varrun_path']}/booting") || $g['booting']) @@ -101,8 +101,6 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host while ($numberofruns < 2) { $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - /* XXX: Configurable from the GUI?! */ - $username = "admin"; $cli->setCredentials($username, $password); if($numberofruns > 0) $cli->setDebug(1); @@ -138,7 +136,7 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host return false; } -function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') { +function carp_sync_xml($url, $username, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') { global $config, $g; if(file_exists("{$g['varrun_path']}/booting") || $g['booting']) @@ -151,11 +149,11 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens /* strip out nosync items */ if (is_array($config_copy['nat']['advancedoutbound']['rule'])) { - $rulescnt = count($config_copy['nat']['advancedoutbound']['rule']); - for ($x = 0; $x < $rulescnt; $x++) { - $config_copy['nat']['advancedoutbound']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['advancedoutbound']['rule'][$x]['descr']); - if (isset ($config_copy['nat']['advancedoutbound']['rule'][$x]['nosync'])) - unset ($config_copy['nat']['advancedoutbound']['rule'][$x]); + $rulescnt = count($config_copy['nat']['advancedoutbound']['rule']); + for ($x = 0; $x < $rulescnt; $x++) { + $config_copy['nat']['advancedoutbound']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['advancedoutbound']['rule'][$x]['descr']); + if (isset ($config_copy['nat']['advancedoutbound']['rule'][$x]['nosync'])) + unset ($config_copy['nat']['advancedoutbound']['rule'][$x]); } } if (is_array($config_copy['nat']['rule'])) { @@ -236,8 +234,6 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens log_error("Beginning XMLRPC sync to {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - /* XXX: Configurable from the GUI?! */ - $username = "admin"; $cli->setCredentials($username, $password); if($numberofruns > 0) $cli->setDebug(1); @@ -386,21 +382,23 @@ if (is_array($config['installedpackages']['carpsettings']['config'])) { if ($carp['synchronizecaptiveportal'] != "" and is_array($config['vouchers'])) $sections[] = 'vouchers'; if (count($sections) > 0) { - if (!carp_check_version($synchronizetoip, $carp['password'], $port)) + if (empty($carp['username'])) + $username = "admin"; + else + $username = $carp['username']; + if (!carp_check_version($synchronizetoip, $username, $carp['password'], $port)) break; update_filter_reload_status("Signaling CARP reload signal..."); - carp_sync_xml($synchronizetoip, $carp['password'], $sections, $port); + carp_sync_xml($synchronizetoip, $username, $carp['password'], $sections, $port); if (is_array($mergesections)) - carp_sync_xml($synchronizetoip, $carp['password'], $mergesections, $port, 'pfsense.restore_config_section'); + carp_sync_xml($synchronizetoip, $username, $carp['password'], $mergesections, $port, 'pfsense.restore_config_section'); $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip, $port); $params = array( XML_RPC_encode($carp['password']) ); $msg = new XML_RPC_Message('pfsense.filter_configure', $params); - /* XXX: Configurable from the GUI */ - $username = "admin"; $cli->setCredentials($username, $carp['password']); $resp = $cli->send($msg, "900"); -- cgit v1.1