summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-08-03 23:10:26 -0500
committerChris Buechler <cmb@pfsense.org>2015-08-03 23:10:26 -0500
commit0057e62d240d5e41f1f5d5a53328bc9ace92f34d (patch)
treed3486aeaec5dace4d3558c72b10e59cbd72385bf /etc/inc
parent626f10a30c38bdb14e557a33f9fbbd01d4dde992 (diff)
downloadpfsense-0057e62d240d5e41f1f5d5a53328bc9ace92f34d.zip
pfsense-0057e62d240d5e41f1f5d5a53328bc9ace92f34d.tar.gz
only read file if it exists, and only foreach if an array.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/pfsense-utils.inc22
1 files changed, 13 insertions, 9 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 93719ad..2d42ecb 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -127,20 +127,24 @@ function get_tmp_file() {
/****f* pfsense-utils/get_dns_servers
* NAME
- * get_dns_servres - get system dns servers
+ * get_dns_servers - get system dns servers
* INPUTS
- * $dns_servers - an array of the dns servers
+ * none
* RESULT
- * null
+ * $dns_servers - an array of the dns servers
******/
function get_dns_servers() {
$dns_servers = array();
- $dns_s = file("/etc/resolv.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- foreach ($dns_s as $dns) {
- $matches = "";
- if (preg_match("/nameserver (.*)/", $dns, $matches)) {
- $dns_servers[] = $matches[1];
- }
+ if (file_exists("/etc/resolv.conf")) {
+ $dns_s = file("/etc/resolv.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ }
+ if (is_array($dns_s)) {
+ foreach ($dns_s as $dns) {
+ $matches = "";
+ if (preg_match("/nameserver (.*)/", $dns, $matches)) {
+ $dns_servers[] = $matches[1];
+ }
+ }
}
return array_unique($dns_servers);
}
OpenPOWER on IntegriCloud