From 13c27aa6861b5ddf2842a257786779b4fea490af Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 12 Mar 2021 11:32:03 +0000 Subject: [PATCH] Emulate "[inet] autoconf" hostname.if(5) lines with "dhcp" With dhcpleased(8) in base, netstart(8) and ifconfig(8) understand both "autoconf" and "inet autoconf" lines in hostname.if(5) files to signal the new daemon. The installer however currently has only dhclient(8), hence manual upgrades with "[inet] autoconf" instead of "dhcp" in hostname.if files would fail to establish IPv4 connectivity. Make install.sub's netstart clone treat autoconf lines like old fashioned dhcp lines such users^Wearly testers of the new approach don't get stuck in nyetwork land. Note that this is only relevant for manual upgrades; installation always creates working hostname.if files and automated upgrades with sysupgrade(8) do not care about network/hostname.if files. Idea from deraadt OK deraadt krw ajacoutot --- distrib/miniroot/install.sub | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 4bef00617cc..81b001f7029 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.1161 2021/01/30 18:21:06 krw Exp $ +# $OpenBSD: install.sub,v 1.1162 2021/03/12 11:32:03 kn Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer @@ -2343,6 +2343,14 @@ parse_hn_line() { ifconfig $_if inet6 >/dev/null 2>&1 && _has_inet6=true [[ -x /sbin/dhclient ]] && _has_dhclient=true + # XXX Reverse when dhcpleased is made the default. + if { [[ ${_c[_af]} == inet ]] && [[ ${_c[_name]} == autoconf ]]; } || + { [[ ${_c[_af]} == autoconf ]]; }; then + # emulate "[inet] autoconf" with "dhcp" + [[ ${_c[_af]} == inet ]] && shift 2 || shift 1 + set -A _c -- dhcp "$@" + fi + case ${_c[_af]} in ''|*([[:blank:]])'#'*) return -- 2.20.1