summaryrefslogtreecommitdiff
path: root/etc/netstart
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2020-11-29 20:14:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2020-11-29 20:14:07 +0000
commitac2bd911058daacc24ff4291dbd1f64018e3f673 (patch)
tree56422725918aaeeaa358c373095cd2f16f7b68e3 /etc/netstart
parent4f6aad51caa8d959e443433a10864db45d1820c3 (diff)
Add support for !command to mygate, so that netstart has a late opportunity
to perform network configuration (for example, "!route source -ifp em0") Split mygate and myname manual pages (how did anyone ever believe these are related), and perform hostname configuration much earlier in rc. discussed with benno, claudio, jmc, etc etc, last version of !command parser by tb
Diffstat (limited to 'etc/netstart')
-rw-r--r--etc/netstart40
1 files changed, 21 insertions, 19 deletions
diff --git a/etc/netstart b/etc/netstart
index d70021d62f3..77ba43ccce4 100644
--- a/etc/netstart
+++ b/etc/netstart
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $OpenBSD: netstart,v 1.207 2020/11/08 16:51:43 jmc Exp $
+# $OpenBSD: netstart,v 1.208 2020/11/29 20:14:06 deraadt Exp $
# Turn off Strict Bourne shell mode.
set +o sh
@@ -177,27 +177,32 @@ ifmstart() {
# Usage: defaultroute
defaultroute() {
local _cmd;
+ set -o noglob
- ! $V4_DHCPCONF && stripcom /etc/mygate |
+ stripcom /etc/mygate |
while read gw; do
- [[ $gw == @(*:*) ]] && continue
- _cmd="route -qn add -host default $gw"
- if $PRINT_ONLY; then
- print -r -- "$_cmd" && break
- else
- $_cmd && break
- fi
- done
- ! $V6_AUTOCONF && stripcom /etc/mygate |
- while read gw; do
- [[ $gw == !(*:*) ]] && continue
- _cmd="route -qn add -host -inet6 default $gw"
+ case $gw in
+ '!'*)
+ _cmd=$(print -- "$gw" | sed 's/\$if/'$_if'/g')
+ _cmd="${_cmd#!}"
+ ;;
+ *)
+ if [[ $gw != @(*:*) ]]; then
+ $V4_DHCPCONF && continue
+ _cmd="route -qn add -host default $gw"
+ elif [[ $gw == @(*:*) ]]; then
+ $V6_AUTOCONF && continue
+ _cmd="route -qn add -host -inet6 default $gw"
+ fi
+ ;;
+ esac
if $PRINT_ONLY; then
- print -r -- "$_cmd" && break
+ print -r -- "$_cmd"
else
- $_cmd && break
+ $_cmd
fi
done
+ set +o noglob
}
# Make sure the invoking user has the right privileges. Check for presence of
@@ -241,9 +246,6 @@ fi
# Otherwise, process with the complete network initialization.
-# /etc/myname contains my symbolic name.
-[[ -f /etc/myname ]] && hostname "$(stripcom /etc/myname)"
-
# Set the address for the loopback interface. Bringing the interface up,
# automatically invokes the IPv6 address ::1.
ifconfig lo0 inet 127.0.0.1/8