From 0b486cd14f7f5b857a8bdf159aae5b4b2a59bbc9 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 18 Jun 2016 14:43:58 +0200 Subject: [PATCH] util: move is_fqdn() The call stack is pretty loose on is_fqdn() as it is called by system_routing_configure() which gets called in an uncontrollable fashion in interface.inc. --- src/etc/inc/openvpn_wizard.inc | 2 ++ src/etc/inc/pfsense-utils.inc | 17 ----------------- src/etc/inc/util.inc | 21 +++++++++++++++++++++ src/etc/inc/xmlrpc/legacy.inc | 2 ++ src/etc/rc.newwanipv6 | 1 + 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/etc/inc/openvpn_wizard.inc b/src/etc/inc/openvpn_wizard.inc index 8492d3336..75f642184 100644 --- a/src/etc/inc/openvpn_wizard.inc +++ b/src/etc/inc/openvpn_wizard.inc @@ -25,7 +25,9 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + require_once("openvpn.inc"); +require_once("util.inc"); require_once("pfsense-utils.inc"); function cert_get_subject_hash($crt) diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 77637d145..6236b0d4e 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -215,23 +215,6 @@ function reload_ttys() exec('/bin/kill -HUP 1'); } -function is_fqdn($fqdn) { - $hostname = false; - if (preg_match("/[-A-Z0-9\.]+\.[-A-Z0-9\.]+/i", $fqdn)) { - $hostname = true; - } - if (preg_match("/\.\./", $fqdn)) { - $hostname = false; - } - if (preg_match("/^\./i", $fqdn)) { - $hostname = false; - } - if (preg_match("/\//i", $fqdn)) { - $hostname = false; - } - return($hostname); -} - /* This xml 2 array function is courtesy of the php.net comment section on xml_parse. * it is roughly 4 times faster then our existing pfSense parser but due to the large * size of the RRD xml dumps this is required. diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index ab613ef98..17a5f0444 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -2,6 +2,7 @@ /* Copyright (C) 2015-2016 Franco Fichtner + Copyright (C) 2004-2007 Scott Ullrich Copyright (C) 2003-2004 Manuel Kasper . All rights reserved. @@ -1489,3 +1490,23 @@ function download_alias_geoip($alias) return false; } } + +function is_fqdn($fqdn) +{ + $hostname = false; + + if (preg_match("/[-A-Z0-9\.]+\.[-A-Z0-9\.]+/i", $fqdn)) { + $hostname = true; + } + if (preg_match("/\.\./", $fqdn)) { + $hostname = false; + } + if (preg_match("/^\./i", $fqdn)) { + $hostname = false; + } + if (preg_match("/\//i", $fqdn)) { + $hostname = false; + } + + return $hostname; +} diff --git a/src/etc/inc/xmlrpc/legacy.inc b/src/etc/inc/xmlrpc/legacy.inc index c9af9e51b..7605ec594 100644 --- a/src/etc/inc/xmlrpc/legacy.inc +++ b/src/etc/inc/xmlrpc/legacy.inc @@ -121,8 +121,10 @@ function firmware_version_xmlrpc() function filter_configure_xmlrpc() { global $config; + require_once("filter.inc"); require_once("system.inc"); + require_once("util.inc"); require_once("interfaces.inc"); require_once("vslb.inc"); require_once("openvpn.inc"); diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index 1a11b493d..68f0502fd 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -38,6 +38,7 @@ require_once("services.inc"); require_once("rrd.inc"); require_once("util.inc"); require_once("system.inc"); +require_once("plugins.inc"); require_once("pfsense-utils.inc"); require_once("interfaces.inc");