Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 194191 - Bug in /lib/rcscript/net/arping.sh, some vairables name may be miswritten and may cause some unexpected problems.
Summary: Bug in /lib/rcscript/net/arping.sh, some vairables name may be miswritten and...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High major
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-29 11:24 UTC by kouyu
Modified: 2007-10-30 07:58 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kouyu 2007-09-29 11:24:18 UTC
I found this bug with my baselayout-1.12-10-r4(r5).
I know baselayout-2 will be out soon. But please glance this bug for a little, and then decide whether it should be fixed. Thank you!

It is in /lib/rcscript/net/arping.sh, about function "arping_start".
I paste the code below:

arping_start() {
	local iface="$1" gateways= x= conf= i=
	local ifvar=$(bash_variable "${iface}")

	einfo "Pinging gateways on ${iface} for configuration"

	gateways="gateways_${ifvar}[@]"
	if [[ -z "${!gateways}" ]] ; then
		eerror "No gateways have been defined (gateways_${ifvar}=( \"...\"))"
		return 1
	fi

	eindent
	
	for x in ${!gateways}; do
		local -a a=( ${x//,/ } )
		local ip="${a[0]}" mac="${a[1]}" extra=
		if [[ -n ${mac} ]] ; then
			mac=$(echo "${mac}" | tr '[:lower:]' '[:upper:]')
			extra=(MAC ${mac})
		fi

		vebegin "${ip} ${extra}"
		if arping_address_exists "${iface}" "${ip}" "${mac}" ; then
			for i in ${ip//./ } ; do
				if [[ ${#i} == "2" ]] ; then
					conf="${conf}0${i}"
				elif [[ ${#i} == "1" ]] ; then
					conf="${conf}00${i}"
				else
					conf="${conf}${i}"
				fi
			done
			[[ -n ${mac} ]] && conf="${conf}_${mac//:/}"
			
			veend 0
			eoutdent
			veinfo "Configuring ${iface} for ${ip} ${extra}"
			configure_variables "${iface}" "${conf}"

			# Call the system module as we've aleady passed it by ....
			# And it *has* to be pre_start for other things to work correctly
			system_pre_start "${iface}"
			
			t="config_${ifvar}[@]"

			# Only return if we HAVE a config that doesn't include
			# arping to avoid infinite recursion.
			if [[ " ${!t} " != *" arping "* ]] ; then
				config=( "${!t}" )
				t="fallback_config_${ifvar}[@]"
				fallback_config=( "${!t}" )
				t="fallback_route_${ifvar}[@]"
				fallback_route=( "${!t}" )
				config_counter=-1
				return 0
			fi
		fi
		veend 1
	done

	eoutdent
	return 1
}


And I think bug is from this segment below:

			# Only return if we HAVE a config that doesn't include
			# arping to avoid infinite recursion.
			if [[ " ${!t} " != *" arping "* ]] ; then
				config=( "${!t}" )
				t="fallback_config_${ifvar}[@]"
				fallback_config=( "${!t}" )
				t="fallback_route_${ifvar}[@]"
				fallback_route=( "${!t}" )
				config_counter=-1
				return 0
			fi

The code above overrides three variables config, fallback_config and fallback_route and set config_counter to -1 in order to restart the main start loop with the new three variables, which is in iface_start, the main function for network-up in /etc/init.d/net.lo .(The three variables is used by the function)

The problem is the 2nd variable may be miswritten, it should be fallback not fallback_config, because in /etc/init.d/net.lo, in iface_start, there is not a variable named fallback_config but named fallback(the other two is config and fallback_route). And in /etc/conf.d/net.example, fallback_config_xxx is not refered either, but many examples of fallback_xxx. So I think in the above code, the "fallback_config" does be "fallback".

I think the users who set fallback_GATEWAY(e.g. fallback_192168000001) wouldn't get the expected result which should have been caused by fallback_GATEWAY variable.



BTW: I know variable "fallback" is corresponding to "config". So in my opinion, "fallback_config" is more understandable then "fallback". However, fallback_config is a bug here.

And In addition, I think "ipconfig" or "ip" is more exact than "config", because I found the all thing variable config represents is all about ip address config, either a static ip string, or dhcp, or apipa, or... And the other configs, such as dns, route, essid, there are special variables to stand for. Only config=noop is meaningful to all network config -- no operation to all network config if interface has been already up. 
The name "config" is a little bigger than what it represents. So..., I think in baselayout2, maybe it would have some changing.
Oh, as I have seen the sources of baselayout-2 about net-script, I think it's better if adding more comments for each function, like what baselayout-1 does.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2007-10-30 07:58:48 UTC
I've fixed this in our svn repo on the off chance we do another 1.12 release.

Thanks!