From cb7e02f44d6a6fd1c6001e23cecb3d7534110617 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado Gomez" Date: Tue, 4 Aug 2020 12:38:46 +0200 Subject: src: enable json echo output when reading native syntax This patch fixes a bug in which nft did not print any output when specifying --echo and --json and reading nft native syntax. This patch respects behavior when input is json, in which the output would be the identical input plus the handles. Adds a json_echo member inside struct nft_ctx to build and store the json object containing the json command objects, the object is built using a mock monitor to reuse monitor json code. This json object is only used when we are sure we have not read json from input. [ added json_alloc_echo() to compile without json support --pablo ] Fixes: https://bugzilla.netfilter.org/show_bug.cgi?id=1446 Signed-off-by: Jose M. Guisado Gomez Tested-by: Eric Garver Signed-off-by: Pablo Neira Ayuso --- include/nftables.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/nftables.h') diff --git a/include/nftables.h b/include/nftables.h index 3556728d..9095ff3d 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -122,6 +122,7 @@ struct nft_ctx { void *scanner; struct scope *top_scope; void *json_root; + json_t *json_echo; }; enum nftables_exit_codes { -- cgit v1.2.3