Project

General

Profile

« Previous | Next » 

Revision e1daff07

Added by Ermal LUÇI over 14 years ago

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.

View differences:

etc/inc/system.inc
86 86

  
87 87
	$syscfg = $config['system'];
88 88

  
89
	$fd = fopen("{$g['varetc_path']}/resolv.conf", "w");
90
	if (!$fd) {
91
		printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n");
92
		return 1;
93
	}
94

  
95 89
	$resolvconf = "domain {$syscfg['domain']}\n";
96 90

  
97 91
	$havedns = false;
......
122 116
		}
123 117
	}
124 118

  
119
	$fd = fopen("{$g['varetc_path']}/resolv.conf", "w");
120
	if (!$fd) {
121
		printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n");
122
		return 1;
123
	}
124

  
125 125
	fwrite($fd, $resolvconf);
126 126
	fclose($fd);
127 127

  
......
158 158
	$master_list = array();
159 159
	
160 160
	// Read in dhclient nameservers
161
	$search_list = split("\n", `/bin/cat /var/etc/searchdomain_* 2>/dev/null`);
161
	$search_list = glob("/var/etc/searchdomain_*");
162 162
	if (is_array($search_lists)) {
163 163
		foreach($search_lists as $dns) {
164 164
			if(is_hostname($dns)) 
......
174 174
	$master_list = array();
175 175
	
176 176
	// Read in dhclient nameservers
177
	$dns_lists = split("\n", `/bin/cat /var/etc/nameserver_* 2>/dev/null`);
177
	$dns_lists = glob("/var/etc/nameserver_*");
178 178
	if (is_array($dns_lists)) {
179 179
		foreach($dns_lists as $dns) {
180 180
			if(is_ipaddr($dns)) 
......
185 185
	// Read in any extra nameservers
186 186
	if(file_exists("/var/etc/nameservers.conf")) {
187 187
		$dns_lists = split("\n", `/bin/cat /var/etc/nameservers.conf`);
188
		if(is_array($dns_s))
188
		$dns_lists = file("/var/etc/nameservers.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
189
		if(is_array($dns_s)) {
189 190
			foreach($dns_s as $dns)
190 191
				if (is_ipaddr($dns))
191 192
					$master_list[] = $dns;
193
		}
192 194
	}
193 195

  
194 196
	return $master_list;
......
1477 1479
	return file_get_contents("{$g['varlog_path']}/dmesg.boot");
1478 1480
}
1479 1481

  
1480
?>
1482
?>

Also available in: Unified diff