diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-12-23 17:22:08 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-12-23 17:22:08 +0000 |
commit | 33403602155c5c10703348606759f370e444143c (patch) | |
tree | 1a03018c78db89b45e6de5177bc4b0d38144c021 | |
parent | 4b2a73e464a8f6ec30a8a8db0514ee4520180f42 (diff) |
Allow the provision of dhclient(8) options on 'dhcp' lines in hostname.if(5)
files.
Usual man page help & ok jmc@
-rw-r--r-- | distrib/miniroot/install.sub | 21 | ||||
-rw-r--r-- | etc/netstart | 21 | ||||
-rw-r--r-- | share/man/man5/hostname.if.5 | 16 |
3 files changed, 42 insertions, 16 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index c213a397191..b846ac5adf0 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.1159 2020/12/21 16:52:49 krw Exp $ +# $OpenBSD: install.sub,v 1.1160 2020/12/23 17:22:07 krw Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org> @@ -2335,7 +2335,7 @@ get_rootinfo() { # Parse and "unpack" a hostname.if(5) line given as positional parameters. # 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 + local _af=0 _name=1 _mask=2 _bc=3 _prefix=2 _c _cmd _prev _daddr _dhcp _i local _has_dhclient=false _has_inet6=false set -A _c -- "$@" set -o noglob @@ -2378,9 +2378,20 @@ parse_hn_line() { _cmds[$_prev]="${_c[@]}" ;; dhcp) ! $_has_dhclient && return - _c[0]="ifconfig $_if" - ((${#_c[*]} > 1)) && _cmds[${#_cmds[*]}]="${_c[@]}" - _cmds[${#_cmds[*]}]="dhclient $_if" + 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" V4_DHCPCONF=true ;; '!'*|bridge) diff --git a/etc/netstart b/etc/netstart index c5743c530ef..46b0ef46d0a 100644 --- a/etc/netstart +++ b/etc/netstart @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: netstart,v 1.210 2020/12/21 16:52:49 krw Exp $ +# $OpenBSD: netstart,v 1.211 2020/12/23 17:22:07 krw Exp $ # Turn off Strict Bourne shell mode. set +o sh @@ -27,7 +27,7 @@ stripcom() { # Parse and "unpack" a hostname.if(5) line given as positional parameters. # 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 + local _af=0 _name=1 _mask=2 _bc=3 _prefix=2 _c _cmd _prev _daddr _dhcp _i set -A _c -- "$@" set -o noglob @@ -63,9 +63,20 @@ parse_hn_line() { _c[_name]="${_c[_name]} $_daddr" _cmds[$_prev]="${_c[@]}" ;; - dhcp) _c[0]="ifconfig $_if" - ((${#_c[*]} > 1)) && _cmds[${#_cmds[*]}]="${_c[@]}" - _cmds[${#_cmds[*]}]="dhclient $_if" + dhcp) 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" V4_DHCPCONF=true ;; '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g') diff --git a/share/man/man5/hostname.if.5 b/share/man/man5/hostname.if.5 index 103e89b0d9c..055a03e771b 100644 --- a/share/man/man5/hostname.if.5 +++ b/share/man/man5/hostname.if.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: hostname.if.5,v 1.72 2020/12/22 17:18:09 jmc Exp $ +.\" $OpenBSD: hostname.if.5,v 1.73 2020/12/23 17:22:07 krw Exp $ .\" $NetBSD: hosts.5,v 1.4 1994/11/30 19:31:20 jtc Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)hosts.5 8.2 (Berkeley) 12/11/93 .\" -.Dd $Mdocdate: December 22 2020 $ +.Dd $Mdocdate: December 23 2020 $ .Dt HOSTNAME.IF 5 .Os .Sh NAME @@ -231,15 +231,19 @@ with dynamic addresses. .Pp For IPv4 dynamic addressing using DHCP, the literal string .Dq dhcp -followed by any options to be passed to -.Xr ifconfig 8 . +followed first by +.Xr dhclient 8 +options and then by +.Xr ifconfig 8 +options. Note that .Xr ifconfig 8 is executed before .Xr dhclient 8 . .Bd -ragged -offset indent .Li dhcp -.Op Va options +.Op Va dhclient_options +.Op Va ifconfig_options .Ed .Pp For IPv6 stateless address autoconfiguration the literal string @@ -251,7 +255,7 @@ Note that must also be enabled. .Bd -ragged -offset indent .Li inet6 autoconf -.Op Va options +.Op Va ifconfig_options .Ed .Sh BRIDGE INTERFACE CONFIGURATION If the network interface is a bridge, the options described in |