]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: fix return code
authorArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Fri, 11 Oct 2013 11:03:08 +0000 (13:03 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 17 Oct 2013 09:08:40 +0000 (11:08 +0200)
Exit with NFT_EXIT_FAILURE if something went wrong in the netlink code.

Before this patch:

internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...]

0

After this patch:

internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...]

1

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/main.c

index 3ddcb7133752a5a410c0f985ccebc57c8180d583..0c97120b2345e3aa6770a5e7fc202b8d16ea946d 100644 (file)
@@ -222,7 +222,7 @@ int main(int argc, char * const *argv)
        char *buf = NULL, *filename = NULL;
        unsigned int len;
        bool interactive = false;
-       int i, val;
+       int i, val, rc = NFT_EXIT_SUCCESS;
 
        while (1) {
                val = getopt_long(argc, argv, OPTSTRING, options, NULL);
@@ -318,11 +318,12 @@ int main(int argc, char * const *argv)
                exit(NFT_EXIT_FAILURE);
        }
 
-       nft_run(scanner, &state, &msgs);
+       if (nft_run(scanner, &state, &msgs) != 0)
+               rc = NFT_EXIT_FAILURE;
 out:
        scanner_destroy(scanner);
        erec_print_list(stdout, &msgs);
 
        xfree(buf);
-       return 0;
+       return rc;
 }