Message ID | 20131011110235.2912.77468.stgit@nfdev.cica.es |
---|---|
State | Accepted |
Headers | show |
On Fri, Oct 11, 2013 at 01:03:08PM +0200, Arturo Borrero Gonzalez wrote: > Exit with NFT_EXIT_FAILURE if something went wrong in the netlink zone. > > Before this patch: > > # nft list chain filter asd ; echo $? > internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...] > > 0 > > After this patch: > > # nft list chain filter asd ; echo $? > internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...] > > 1 Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/src/main.c b/src/main.c index 3ddcb71..0c97120 100644 --- a/src/main.c +++ b/src/main.c @@ -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; }
Exit with NFT_EXIT_FAILURE if something went wrong in the netlink zone. Before this patch: # nft list chain filter asd ; echo $? internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...] 0 After this patch: # nft list chain filter asd ; echo $? 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> --- v2: assume NFT_EXIT_SUCCESS. Do return rc instead of exit(rc). src/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html