the gateway is read from the kernel table, because this job image has no ip command
Run 2355, image job: `ip: command not found`, exit 127 — the step that names the address died one line in, before the gate ever ran. /proc/net/route carries the same default route; its gateway is hex little-endian, and bash turns it back into a dotted quad with no helper at all (0100110A → 10.17.0.1).
This commit is contained in:
@@ -235,8 +235,12 @@ jobs:
|
||||
- name: Name the address the job can reach the published ports on
|
||||
run: |
|
||||
set -eu
|
||||
GW=$(ip route | awk '/default/ {print $3; exit}')
|
||||
[ -n "$GW" ] || { echo "no default route out of the job container"; exit 1; }
|
||||
# `ip` is not in this image (measured: `ip: command not found`, exit 127),
|
||||
# so the route is read from the kernel's own table. The gateway there is
|
||||
# hex, little-endian, and bash turns it back into dotted quad.
|
||||
GWHEX=$(awk '$2=="00000000" {print $3; exit}' /proc/net/route)
|
||||
[ -n "$GWHEX" ] || { echo "no default route in /proc/net/route"; exit 1; }
|
||||
GW=$(printf '%d.%d.%d.%d' "0x${GWHEX:6:2}" "0x${GWHEX:4:2}" "0x${GWHEX:2:2}" "0x${GWHEX:0:2}")
|
||||
echo "OPENWAF_EDGE_HOST=$GW" >> "$GITHUB_ENV"
|
||||
echo "the gate will ask the edge at $GW"
|
||||
|
||||
@@ -363,8 +367,12 @@ jobs:
|
||||
- name: Name the address the job can reach the published ports on
|
||||
run: |
|
||||
set -eu
|
||||
GW=$(ip route | awk '/default/ {print $3; exit}')
|
||||
[ -n "$GW" ] || { echo "no default route out of the job container"; exit 1; }
|
||||
# `ip` is not in this image (measured: `ip: command not found`, exit 127),
|
||||
# so the route is read from the kernel's own table. The gateway there is
|
||||
# hex, little-endian, and bash turns it back into dotted quad.
|
||||
GWHEX=$(awk '$2=="00000000" {print $3; exit}' /proc/net/route)
|
||||
[ -n "$GWHEX" ] || { echo "no default route in /proc/net/route"; exit 1; }
|
||||
GW=$(printf '%d.%d.%d.%d' "0x${GWHEX:6:2}" "0x${GWHEX:4:2}" "0x${GWHEX:2:2}" "0x${GWHEX:0:2}")
|
||||
echo "OPENWAF_EDGE_HOST=$GW" >> "$GITHUB_ENV"
|
||||
echo "the gate will ask the edge at $GW"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user