From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: fw@strlen.de, phil@nwl.cc
Subject: [PATCH nft,v2 1/5] main: consolidate EPERM to non-root users
Date: Thu, 9 Apr 2026 15:53:11 +0200 [thread overview]
Message-ID: <20260409135311.49221-1-pablo@netfilter.org> (raw)
Move the check added by 3cfb9e4b3e40 ("src: report EPERM for non-root users")
to the main function.
EPERM is also possible when removing a ruleset that is owned by a
process, tone it down to suggest that root is maybe needed.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
v2: handle EPERM from main, per Florian.
I'm not resending the entire series at this stage,
patch 2/5, 3/5, 4/5 and 5/5 got no changes.
src/libnftables.c | 7 +------
src/main.c | 2 ++
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/libnftables.c b/src/libnftables.c
index 66b03a1170bb..bc42c32de889 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -630,13 +630,8 @@ int nft_run_cmd_from_buffer(struct nft_ctx *nft, const char *buf)
parser_rc = rc;
rc = nft_evaluate(nft, &msgs, &cmds);
- if (rc < 0) {
- if (errno == EPERM) {
- fprintf(stderr, "%s (you must be root)\n",
- strerror(errno));
- }
+ if (rc < 0)
goto err;
- }
if (parser_rc) {
rc = parser_rc;
diff --git a/src/main.c b/src/main.c
index 29b0533dee7c..4cb51ff7f5fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -548,6 +548,8 @@ int main(int argc, char * const *argv)
goto out_fail;
}
+ if (rc && errno == EPERM)
+ fprintf(stderr, "Error: %s (perhaps you must be root?)\n", strerror(errno));
out:
nft_ctx_free(nft);
return rc;
--
2.47.3
next reply other threads:[~2026-04-09 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 13:53 Pablo Neira Ayuso [this message]
2026-04-09 14:00 ` [PATCH nft,v2 1/5] main: consolidate EPERM to non-root users Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409135311.49221-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.