Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 540728
Collapse All | Expand All

(-)macchanger.sh.orig (-16 / +20 lines)
Lines 14-20 Link Here
14
	# We don't change MAC addresses from background
14
	# We don't change MAC addresses from background
15
	yesno ${IN_BACKGROUND} && return 0
15
	yesno ${IN_BACKGROUND} && return 0
16
16
17
	local mac= opts=
17
	local mac= opts= try= output= rc=
18
18
19
	eval mac=\$mac_${IFVAR}
19
	eval mac=\$mac_${IFVAR}
20
	[ -z "${mac}" ] && return 0
20
	[ -z "${mac}" ] && return 0
Lines 60-66 Link Here
60
		random-full|random) opts="${opts} -r";;
60
		random-full|random) opts="${opts} -r";;
61
61
62
		# default case is just to pass on all the options
62
		# default case is just to pass on all the options
63
		*) opts="${opts} ${mac}";;
63
		*) opts="${opts} -m ${mac}";;
64
	esac
64
	esac
65
65
66
	if [ ! -x /sbin/macchanger ]; then
66
	if [ ! -x /sbin/macchanger ]; then
Lines 68-92 Link Here
68
		return 1
68
		return 1
69
	fi
69
	fi
70
70
71
	mac=$(/sbin/macchanger ${opts} "${IFACE}" \
71
	for try in 1 2; do
72
		| sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
72
		# Sometimes the interface needs to be up
73
	_up
73
		[ "${try}" -eq 2 ] && _up
74
74
		output=$(/sbin/macchanger ${opts} "${IFACE}")
75
	# Sometimes the interface needs to be up ....
75
		rc=$?
76
	if [ -z "${mac}" ]; then
76
		[ "${rc}" -eq 0 ] && break
77
		mac=$(/sbin/macchanger ${opts} "${IFACE}" \
77
	done
78
		| sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
79
	fi
80
78
81
	if [ -z "${mac}" ]; then
79
	if [ "${rc}" -ne 0 ]; then
82
		eend 1 "Failed to set MAC address"
80
		eend 1 "Failed to set MAC address"
83
		return 1
81
		return 1
84
	fi
82
	fi
85
83
	
86
	eend 0
84
	eend 0
87
	eindent
85
88
	einfo "changed to" "${mac}"
86
	mac=$(printf "%s" "$output" \
89
	eoutdent
87
		| sed -n -e 's/^New MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p')
88
89
	if [ -n "${mac}" ]; then
90
		eindent
91
		einfo "changed to" "${mac}"
92
		eoutdent
93
	fi
90
94
91
	return 0
95
	return 0
92
}
96
}

Return to bug 540728