Write the multi step netconfig to a temporary file and only move that

to the final name if netconfig was completely finished.  This fixes
reentrance problems even better than r222611.

Suggested by:	nwhitehorn
Reviewed by:	nwhitehorn
Sponsored by:	The FreeBSD Foundation
Sponsored by:	iXsystems
This commit is contained in:
Bjoern A. Zeeb 2011-06-02 14:25:27 +00:00
parent 1dff98d9bb
commit d63d020e22
3 changed files with 10 additions and 9 deletions

View File

@ -54,14 +54,14 @@ INTERFACE=`echo $DIALOG_TAGS | xargs dialog --backtitle 'FreeBSD Installer' --ti
if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
exec 3>&-
: > $BSDINSTALL_TMPETC/rc.conf.net
: > $BSDINSTALL_TMPETC/._rc.conf.net
# Do a dirty check to see if this a wireless interface -- there should be a
# better way
IFCONFIG_PREFIX=""
if ifconfig $INTERFACE | grep -q 'media: IEEE 802.11 Wireless'; then
NEXT_WLAN_IFACE=wlan0 # XXX
echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/rc.conf.net
echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/._rc.conf.net
IFCONFIG_PREFIX="WPA "
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
ifconfig $NEXT_WLAN_IFACE create wlandev $INTERFACE
@ -95,7 +95,7 @@ fi
# In case wlanconfig left an option and we do not support IPv4 we need to write
# it out on its own. We cannot write it out with IPv6 as that suffix.
if [ ${IPV4_AVAIL} -eq 0 -a -n ${IFCONFIG_PREFIX} ]; then
echo ifconfig_${INTERFACE}=\"${IFCONFIG_PREFIX}\" >> $BSDINSTALL_TMPETC/rc.conf.net
echo ifconfig_${INTERFACE}=\"${IFCONFIG_PREFIX}\" >> $BSDINSTALL_TMPETC/._rc.conf.net
fi
if [ ${IPV6_AVAIL} -eq 1 ]; then
dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \
@ -192,3 +192,4 @@ BEGIN {
printf "nameserver %s\n", $1;
}' > ${BSDINSTALL_TMPETC}/resolv.conf
mv $BSDINSTALL_TMPETC/._rc.conf.net $BSDINSTALL_TMPETC/rc.conf.net

View File

@ -44,7 +44,7 @@ esac
dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0
if [ $? -eq $DIALOG_OK ]; then
echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/rc.conf.net
echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring DHCP lease..." 0 0
@ -74,10 +74,10 @@ echo $INTERFACE $IF_CONFIG |
awk -v prefix="$IFCONFIG_PREFIX" '{
printf("ifconfig_%s=\"%s inet %s netmask %s\"\n", $1, prefix, $2, $3);
printf("defaultrouter=\"%s\"\n", $4);
}' >> $BSDINSTALL_TMPETC/rc.conf.net
}' >> $BSDINSTALL_TMPETC/._rc.conf.net
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
. $BSDINSTALL_TMPETC/rc.conf.net
. $BSDINSTALL_TMPETC/._rc.conf.net
ifconfig $INTERFACE inet `eval echo \\\$ifconfig_$INTERFACE`
route delete -inet default
route add -inet default $defaultrouter

View File

@ -69,7 +69,7 @@ while : ; do
continue
fi
fi
echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/rc.conf.net
echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/._rc.conf.net
exit 0
else
break
@ -138,10 +138,10 @@ BEGIN {
sub("$", "/64", $1);
}
printf("ifconfig_%s_ipv6=\"inet6 %s\"\n", iface, $1);
}' >> $BSDINSTALL_TMPETC/rc.conf.net
}' >> $BSDINSTALL_TMPETC/._rc.conf.net
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
. $BSDINSTALL_TMPETC/rc.conf.net
. $BSDINSTALL_TMPETC/._rc.conf.net
ifconfig ${INTERFACE} `eval echo \\\$ifconfig_${INTERFACE}_ipv6`
route delete default
route add default ${ipv6_defaultrouter}