Bug 262262

Summary: bsdinstall: resolver configuration fails (is not automated) in some situations
Product: Base System Reporter: Graham Perrin <grahamperrin>
Component: binAssignee: Alfonso S. Siciliano <asiciliano>
Status: In Progress ---    
Severity: Affects Many People CC: asiciliano, emaste, freebsd
Priority: --- Keywords: install
Version: UnspecifiedFlags: grahamperrin: mfc-stable13?
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216130
Attachments:
Description Flags
Screenshot: FreeBSD installer: network configuration: resolver configuration: the search field and DNS fields are empty none

Description Graham Perrin freebsd_committer freebsd_triage 2022-03-01 07:49:55 UTC
Created attachment 232179 [details]
Screenshot: FreeBSD installer: network configuration: resolver configuration: the search field and DNS fields are empty

Steps
=====

1.  FreeBSD-13.1-PRERELEASE-amd64-20220224-9134a398506-249729-disc1.iso

2.  boot from the installer

3.  begin installation

4.  choose optional system components to install

    * impossible choices are permitted without forewarning (a separate bug)

5.  configure networking (IPv4, DHCP, not IPv6)

6.  observe the resolver configuration with automatically completed entries

7.  proceed beyond failures to fetch, beyond failure(s) to extract

8.  in the Abort dialogue, exit

9.  in the Welcome dialogue, install, proceed

10. refrain from choosing optional system components

11. proceed, observe installation, set the password for root

12. configure networking (IPv4, DHCP, not IPv6)

Bug
===

13. resolver configuration is not automated

----

Whilst FreeBSD-13.1-PRERELEASE-amd64-20220224-9134a398506-249729-disc1.iso (as an example) is novel, this is, I believe, a very old bug that has bitten me on many occasions. 

UX: not a good first impression of FreeBSD.
Comment 1 Alfonso S. Siciliano freebsd_committer freebsd_triage 2022-04-29 11:42:28 UTC
https://reviews.freebsd.org/D35094
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-04-30 15:35:55 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1ad9134e1112cec3bc29c9ae36b5e02526edb388

commit 1ad9134e1112cec3bc29c9ae36b5e02526edb388
Author:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
AuthorDate: 2022-04-30 15:25:57 +0000
Commit:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
CommitDate: 2022-04-30 15:34:53 +0000

    bsdinstall netconfig_ipv4: Fix resolv.conf rebuild

    After an installation restart (for error or choice) dhclient does not
    rebuild resolv.conf so `dialog --mixedform' of "Resolver Configuration"
    in bsdinstall/scripts/netconfig draws empty forms. It causes a bad UX,
    to see PR262262. Fixed resetting the interface before to run dhclient.

    PR:                     262262
    Reviewed by:            bapt
    Differential Revision:  https://reviews.freebsd.org/D35094

 usr.sbin/bsdinstall/scripts/netconfig_ipv4 | 3 +++
 1 file changed, 3 insertions(+)
Comment 3 Graham Perrin freebsd_committer freebsd_triage 2022-04-30 16:01:08 UTC
Thank you!
Comment 4 Winter 2022-06-20 04:16:49 UTC
How does dhclient know to update the resolv.conf file within $BSDINSTALL_TMPETC? I ask this since, as far as I can tell, it's not copied from /etc or anything before it's read by netconfig to populate the resolver configuration dialog.
Comment 5 Alfonso S. Siciliano freebsd_committer freebsd_triage 2022-06-21 11:21:20 UTC
Hi winter,

thanks for the report.

Probably your consideration is for the last part (about resolv.conf) of the comment in the script:

	# XXX: get interface down otherwise after installation restart
	# dhclient does not build a new resolv.conf (see PR262262).

because the commit solves the PR ("resolver configuration fails (is not automated) in some situations") by resetting the interface:

	ifconfig $INTERFACE down


Briefly.
You are right (my error). I described a consequence, not the actual problem. I'll update the comment to fix:

	# get interface down otherwise after an installation restart
	# dhclient fails starting an error chain.

I am also considering to delete the comment, Rationale below.
Do you have any preference for name and email in the commit message?

	Reported by: <name> <email>


Rationale.
bsdinstall(8) set up networking with some automatism to help the users. However after an installation restart (PR steps) an empty "Resolver Configuration" dialog form is built (PR screenshot).

The empty dialog is only a "piece" of an error "chain" (if I remember correctly): Restart installation -> dhclient in netconfig_ipv4 fails -> ifconfig in netconfig_ipv4 fails -> dialog in netconfig builds an empty --mixedform (filled before restarting) -> inconsistent resolv.conf (correct before restarting) -> no auto networking after reboot.
To fix just `ifconfig $INTERFACE down` before dhclient in netconfig_ipv4. So, my comment "XXX: get interface down otherwise after installation restart dhclient does not build a new resolv.conf (see PR262262)".

The Winters's Comment 4 notes: dhclient (in netconfig_ipv4) does not build resolv.conf, the file is built from a mixedform in netconfig, it is correct! Obviously my comment "dhclient does not build a new resolv.conf" makes a misunderstanding. It describes a possible consequence not the actual problem, I' ll update the comment to fix (above).

I wanted to solve soon and temporarily the PR to replace dialog with bsddialog without any issues existing in the script, to be sure bsddialog has not bugs with --mixedform. Indeed, I added "XXX" and "see PR262262" to remember to update/improve the fix following further investigation. However, netconfig and netconfig_ipv4 use bsddialog currently, I am quite sure getting down the interface is the correct way to reset it, reading ifconfig(8). Then the comment could be deleted now.


Conclusion.
I hope my explanation is understandable. Thanks for the report, I forgot the comment in netconfig_ipv4.


Alfonso
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2023-05-27 11:15:43 UTC
I encountered this bug in an installer for 13.2, it surprised me. 

Can we have a merge to stable/13, for inclusion in installers for 13.3?

Thanks