From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B4F83138D6A for ; Mon, 24 Oct 2016 23:16:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F113CE0AF0; Mon, 24 Oct 2016 23:16:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D9E4FE0AF0 for ; Mon, 24 Oct 2016 23:16:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E01303416B3 for ; Mon, 24 Oct 2016 23:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3411324A2 for ; Mon, 24 Oct 2016 23:16:41 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1477350846.edd52106d7c868c86c396e0c2f486e58a6132d3c.robbat2@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/macchanger.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: edd52106d7c868c86c396e0c2f486e58a6132d3c X-VCS-Branch: master Date: Mon, 24 Oct 2016 23:16:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bc754295-e7ea-4232-905f-01d431616afc X-Archives-Hash: 2f3f5c74ca1e8f9e703827ec5f8bb734 commit: edd52106d7c868c86c396e0c2f486e58a6132d3c Author: Robin H. Johnson gentoo org> AuthorDate: Mon Oct 24 23:14:06 2016 +0000 Commit: Robin H. Johnson gentoo 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 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