commit: edd52106d7c868c86c396e0c2f486e58a6132d3c Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> AuthorDate: Mon Oct 24 23:14:06 2016 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Mon Oct 24 23:14:06 2016 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=edd52106
net/macchanger: support newer macchanger tool. Newer versions of macchanger require -m to specify the MAC (it used to be a non-option argument). Also don't depend on the output format at all anymore, instead reading the new MAC from sysfs on after macchanger reports success. X-Gentoo-Bug: 540728 X-Gentoo-Bug: 547906 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540728 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547906 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> net/macchanger.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/macchanger.sh b/net/macchanger.sh index ff13770..ae9ff9b 100644 --- a/net/macchanger.sh +++ b/net/macchanger.sh @@ -14,7 +14,7 @@ macchanger_pre_start() # We don't change MAC addresses from background yesno ${IN_BACKGROUND} && return 0 - local mac= opts= + local mac= opts= try= output= rc= eval mac=\$mac_${IFVAR} [ -z "${mac}" ] && return 0 @@ -60,7 +60,7 @@ macchanger_pre_start() random-full|random) opts="${opts} -r";; # default case is just to pass on all the options - *) opts="${opts} ${mac}";; + *) opts="${opts} -m ${mac}";; esac if [ ! -x /sbin/macchanger ]; then @@ -68,24 +68,24 @@ macchanger_pre_start() return 1 fi - mac=$(/sbin/macchanger ${opts} "${IFACE}" \ - | sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' ) - _up + for try in 1 2; do + # Sometimes the interface needs to be up + [ "${try}" -eq 2 ] && _up + output=$(/sbin/macchanger ${opts} "${IFACE}") + rc=$? + [ "${rc}" -eq 0 ] && break + done - # Sometimes the interface needs to be up .... - if [ -z "${mac}" ]; then - mac=$(/sbin/macchanger ${opts} "${IFACE}" \ - | sed -n -e 's/^\(Faked\|New\) MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\2/p' ) - fi - - if [ -z "${mac}" ]; then + if [ "${rc}" -ne 0 ]; then + eerror "${output}" eend 1 "Failed to set MAC address" return 1 fi eend 0 eindent - einfo "changed to" "${mac}" + newmac=$(_get_mac_address) + einfo "changed to ${newmac}" eoutdent return 0
