mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
bsdinstall: avoid conflicts with fd 3
Throughout the bsdinstall script fd 3 is used by f_dprintf (set through
$TERMINAL_STDOUT_PASSTHRU). In several places in the bsdinstalls scripts,
we use fd 3 to juggle stdout when calling out to other tools, which can
cause the installer to fail with a "Bad file descriptor" error when
f_dprintf attempts to use it.
This commit replaces all constructs like this:
exec 3>&1
SOME_VARIABLE=$(some command 2>&1 1>&3)
exec 3>&-
With:
exec 5>&1
SOME_VARIABLE=$(some command 2>&1 1>&5)
exec 5>&-
PR: 273148
Reviewed by: corvink
Fixes: 1f7746d81f
("bsdinstall: stop messing with file descriptors")
MFC after: 1 week
This commit is contained in:
parent
cf7974fd9e
commit
c0e249d32c
@ -159,13 +159,13 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
|
||||
DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')"
|
||||
|
||||
if [ -n "$DISTMENU" ]; then
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
EXTRA_DISTS=$( eval dialog \
|
||||
--backtitle \"$OSNAME Installer\" \
|
||||
--title \"Distribution Select\" --nocancel --separate-output \
|
||||
--checklist \"Choose optional system components to install:\" \
|
||||
0 0 0 $DISTMENU \
|
||||
2>&1 1>&3 )
|
||||
2>&1 1>&5 )
|
||||
for dist in $EXTRA_DISTS; do
|
||||
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
|
||||
done
|
||||
@ -301,13 +301,13 @@ case $CURARCH in
|
||||
;;
|
||||
esac
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
PARTMODE=`echo $PMODES | xargs dialog --backtitle "$OSNAME Installer" \
|
||||
--title "Partitioning" \
|
||||
--item-help \
|
||||
--menu "How would you like to partition your disk?" \
|
||||
0 0 0 2>&1 1>&3` || exit 1
|
||||
exec 3>&-
|
||||
0 0 0 2>&1 1>&5` || exit 1
|
||||
exec 5>&-
|
||||
|
||||
case "$PARTMODE" in
|
||||
"$msg_auto_zfs") # ZFS
|
||||
@ -340,10 +340,10 @@ esac
|
||||
[ -f /usr/libexec/bsdinstall/local.pre-fetch ] && f_dprintf "Running local.pre-fetch" && sh /usr/libexec/bsdinstall/local.pre-fetch "$BSDINSTALL_CHROOT"
|
||||
|
||||
if [ -n "$FETCH_DISTRIBUTIONS" ]; then
|
||||
exec 3>&1
|
||||
export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3)
|
||||
exec 5>&1
|
||||
export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5)
|
||||
FETCH_RESULT=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions"
|
||||
fi
|
||||
@ -371,7 +371,7 @@ fi
|
||||
bsdinstall adduser
|
||||
|
||||
finalconfig() {
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
REVISIT=$(dialog --backtitle "$OSNAME Installer" \
|
||||
--title "Final Configuration" --no-cancel --menu \
|
||||
"Setup of your $OSNAME system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
|
||||
@ -383,8 +383,8 @@ finalconfig() {
|
||||
"Services" "Set daemons to run on startup" \
|
||||
"System Hardening" "Set security options" \
|
||||
"Time Zone" "Set system timezone" \
|
||||
"Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&3)
|
||||
exec 3>&-
|
||||
"Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&5)
|
||||
exec 5>&-
|
||||
|
||||
case "$REVISIT" in
|
||||
"Add User")
|
||||
|
@ -61,10 +61,10 @@ BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
|
||||
mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
|
||||
|
||||
if [ -z "$BSDINSTALL_DISTSITE" ]; then
|
||||
exec 3>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
|
||||
exec 5>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
|
||||
export BSDINSTALL_DISTSITE
|
||||
fi
|
||||
|
@ -34,7 +34,7 @@ echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening
|
||||
echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening
|
||||
echo -n > $BSDINSTALL_TMPBOOT/loader.conf.hardening
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title "System Hardening" --nocancel --separate-output \
|
||||
--checklist "Choose system security hardening options:" \
|
||||
@ -49,9 +49,9 @@ FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \
|
||||
"7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \
|
||||
"8 secure_console" "Enable console password prompt" ${secure_console:-off} \
|
||||
"9 disable_ddtrace" "Disallow DTrace destructive-mode" ${disable_ddtrace:-off} \
|
||||
2>&1 1>&3 )
|
||||
2>&1 1>&5 )
|
||||
retval=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
if [ $retval -ne $BSDDIALOG_OK ]; then
|
||||
exit 1
|
||||
|
@ -66,10 +66,10 @@ fi
|
||||
test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
|
||||
|
||||
if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
|
||||
exec 3>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
|
||||
exec 5>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
|
||||
export BSDINSTALL_DISTSITE
|
||||
fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST"
|
||||
@ -81,13 +81,13 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
|
||||
|
||||
if [ ! "$nonInteractive" == "YES" ]
|
||||
then
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
EXTRA_DISTS=$(echo $DISTMENU | xargs -o bsddialog \
|
||||
--backtitle "$OSNAME Installer" \
|
||||
--title "Distribution Select" --no-cancel --separate-output \
|
||||
--checklist "Choose optional system components to install:" \
|
||||
0 0 0 \
|
||||
2>&1 1>&3)
|
||||
2>&1 1>&5)
|
||||
for dist in $EXTRA_DISTS; do
|
||||
export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
|
||||
done
|
||||
@ -103,10 +103,10 @@ done
|
||||
FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
|
||||
|
||||
if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
|
||||
exec 3>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
|
||||
exec 5>&1
|
||||
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5)
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
|
||||
export BSDINSTALL_DISTSITE
|
||||
fi
|
||||
|
@ -35,7 +35,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
|
||||
: ${BSDDIALOG_ESC=5}
|
||||
: ${BSDDIALOG_ERROR=255}
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title "Mirror Selection" --extra-button --extra-label "Other" \
|
||||
--menu "Please select the best suitable site for you or \"other\" if you want to specify a different choice. The \"Main Site\" directs users to the nearest project managed mirror via GeoDNS (they carry the full range of possible distributions and support both IPv4 and IPv6). All other sites are known as \"Community Mirrors\"; not every site listed here carries more than the base distribution kits. Select a site!" \
|
||||
@ -88,9 +88,9 @@ MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
|
||||
ftp://ftp5.us.freebsd.org "USA #5 - IPv6"\
|
||||
ftp://ftp11.us.freebsd.org "USA #11 - IPv6"\
|
||||
ftp://ftp14.us.freebsd.org "USA #14"\
|
||||
2>&1 1>&3`
|
||||
2>&1 1>&5`
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
_UNAME_R=`uname -r`
|
||||
_UNAME_R=${_UNAME_R%-p*}
|
||||
@ -113,13 +113,13 @@ $BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC)
|
||||
$BSDDIALOG_OK)
|
||||
;;
|
||||
$BSDDIALOG_EXTRA)
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title "Mirror Selection" \
|
||||
--inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
|
||||
0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
|
||||
0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&5`
|
||||
MIRROR_BUTTON=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@
|
||||
;;
|
||||
esac
|
||||
|
@ -71,10 +71,10 @@ if [ -z "$INTERFACES" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec 3>&1
|
||||
INTERFACE=`echo $BSDDIALOG_ITEMS | xargs -o bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3`
|
||||
exec 5>&1
|
||||
INTERFACE=`echo $BSDDIALOG_ITEMS | xargs -o bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&5`
|
||||
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
: > $BSDINSTALL_TMPETC/._rc.conf.net
|
||||
|
||||
@ -182,13 +182,13 @@ else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title 'Network Configuration' \
|
||||
--mixedform 'Resolver Configuration' 0 0 0 \
|
||||
2>&1 1>&3)
|
||||
2>&1 1>&5)
|
||||
if [ $? -eq $BSDDIALOG_CANCEL ]; then exec $0; fi
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
echo ${RESOLV} | tr ' ' '\n' | \
|
||||
awk '
|
||||
|
@ -71,14 +71,14 @@ IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'`
|
||||
NETMASK=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $4); }'`
|
||||
ROUTER=`netstat -rn -f inet | awk '/default/ {printf("%s\n", $2);}'`
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
IF_CONFIG=$(bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --form 'Static Network Interface Configuration' 0 0 0 \
|
||||
'IP Address' 1 1 "$IP_ADDRESS" 1 20 16 0 \
|
||||
'Subnet Mask' 2 1 "$NETMASK" 2 20 16 0 \
|
||||
'Default Router' 3 1 "$ROUTER" 3 20 16 0 \
|
||||
2>&1 1>&3)
|
||||
2>&1 1>&5)
|
||||
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
echo $INTERFACE $IF_CONFIG |
|
||||
awk -v prefix="$IFCONFIG_PREFIX" '{
|
||||
|
@ -107,13 +107,13 @@ END {
|
||||
printf "\"Default Router\" %d 1 \"%s\" %d 16 50 50 0 ", n, dfr, n;
|
||||
}'`
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
IF_CONFIG=$(echo ${ADDRS} | xargs -o bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title 'Network Configuration' \
|
||||
--mixedform 'Static IPv6 Network Interface Configuration' 0 0 0 \
|
||||
2>&1 1>&3)
|
||||
2>&1 1>&5)
|
||||
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
echo ${IF_CONFIG} | tr ' ' '\n' | \
|
||||
awk -v iface="${INTERFACE}" '
|
||||
|
@ -114,13 +114,12 @@ fi
|
||||
bsdinstall mount
|
||||
|
||||
# Fetch missing distribution files, if any
|
||||
(
|
||||
exec 3>&1
|
||||
export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3)
|
||||
FETCH_RESULT=$?
|
||||
exec 3>&-
|
||||
return $FETCH_RESULT
|
||||
) || error "Could not fetch remote distributions"
|
||||
exec 5>&1
|
||||
export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5)
|
||||
FETCH_RESULT=$?
|
||||
exec 5>&-
|
||||
|
||||
[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions"
|
||||
|
||||
# Unpack distributions
|
||||
bsdinstall checksum
|
||||
|
@ -40,7 +40,7 @@ fi
|
||||
|
||||
echo -n > $BSDINSTALL_TMPETC/rc.conf.services
|
||||
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
DAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title "System Configuration" --no-cancel --separate-output \
|
||||
--checklist "Choose the services you would like to be started at boot:" \
|
||||
@ -55,9 +55,9 @@ DAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \
|
||||
powerd "Adjust CPU frequency dynamically if supported" \
|
||||
${powerd_enable:-off} \
|
||||
dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \
|
||||
2>&1 1>&3 )
|
||||
2>&1 1>&5 )
|
||||
retval=$?
|
||||
exec 3>&-
|
||||
exec 5>&-
|
||||
|
||||
if [ $retval -ne $BSDDIALOG_OK ]; then
|
||||
exit 1
|
||||
|
@ -37,7 +37,7 @@ TZ="${BSDINSTALL_CHROOT}/etc/localtime"
|
||||
export TZ
|
||||
|
||||
# Set date
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
DATE=$(bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title 'Time & Date' \
|
||||
--ok-label 'Set Date' \
|
||||
@ -45,11 +45,11 @@ DATE=$(bsddialog --backtitle "$OSNAME Installer" \
|
||||
--default-no \
|
||||
--date-format '%Y%m%d%H%M.%S' \
|
||||
--datebox '' 0 40 \
|
||||
2>&1 1>&3) && date $DATE
|
||||
exec 3>&-
|
||||
2>&1 1>&5) && date $DATE
|
||||
exec 5>&-
|
||||
|
||||
# Set time
|
||||
exec 3>&1
|
||||
exec 5>&1
|
||||
TIME=$(bsddialog --backtitle "$OSNAME Installer" \
|
||||
--title 'Time & Date' \
|
||||
--ok-label 'Set Time' \
|
||||
@ -57,8 +57,8 @@ TIME=$(bsddialog --backtitle "$OSNAME Installer" \
|
||||
--default-no \
|
||||
--time-format '%H%M.%S' \
|
||||
--timebox '' 0 40 \
|
||||
2>&1 1>&3) && date $TIME
|
||||
exec 3>&-
|
||||
2>&1 1>&5) && date $TIME
|
||||
exec 5>&-
|
||||
|
||||
# Switch back
|
||||
if [ -n "$saved_TZ" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user