diff options
author | Phil Sutter <phil@nwl.cc> | 2022-01-18 22:39:08 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-01-20 11:39:30 +0100 |
commit | 26ecdf53960658771c0fc582f72a4025e2887f75 (patch) | |
tree | bf88b64f89db8e71653dbd2050190587f0105bc3 /iptables/nft.c | |
parent | b32ae771c8cd7f0b72e4e21cd7d388c745fbae41 (diff) |
xshared: Fix response to unprivileged users
Expected behaviour in both variants is:
* Print help without error, append extension help if -m and/or -j
options are present
* Indicate lack of permissions in an error message for anything else
With iptables-nft, this was broken basically from day 1. Shared use of
do_parse() then somewhat broke legacy: it started complaining about
inability to create a lock file.
Fix this by making iptables-nft assume extension revision 0 is present
if permissions don't allow to verify. This is consistent with legacy.
Second part is to exit directly after printing help - this avoids having
to make the following code "nop-aware" to prevent privileged actions.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r-- | iptables/nft.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index 72f7cf13..b5de687c 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -3312,6 +3312,11 @@ int nft_compatible_revision(const char *name, uint8_t rev, int opt) err: mnl_socket_close(nl); + /* pretend revision 0 is valid if not permitted to check - + * this is required for printing extension help texts as user */ + if (ret < 0 && errno == EPERM && rev == 0) + return 1; + return ret < 0 ? 0 : 1; } |