diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-08-27 10:17:42 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-08-27 10:19:31 +0200 |
commit | 91fbeb4a926b8a75274d012a3994ef337dca51d9 (patch) | |
tree | b5738ff567d29c528690efa171fe52604bcd3be6 /src/wg-quick/openbsd.bash | |
parent | wg-quick: android: use iproute2 to bring up interface instead of ndc (diff) | |
download | wireguard-tools-91fbeb4a926b8a75274d012a3994ef337dca51d9.tar.xz wireguard-tools-91fbeb4a926b8a75274d012a3994ef337dca51d9.zip |
Revert "wg-quick: wait on process substitutions"
This reverts commit 26683f6c9ad18d9914b23312c221f27fd5ecab51, which
means the old problem comes back. That's an issue. But waiting on
process substitutions is not available with commonly used bash versions:
# wg-quick up demo
[#] ip link add demo type wireguard
[#] wg setconf demo /dev/fd/63
/usr/bin/wg-quick: line 251: wait: pid 2955 is not a child of this shell
[#] ip link delete dev demo
This means we have to wait a few years before fixing this issue. IOW,
bash limitation; can't fix.
Reported-by: Theodore Mozzo <theodore.mozzo@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/wg-quick/openbsd.bash')
-rwxr-xr-x | src/wg-quick/openbsd.bash | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/wg-quick/openbsd.bash b/src/wg-quick/openbsd.bash index f45027c..ffd1834 100755 --- a/src/wg-quick/openbsd.bash +++ b/src/wg-quick/openbsd.bash @@ -131,14 +131,14 @@ del_routes() { [[ -n $REAL_INTERFACE ]] || return 0 while read -r destination _ _ _ _ netif _; do [[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" ) - done < <(netstat -nr -f inet); wait $! + done < <(netstat -nr -f inet) for destination in "${todelete[@]}"; do cmd route -q -n delete -inet "$destination" || true done todelete=( ) while read -r destination gateway _ netif; do [[ $netif == "$REAL_INTERFACE" || ( $netif == lo* && $gateway == "$REAL_INTERFACE" ) ]] && todelete+=( "$destination" ) - done < <(netstat -nr -f inet6); wait $! + done < <(netstat -nr -f inet6) for destination in "${todelete[@]}"; do cmd route -q -n delete -inet6 "$destination" || true done @@ -189,9 +189,9 @@ set_mtu() { [[ ${BASH_REMATCH[1]} == *:* ]] && family=inet6 output="$(route -n get "-$family" "${BASH_REMATCH[1]}" || true)" [[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}" - done < <(wg show "$REAL_INTERFACE" endpoints); wait $! + done < <(wg show "$REAL_INTERFACE" endpoints) if [[ $mtu -eq 0 ]]; then - read -r output < <(route -n get default) || true + read -r output < <(route -n get default || true) || true [[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}" fi [[ $mtu -gt 0 ]] || mtu=1500 @@ -207,14 +207,14 @@ collect_gateways() { [[ $destination == default ]] || continue GATEWAY4="$gateway" break - done < <(netstat -nr -f inet); wait $! + done < <(netstat -nr -f inet) GATEWAY6="" while read -r destination gateway _; do [[ $destination == default ]] || continue GATEWAY6="$gateway" break - done < <(netstat -nr -f inet6); wait $! + done < <(netstat -nr -f inet6) } collect_endpoints() { @@ -222,7 +222,7 @@ collect_endpoints() { while read -r _ endpoint; do [[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue ENDPOINTS+=( "${BASH_REMATCH[1]}" ) - done < <(wg show "$REAL_INTERFACE" endpoints); wait $! + done < <(wg show "$REAL_INTERFACE" endpoints) } set_endpoint_direct_route() { @@ -290,7 +290,7 @@ monitor_daemon() { ifconfig "$REAL_INTERFACE" >/dev/null 2>&1 || break [[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route # TODO: set the mtu as well, but only if up - done < <(route -n monitor); wait $!) & disown + done < <(route -n monitor)) & disown } set_dns() { @@ -339,7 +339,7 @@ add_route() { } set_config() { - cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG"); wait $! + cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG") } save_config() { @@ -347,7 +347,7 @@ save_config() { new_config=$'[Interface]\n' { read -r _; while read -r _ _ network address _; do [[ $network == *Link* ]] || new_config+="Address = $address"$'\n' - done } < <(netstat -I "$REAL_INTERFACE" -n -v); wait $! + done } < <(netstat -I "$REAL_INTERFACE" -n -v) # TODO: actually determine current DNS for interface for address in "${DNS[@]}"; do new_config+="DNS = $address"$'\n' @@ -428,7 +428,7 @@ cmd_up() { set_mtu up_if set_dns - for i in $({ while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips); wait $!; } | sort -nr -k 2 -t /); do + for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do add_route "$i" done [[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route |