From 7363445d8d5d6d0f4f259af973f3c40ce38c69a6 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 5 Feb 2019 22:02:53 +0100 Subject: [PATCH] interfaces: cleanups for MAC spoofing; closes #1352 --- src/etc/inc/interfaces.inc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index b6854f20f..769a93f8f 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2387,24 +2387,20 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal interface_wireless_configure($realif, $wancfg, $wancfg['wireless']); } - $mac = get_interface_mac($realhwif); - /* * Don't try to reapply the spoofed MAC if it's already applied. - * When ifconfig link is used, it cycles the interface down/up, which triggers - * the interface config again, which attempts to spoof the MAC again, - * which cycles the link again... + * When ifconfig link is used, it cycles the interface down/up, + * which triggers the interface config again, which attempts to + * spoof the MAC again which cycles the link again... */ - if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], $mac)) { - mwexec("/sbin/ifconfig " . escapeshellarg($realhwif) . - " link " . escapeshellarg($wancfg['spoofmac'])); + if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif))) { + mwexecf('/sbin/ifconfig %s link %s', array($realhwif, $wancfg['spoofmac'])); /* All vlans need to spoof their parent mac address, too. */ if (isset($config['vlans']['vlan'])) { foreach ($config['vlans']['vlan'] as $vlan) { if ($vlan['if'] == $realhwif) { - mwexec("/sbin/ifconfig " . escapeshellarg($vlan['vlanif']) . - " link " . escapeshellarg($wancfg['spoofmac'])); + mwexecf('/sbin/ifconfig %s link %s', array($vlan['vlanif'], $wancfg['spoofmac'])); } } }