aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2016-10-24 16:14:06 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2016-10-24 16:14:06 -0700
commitedd52106d7c868c86c396e0c2f486e58a6132d3c (patch)
tree80790fa96d6028da2cc93e741c8fc6f2ec3db03d
parentMakefile.inc: prepare for next release. (diff)
downloadnetifrc-0.5.0.tar.gz
netifrc-0.5.0.tar.bz2
netifrc-0.5.0.zip
net/macchanger: support newer macchanger tool.0.5.0
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@gentoo.org>
-rw-r--r--net/macchanger.sh26
1 files 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