summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-07-10 14:54:09 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-07-14 18:10:25 +0200
commitb2ad9e5273248f76aacc0485e3c8f3310c83857a (patch)
treed223787a3729fdc2ba978c5526a85477133a5b2a /src
parent26b31033261427a3058a8fb994d54273bc93f7bf (diff)
main: return error to shell on evaluation problems
# nft add chain filter input { type filter hook inputt priority 0\; } <cmdline>:1:43-48: Error: unknown chain hook inputt add chain filter input { type filter hook inputt priority 0; } ^^^^^^ Before: # echo $? 0 After: # echo $? 1 Note that nft_parse() returns 1 on parsing errors and 0 + state->errs on evaluation problems, so return -1 as other functions do here to pass up the error to the main routine. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index bfe589a0..a2c4f87d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -230,15 +230,17 @@ int nft_run(void *scanner, struct parser_state *state, struct list_head *msgs)
int ret;
ret = nft_parse(scanner, state);
- if (ret != 0 || state->nerrs > 0)
- return -1;
+ if (ret != 0 || state->nerrs > 0) {
+ ret = -1;
+ goto err1;
+ }
retry:
ret = nft_netlink(state, msgs);
if (ret < 0 && errno == EINTR) {
netlink_restart();
goto retry;
}
-
+err1:
list_for_each_entry_safe(cmd, next, &state->cmds, list) {
list_del(&cmd->list);
cmd_free(cmd);