summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-06-08 17:32:42 -0400
committerjim-p <jimp@pfsense.org>2011-06-08 17:33:26 -0400
commit7401c8c451e33a5f5fd38e934760e1b855fee822 (patch)
tree5f7131efaa087574a623c58606b8b59e0fbfdeae
parentc7422829b2a76301d2efbe0aa01e3dcfcce3012f (diff)
downloadpfsense-7401c8c451e33a5f5fd38e934760e1b855fee822.zip
pfsense-7401c8c451e33a5f5fd38e934760e1b855fee822.tar.gz
Allow OpenNTPD to listen on Virtual IPs, not just interfaces. Fixes #342
-rw-r--r--etc/inc/system.inc32
-rw-r--r--usr/local/pkg/openntpd.xml6
2 files changed, 34 insertions, 4 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 7e105ab..3f6bc3a 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -1171,9 +1171,16 @@ function system_ntp_configure() {
$xmlsettings = $config['installedpackages']['openntpd']['config'][0];
if ($xmlsettings['enable'] == 'on') {
$ifaces = explode(',', $xmlsettings['interface']);
- $ifaces = array_map('get_real_interface', $ifaces);
- $ifaces = array_filter($ifaces, 'does_interface_exist');
- $ips = array_map('find_interface_ip', $ifaces);
+ $ips = array();
+ foreach ($ifaces as $if) {
+ if (is_ipaddr($if)) {
+ $ips[] = $if;
+ } else {
+ $if = get_real_interface($if);
+ if (does_interface_exist($if))
+ $ips[] = find_interface_ip($if);
+ }
+ }
foreach ($ips as $ip) {
if (is_ipaddr($ip))
$ntpcfg .= "listen on $ip\n";
@@ -1494,4 +1501,23 @@ function system_get_dmesg_boot() {
return file_get_contents("{$g['varlog_path']}/dmesg.boot");
}
+function openntpd_get_listen_ips() {
+ $interfaces = get_configured_interface_with_descr();
+ $carplist = get_configured_carp_interface_list();
+ $listenips = array();
+ foreach ($carplist as $cif => $carpip)
+ $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
+ $aliaslist = get_configured_ip_aliases_list();
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+ foreach ($interfaces as $iface => $ifacename) {
+ $tmp["name"] = $ifacename;
+ $tmp["value"] = $iface;
+ $listenips[] = $tmp;
+ }
+ $tmp["name"] = "Localhost";
+ $tmp["value"] = "lo0";
+ $listenips[] = $tmp;
+ return $listenips;
+}
?>
diff --git a/usr/local/pkg/openntpd.xml b/usr/local/pkg/openntpd.xml
index 907c6fb..cefb76d 100644
--- a/usr/local/pkg/openntpd.xml
+++ b/usr/local/pkg/openntpd.xml
@@ -15,8 +15,12 @@
<fielddescr>Interface</fielddescr>
<description>Select the interface(s) the NTP server will listen on.</description>
<default_value>lan</default_value>
- <type>interfaces_selection</type>
<multiple/>
+ <type>select_source</type>
+ <source><![CDATA[openntpd_get_listen_ips()]]></source>
+ <source_name>name</source_name>
+ <source_value>value</source_value>
+
</field>
</fields>
<custom_php_resync_config_command>
OpenPOWER on IntegriCloud