Bug 266802

Summary: (1f7746d) /usr/libexec/bsdinstall/script: 3: Bad file descriptor
Product: Base System Reporter: Andrew Cagney <andrew.cagney>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: asiciliano, grahamperrin, john.grafton, manu, re
Priority: --- Keywords: install
Version: 13.1-RELEASEFlags: grahamperrin: maintainer-feedback? (re)
Hardware: amd64   
OS: Any   
URL: https://cgit.freebsd.org/src/commit/?h=main&id=1f7746d81f53447ac15cc99395bb714d4dd0a4da
See Also: https://reviews.freebsd.org/D35113#795883
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267644
Attachments:
Description Flags
loader.conf (probably not interesting)
none
base.conf none

Description Andrew Cagney 2022-10-03 19:52:46 UTC
Automated 13.1 install gets the error:

 DEBUG: dialog.subr: DIALOG_SELF_INITIALIZE=[1]
 DEBUG: f_dialog_init: ARGV=[/etc/installerconfig] GETOPTS_STDARGS=[dD:SX]
 DEBUG: f_dialog_init: SECURE=[] USE_XDIALOG=[]
 DEBUG: f_dialog_init: dialog(1) API initialized.
 DEBUG: dialog.subr: Successfully loaded.
 DEBUG: f_include: file=[/usr/share/bsdconfig/variable.subr]
 DEBUG: Began Installation at Mon Oct  3 19:41:48 UTC 2022
 /usr/libexec/bsdinstall/script: 3: Bad file descriptor

identical configuration files but using 13.0 ISO works.

The ISO is constructed using something like

cp /home/pool/FreeBSD-13.1-RELEASE-amd64-disc1.iso /home/pool/m.freebsd-base.iso.tmp
sed -e 's;@@GATEWAY@@;192.168.234.1;' -e 's;@@POOLDIR@@;/home/pool;' -e 's;@@SOURCEDIR@@;/home/libreswan/wip-misc;' -e 's;@@LOCALDIR@@;/tmp/pool;' -e 's;@@TESTINGDIR@@;/home/libreswan/wip-misc/testi
ng;' -e 's;@@USER@@;1000;' -e 's;@@GROUP@@;107;' -e 's;@@PREFIX@@;m.;' \
	testing/libvirt/freebsd/base.conf \
	> /home/pool/m.freebsd-base.base.conf
growisofs -M /home/pool/m.freebsd-base.iso.tmp -l -R \
	-input-charset utf-8 \
	-graft-points \
	/boot/loader.conf=testing/libvirt/freebsd/loader.conf \
	/etc/installerconfig=/home/pool/m.freebsd-base.base.conf

and then booted under kvm using:

	sudo virt-install \
		--connect=qemu:///system --check=path_in_use=off --graphics=none --virt-type=kvm --noreboot --console=pty,target_type=serial --vcpus=4 --memory=5120  --cpu=host-passthrough --network
=network:swandefault,model=virtio --rng=type=random,device=/dev/random --security=type=static,model=dac,label='1000:107',relabel=yes --filesystem=target=pool,type=mount,accessmode=squash,source=/hom
e/pool \
		--name=m.freebsd-base \
		 --os-variant=freebsd13.1 \
		--disk=path=/home/pool/m.freebsd-base.qcow2,size=10,bus=virtio,format=qcow2 \
		--cdrom=/home/pool/m.freebsd-base.iso
Comment 1 John Grafton 2022-10-20 16:57:16 UTC
Can you provide more information about what's going into /etc/installerconfig?
Comment 2 Andrew Cagney 2022-10-20 19:14:16 UTC
Created attachment 237486 [details]
loader.conf (probably not interesting)
Comment 3 Andrew Cagney 2022-10-20 19:16:05 UTC
Created attachment 237487 [details]
base.conf

processed base.conf ready for adding to the CDROM
Comment 4 Andrew Cagney 2022-10-20 19:17:48 UTC
i.e., /etc/installerconfig ends up with the contents of base.conf
Comment 5 John Grafton 2022-10-21 18:29:30 UTC
This bug was fixed in CURRENT with this commit:

commit 1f7746d81f53447ac15cc99395bb714d4dd0a4da
Author: Corvin Köhne <CorvinK@beckhoff.com>
Date:   Tue May 3 16:00:09 2022 +0200

    bsdinstall: stop messing with file descriptors

    Throughout the bsdinstall script fd 3 is used by f_dprintf (set through
    $TERMINAL_STDOUT_PASSTHRU). By closing file descriptor 3 here, the
    final f_dprintf "Installation Completed ... does not work anymore.

    By putting the code into a subshell, file descriptors can be edited
    without interference with the calling script.

    Reviewed by:            emaste
    Differential Revision:  https://reviews.freebsd.org/D35113
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    MFC after:              3 days

It doesn't appear to have landed in 13.1-RELEASE yet.
Comment 6 John Grafton 2022-10-25 15:35:32 UTC
The commit referenced in the last comment should probably be merged into releng/13.1 since scripted installs fail at the complete message.  It's already in stable/13.
Comment 7 Graham Perrin freebsd_committer freebsd_triage 2022-11-11 05:25:03 UTC
<https://cgit.freebsd.org/src/log/?h=releng/13.1>

In the review, manu@ (FreeBSD Core Team) wrote: 

> …  This breaks scripted install for 13.1 …

stable/13: 

<https://github.com/freebsd/freebsd-src/commit/45eb93a964e669dabb1d7f59dadac23c4238f878>

> (cherry picked from commit 1f7746d)
Comment 8 John Grafton 2022-11-28 18:58:04 UTC
bump since scripted installs are still broken on releng/13.1.  The patch was MFC'd into stable/13 awhile ago and should be pulled into a release.
Comment 9 Emmanuel Vadot freebsd_committer freebsd_triage 2022-11-28 21:26:08 UTC
(In reply to John Grafton from comment #8)

We don't regenerate release image so you will have to wait for 13.2 to have the fix.
Comment 10 Graham Perrin freebsd_committer freebsd_triage 2023-04-01 17:06:50 UTC
Should the fix for this be mentioned in release notes for 13.2?
Comment 11 Andrew Cagney 2023-05-06 14:56:28 UTC
libreswan's switched to 13.2 for testing; thanks!