From 0f2ba939fd508fc41a870aa9ee1dc8f5fdd278b1 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 1 Oct 2026 19:29:04 +0000 Subject: [PATCH] Iterate the gateway's UDP socket inodes from a variable shellcheck reports SC2013 on the for loop over a command substitution in gateway_dns_held_by, and the OpenWrt Package workflow fails its lint step on it. Capture the awk output in a variable and iterate that instead; the words the loop sees are the same. cat stays in front of awk because busybox awk gives up on a missing /proc/net/udp6, and a while-read loop at the end of the pipe would run in a subshell under ash, where returning from the function is not possible. --- packaging/openwrt-ipk/files/etc/init.d/fips-gateway | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packaging/openwrt-ipk/files/etc/init.d/fips-gateway b/packaging/openwrt-ipk/files/etc/init.d/fips-gateway index bc897b79..4d577455 100755 --- a/packaging/openwrt-ipk/files/etc/init.d/fips-gateway +++ b/packaging/openwrt-ipk/files/etc/init.d/fips-gateway @@ -185,11 +185,15 @@ dns_locked() { # is among the process's open descriptors. Another process holding the port, # such as an mDNS responder on 5353, does not count. gateway_dns_held_by() { - local hex inode fd + local hex inodes inode fd [ -n "$2" ] || return 1 hex="$(printf '%04X' "$1")" - for inode in $(cat /proc/net/udp /proc/net/udp6 2>/dev/null | - awk -v want=":$hex" 'substr($2, length($2) - 4) == want { print $10 }'); do + # cat rather than awk's own file arguments: busybox awk gives up on a + # missing /proc/net/udp6. A while-read loop on the pipe would run in a + # subshell under ash, where the return below could not leave this function. + inodes="$(cat /proc/net/udp /proc/net/udp6 2>/dev/null | + awk -v want=":$hex" 'substr($2, length($2) - 4) == want { print $10 }')" + for inode in $inodes; do for fd in /proc/"$2"/fd/*; do [ "$(readlink "$fd" 2>/dev/null)" = "socket:[$inode]" ] && return 0 done