]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
main: propagate error to shell
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 22 Jul 2014 23:07:34 +0000 (01:07 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 25 Jul 2014 01:41:17 +0000 (03:41 +0200)
Before:

 # nft add rule ip test input ip hdrlength 3
 <cmdline>:1:1-37: Error: Could not process rule: Invalid argument
 add rule ip test input ip hdrlength 3
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 # echo $?
 0

After:

 # nft add rule ip test input ip hdrlength 3
 <cmdline>:1:1-37: Error: Could not process rule: Invalid argument
 add rule ip test input ip hdrlength 3
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 # echo $?
 1

Reported-by: Ana Rey Botello <anarey@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/main.c

index bd8feee5ec1b89bf5eb29d4cba8cc87ff66c767b..04a98e3553610228437d9709d4289691be91433a 100644 (file)
@@ -200,6 +200,8 @@ static int nft_netlink(struct parser_state *state, struct list_head *msgs)
                                netlink_io_error(&ctx, &cmd->location,
                                                 "Could not process rule: %s",
                                                 strerror(err->err));
+                               ret = -1;
+                               errno = err->err;
                                if (err->seqnum == cmd->seqnum) {
                                        mnl_err_list_free(err);
                                        break;