From 69d3b5254777d7202449b40d7e1ade89ab1dc859 Mon Sep 17 00:00:00 2001 From: rpe Date: Wed, 21 Feb 2018 19:54:25 +0000 Subject: [PATCH] If there is one interface, and it is configured via dhcp, and the lease contains both domain-name and domain-search options make sure to use the first domain-name entry (there might be multiple). This issue was noticed by Raf Czlonka, thanks for reporting Discussed with, tested and OK krw --- 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 740064a86a8..839ac13cbe5 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.1063 2018/02/18 01:50:04 kn Exp $ +# $OpenBSD: install.sub,v 1.1064 2018/02/21 19:54:25 rpe Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer @@ -251,7 +251,9 @@ __EOT lease_value() { local _lf=$1 _o + [[ -s $_lf ]] || return shift + for _o; do sed -E \ -e '/^ *(option )?'"$_o"' (.*);$/!d;s//\2/' \ @@ -1999,6 +2001,12 @@ donetconfig() { # configured via dhclient too. resp="${_dn:-$(get_fqdn)}" if ifconfig dhcp >/dev/null 2>&1 && [[ $NIFS == 1 && -n $_dn ]]; then + # If we have a 'domain-name' option in the lease file use that. + # It might *NOT* not be the same as the first domain in any + # 'domain-search' option. + set -- $(get_ifs dhcp) + set -- $(lease_value /var/db/dhclient.leases.$1 domain-name) + [[ -n $1 ]] && resp=$1 echo "Using DNS domainname $resp" else ask "DNS domain name? (e.g. 'example.com')" "$resp" -- 2.20.1