#!/bin/ksh
-# $OpenBSD: install.sub,v 1.1166 2021/07/05 13:56:24 jca Exp $
+# $OpenBSD: install.sub,v 1.1167 2021/07/16 15:25:31 florian Exp $
#
# Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback
# Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org>
for _o; do
sed -E \
- -e '/^ *(option )?'"$_o"' (.*);$/!d;s//\2/' \
+ -e '/^'"$_o"': (.*)$/!d;s//\1/' \
-e '/^"(.*)"$/{s//\1/;s/\\(.)/\1/g;};q' "$_lf" \
| grep ^ && return
done
[[ -f $_rf ]] && cp $_rf /tmp/ai/ai.$AI_MODE.conf && return
for _if in ''; do
- [[ -x /sbin/dhclient ]] || break
+ [[ -x /sbin/dhcpleased ]] || break
# Select a network interface for initial dhcp request.
# Prefer the interface the system netbooted from.
done
# Issue initial dhcp request via the found interface.
- [[ -n $_if ]] && dhclient $_if || break
- _lf=/var/db/dhclient.leases.$_if
+ [[ -n $_if ]] && ifconfig $_if inet autoconf || break
+ _lf=/var/db/dhcpleased/$_if
if ! wait_for_dhcp_info $_if 30; then
echo "No dhcp address on interface $_if in 30 seconds."
if unpriv ftp -Vo - "$_url" \
>"/tmp/ai/ai.$AI_MODE.conf" 2>/dev/null; then
ifconfig $_if delete down 2>/dev/null
+ rm /var/db/dhcpleased/$_if
return 0
fi
done
ifconfig $_if group dhcp >/dev/null 2>&1
- if [[ -x /sbin/dhclient ]]; then
- /sbin/dhclient $_if
+ if [[ -x /sbin/dhcpleased ]]; then
+ ifconfig $_if inet autoconf
+ if ! wait_for_dhcp_info $_if 30; then
+ echo "No dhcp address on interface $_if in 30 seconds."
+ fi
+
else
- echo "DHCP leases not available during install - no /sbin/dhclient."
+ echo "DHCP leases not available during install."
fi
# Move resolv.conf to where it will be copied to the installed system.
# Wait until there is a leases file to parse.
while (( _secs > 0 )); do
- [[ -s /var/db/dhclient.leases.$_if ]] && break
+ [[ -s /var/db/dhcpleased/$_if ]] && break
sleep 1
(( _secs-- ))
done
sed -En 's/^default +([0-9.]+) .* ([a-z0-9]+) *$/\1 \2/p')
[[ -n $1 ]] && _dr=$1 _dr_if=$2
- # Don't ask if a default route exits and is handled by dhclient.
+ # Don't ask if a default route exits and is handled by dhcp.
[[ -n $_dr ]] && isin "$_dr_if" $(get_ifs dhcp) && return
while :; do
# interface and if it's managed by dhclient and if the domain name is
# configured via dhclient too.
resp="${_dn:-$(get_fqdn)}"
- if ifconfig dhcp >/dev/null 2>&1 && [[ $NIFS == 1 && -n $_dn ]]; then
+ if ifconfig dhcp >/dev/null 2>&1 && [[ $NIFS == 1 && -z $_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)
+ set -- $(lease_value /var/db/dhcpleased/$1 domain-name)
[[ -n $1 ]] && resp=$1
echo "Using DNS domainname $resp"
else
hostname "$(hostname -s).$resp"
# Get & add nameservers to /tmp/i/resolv.conf. Don't ask if there's only
- # one configured interface and if it's managed by dhclient and if the
- # nameserver is configured via dhclient too.
+ # one configured interface and if it's managed by dhcp and if the
+ # nameserver is configured via dhcp too.
resp="${_ns:-none}"
if ifconfig dhcp >/dev/null 2>&1 && [[ $NIFS == 1 && -n $_ns ]]; then
echo "Using DNS nameservers at $resp"
# Fill the _cmds array with the resulting interface configuration commands.
parse_hn_line() {
local _af=0 _name=1 _mask=2 _bc=3 _prefix=2 _c _cmd _prev _daddr _dhcp _i
- local _has_dhclient=false _has_inet6=false
+ local _has_dhcp=false _has_inet6=false
set -A _c -- "$@"
set -o noglob
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
+ [[ -x /sbin/dhcpleased ]] && _has_dhcp=true
case ${_c[_af]} in
''|*([[:blank:]])'#'*)
_c[_name]="${_c[_name]} $_daddr"
_cmds[$_prev]="${_c[@]}"
;;
- dhcp) ! $_has_dhclient && return
- unset _c[0]
- _i=1
- while [[ ${_c[$_i]} == @(-c|-d|-i|-n|-r|-v) ]]; do
- if [[ ${_c[$_i]} == @(-c|-i) ]]; then
- _dhcp[${#_dhcp[*]}]=${_c[$_i]}
- unset _c[$_i]
- (( _i++ ))
- fi
- _dhcp[${#_dhcp[*]}]=${_c[$_i]}
- unset _c[$_i]
- (( _i++ ))
- done
- ((${#_c[*]} > 0)) && _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
- _cmds[${#_cmds[*]}]="dhclient ${_dhcp[@]} $_if"
+ dhcp) ! $_has_dhcp && return
+ _cmds[${#_cmds[*]}]="ifconfig $_if inet autoconf"
V4_DHCPCONF=true
;;
'!'*|bridge)
echo -n "Saving configuration files..."
# Save any leases obtained during install.
- (cd /var/db; for _f in dhclient.leases.*; do
- [[ -f $_f ]] && mv $_f /mnt/var/db/.
+ (cd /var/db/dhcpleased; for _f in *; do
+ [[ -f $_f ]] && mv $_f /mnt/var/db/dhcpleased/.
done)
# Move configuration files from /tmp/i/ to /mnt/etc.