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>
parser_rc = rc;
rc = nft_evaluate(nft, &msgs, &cmds);
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 (parser_rc) {
rc = parser_rc;
if (parser_rc) {
rc = parser_rc;
+ if (rc && errno == EPERM)
+ fprintf(stderr, "Error: %s (perhaps you must be root?)\n", strerror(errno));
out:
nft_ctx_free(nft);
return rc;
out:
nft_ctx_free(nft);
return rc;