Project

General

Profile

« Previous | Next » 

Revision f36d4bd2

Added by Scott Ullrich almost 20 years ago

If the interface has a mac address of ff:ff:ff:ff:ff:ff generate a random mac address and assign.

View differences:

etc/inc/interfaces.inc
93 93
		interfaces_wireless_configure($lancfg['if'], $lancfg['wireless']);
94 94

  
95 95
	/* MAC spoofing? */
96
	if ($lancfg['spoofmac'])
96
	if ($lancfg['spoofmac']) {
97 97
		mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
98 98
			" link " . escapeshellarg($lancfg['spoofmac']));
99

  
99
	} else {
100
		$mac = get_interface_mac_address($lancfg['if']);
101
		if($mac == "ff:ff:ff:ff:ff:ff") {
102
			/*   this is not a valid mac address.  generate a
103
			 *   temporary mac address so the machine can get online.
104
			 */
105
			$random_mac = generate_random_mac_address();
106
			mwexec("/sbin/ifconfig " . escapeshellarg($lancfg['if']) .
107
				" link " . escapeshellarg($random_mac));
108
			$lancfg['spoofmac'] = $random_mac;
109
			write_config();
110
		}
111
	}	
112
	
100 113
	/* media */
101 114
	if ($lancfg['media'] || $lancfg['mediaopt']) {
102 115
		$cmd = "/sbin/ifconfig " . escapeshellarg($lancfg['if']);
......
193 206
			interfaces_wireless_configure($optcfg['if'], $optcfg['wireless']);
194 207

  
195 208
		/* MAC spoofing? */
196
		if ($optcfg['spoofmac'])
209
		if ($optcfg['spoofmac']) {
197 210
			mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) .
198 211
				" link " . escapeshellarg($optcfg['spoofmac']));
212
		}  else {
213
		$mac = get_interface_mac_address($optcfg['if']);
214
		if($mac == "ff:ff:ff:ff:ff:ff") {
215
			/*   this is not a valid mac address.  generate a
216
			 *   temporary mac address so the machine can get online.
217
			 */
218
			$random_mac = generate_random_mac_address();
219
			mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) .
220
				" link " . escapeshellarg($random_mac));
221
			$optcfg['spoofmac'] = $random_mac;
222
			write_config();
223
		}
199 224

  
200 225
		/* media */
201 226
		if ($optcfg['media'] || $optcfg['mediaopt']) {
......
428 453
	if (is_array($wancfg['wireless']))
429 454
		interfaces_wireless_configure($wancfg['if'], $wancfg['wireless']);
430 455

  
431
	if ($wancfg['spoofmac'])
456
	if ($wancfg['spoofmac']) {
432 457
		mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) .
433 458
			" link " . escapeshellarg($wancfg['spoofmac']));
459
	}  else {
460
		$mac = get_interface_mac_address($wancfg['if']);
461
		if($mac == "ff:ff:ff:ff:ff:ff") {
462
			/*   this is not a valid mac address.  generate a
463
			 *   temporary mac address so the machine can get online.
464
			 */
465
			$random_mac = generate_random_mac_address();
466
			mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) .
467
				" link " . escapeshellarg($random_mac));
468
			$wancfg['spoofmac'] = $random_mac;
469
			write_config();
470
		}
471
	}
434 472

  
435 473
	/* media */
436 474
	if ($wancfg['media'] || $wancfg['mediaopt']) {

Also available in: Unified diff