summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-01-03 21:49:24 +0000
committerErmal <eri@pfsense.org>2011-01-03 21:49:24 +0000
commite1daff07b2f35197abb977437cbb317097423f6f (patch)
tree48192a45c62dcc0262c4c7ad7865caf274e9b93b
parent55c51af7293cf6ac65d6c1fee15071aef0558482 (diff)
downloadpfsense-e1daff07b2f35197abb977437cbb317097423f6f.zip
pfsense-e1daff07b2f35197abb977437cbb317097423f6f.tar.gz
Use glob instead of forking cat with glob patterns. Also use file() instead of forking cat just for reading a file. This might help with the issue reported on Ticket #943 which seems like a timing issue even though the dns events happen before newip events.
-rw-r--r--etc/inc/system.inc22
1 files changed, 12 insertions, 10 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index d95875d..7b6bfe7 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -86,12 +86,6 @@ function system_resolvconf_generate($dynupdate = false) {
$syscfg = $config['system'];
- $fd = fopen("{$g['varetc_path']}/resolv.conf", "w");
- if (!$fd) {
- printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n");
- return 1;
- }
-
$resolvconf = "domain {$syscfg['domain']}\n";
$havedns = false;
@@ -122,6 +116,12 @@ function system_resolvconf_generate($dynupdate = false) {
}
}
+ $fd = fopen("{$g['varetc_path']}/resolv.conf", "w");
+ if (!$fd) {
+ printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n");
+ return 1;
+ }
+
fwrite($fd, $resolvconf);
fclose($fd);
@@ -158,7 +158,7 @@ function get_searchdomains() {
$master_list = array();
// Read in dhclient nameservers
- $search_list = split("\n", `/bin/cat /var/etc/searchdomain_* 2>/dev/null`);
+ $search_list = glob("/var/etc/searchdomain_*");
if (is_array($search_lists)) {
foreach($search_lists as $dns) {
if(is_hostname($dns))
@@ -174,7 +174,7 @@ function get_nameservers() {
$master_list = array();
// Read in dhclient nameservers
- $dns_lists = split("\n", `/bin/cat /var/etc/nameserver_* 2>/dev/null`);
+ $dns_lists = glob("/var/etc/nameserver_*");
if (is_array($dns_lists)) {
foreach($dns_lists as $dns) {
if(is_ipaddr($dns))
@@ -185,10 +185,12 @@ function get_nameservers() {
// Read in any extra nameservers
if(file_exists("/var/etc/nameservers.conf")) {
$dns_lists = split("\n", `/bin/cat /var/etc/nameservers.conf`);
- if(is_array($dns_s))
+ $dns_lists = file("/var/etc/nameservers.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ if(is_array($dns_s)) {
foreach($dns_s as $dns)
if (is_ipaddr($dns))
$master_list[] = $dns;
+ }
}
return $master_list;
@@ -1477,4 +1479,4 @@ function system_get_dmesg_boot() {
return file_get_contents("{$g['varlog_path']}/dmesg.boot");
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud