From a340aa6ca6cd08ae173fbb95cd3e65807264df07 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 15 Feb 2018 17:22:16 +0100 Subject: src: bail out when exporting ruleset with unsupported output Display error message and propagate error to shell when running command with unsupported output: # nft export ruleset json Error: this output type is not supported export ruleset json ^^^^^^^^^^^^^^^^^^^^ # echo $? 1 When displaying the output in json using the low-level VM representation, it shows: # nft export ruleset vm json ... low-level VM json output # echo $? 0 While at it, do the same with obsoleted XML output. Fixes: https://bugzilla.netfilter.org/show_bug.cgi?id=1224 Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 578bfdc1..56341115 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -1198,7 +1198,6 @@ import_cmd : RULESET markup_format struct markup *markup = markup_alloc($1); $$ = cmd_alloc(CMD_IMPORT, CMD_OBJ_MARKUP, &h, &@$, markup); } - | JSON { $$ = NULL; } ; export_cmd : RULESET markup_format @@ -1213,7 +1212,6 @@ export_cmd : RULESET markup_format struct markup *markup = markup_alloc($1); $$ = cmd_alloc(CMD_EXPORT, CMD_OBJ_MARKUP, &h, &@$, markup); } - | JSON { $$ = NULL; } ; monitor_cmd : monitor_event monitor_object monitor_format @@ -1241,10 +1239,10 @@ monitor_object : /* empty */ { $$ = CMD_MONITOR_OBJ_ANY; } monitor_format : /* empty */ { $$ = NFTNL_OUTPUT_DEFAULT; } | markup_format - | JSON { $$ = NFTNL_OUTPUT_JSON; } ; -markup_format : XML { $$ = NFTNL_OUTPUT_XML; } +markup_format : XML { $$ = __NFT_OUTPUT_NOTSUPP; } + | JSON { $$ = __NFT_OUTPUT_NOTSUPP; } | VM JSON { $$ = NFTNL_OUTPUT_JSON; } ; -- cgit v1.2.3