fw4: prefer /dev/stdin if available
authorJo-Philipp Wich <jo@mein.io>
Tue, 31 May 2022 18:55:36 +0000 (20:55 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 31 May 2022 18:55:36 +0000 (20:55 +0200)
commit210991df51587bdb736b4fc74b1200ec6cf6ecc7
treef907e3023c5ed846135e2bf3f23eddf67ac7c421
parent4e5e3226260a7a67dce325314d0926745727bab0
fw4: prefer /dev/stdin if available

The nftables executable treats `-` and `/dev/stdin` specially when processing
nft scripts from stdin; it will buffer the contents in order to be able to
print detailled error diagnostics. The `/proc/self/fd/0` path used by `fw4`
does not get this special treatment which will lead to nftables error
messages without any reported context.

Make the `fw4` executable prefer `/dev/stdin` in case it exists and fall back
to using `/proc/self/fd/0` as before.

Ref: https://github.com/openwrt/openwrt/issues/9927
Ref: https://git.openwrt.org/50bc06e774f89517f98c89c76a7626f35c3ff659
Ref: https://git.netfilter.org/nftables/tree/src/libnftables.c?h=v1.0.3#n733
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
root/sbin/fw4