* [nft PATCH 0/2] Improve a few minor JSON glitches
@ 2019-06-24 17:10 Phil Sutter
2019-06-24 17:10 ` [nft PATCH 1/2] json: Print newline at end of list output Phil Sutter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Phil Sutter @ 2019-06-24 17:10 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
As suggested offline, print newline at end of JSON output (patch 1) and
don't ignore -j flag if JSON support is not compiled-in - bail instead
(patch 2).
Phil Sutter (2):
json: Print newline at end of list output
main: Bail if non-available JSON was requested
src/json.c | 2 ++
src/main.c | 3 +++
2 files changed, 5 insertions(+)
--
2.21.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [nft PATCH 1/2] json: Print newline at end of list output
2019-06-24 17:10 [nft PATCH 0/2] Improve a few minor JSON glitches Phil Sutter
@ 2019-06-24 17:10 ` Phil Sutter
2019-06-24 17:10 ` [nft PATCH 2/2] main: Bail if non-available JSON was requested Phil Sutter
2019-06-25 0:17 ` [nft PATCH 0/2] Improve a few minor JSON glitches Pablo Neira Ayuso
2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2019-06-24 17:10 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
If listing ruleset elements with '-j' flag, print a final newline to not
upset shell prompts.
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/json.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/json.c b/src/json.c
index 4e64684201638..1484c21be819a 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1752,6 +1752,8 @@ int do_command_list_json(struct netlink_ctx *ctx, struct cmd *cmd)
root = json_pack("{s:o}", "nftables", root);
json_dumpf(root, ctx->nft->output.output_fp, 0);
json_decref(root);
+ fprintf(ctx->nft->output.output_fp, "\n");
+ fflush(ctx->nft->output.output_fp);
return 0;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [nft PATCH 2/2] main: Bail if non-available JSON was requested
2019-06-24 17:10 [nft PATCH 0/2] Improve a few minor JSON glitches Phil Sutter
2019-06-24 17:10 ` [nft PATCH 1/2] json: Print newline at end of list output Phil Sutter
@ 2019-06-24 17:10 ` Phil Sutter
2019-06-25 0:17 ` [nft PATCH 0/2] Improve a few minor JSON glitches Pablo Neira Ayuso
2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2019-06-24 17:10 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
If user passes '-j' flag, falling back to standard syntax output
probably causes more harm than good so instead print an error message
and exit(1).
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main.c b/src/main.c
index 9a50f30f850b2..cbfd69a42d045 100644
--- a/src/main.c
+++ b/src/main.c
@@ -277,6 +277,9 @@ int main(int argc, char * const *argv)
case OPT_JSON:
#ifdef HAVE_LIBJANSSON
output_flags |= NFT_CTX_OUTPUT_JSON;
+#else
+ fprintf(stderr, "JSON support not compiled-in\n");
+ exit(EXIT_FAILURE);
#endif
break;
case OPT_GUID:
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [nft PATCH 0/2] Improve a few minor JSON glitches
2019-06-24 17:10 [nft PATCH 0/2] Improve a few minor JSON glitches Phil Sutter
2019-06-24 17:10 ` [nft PATCH 1/2] json: Print newline at end of list output Phil Sutter
2019-06-24 17:10 ` [nft PATCH 2/2] main: Bail if non-available JSON was requested Phil Sutter
@ 2019-06-25 0:17 ` Pablo Neira Ayuso
2 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-06-25 0:17 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Mon, Jun 24, 2019 at 07:10:36PM +0200, Phil Sutter wrote:
> As suggested offline, print newline at end of JSON output (patch 1) and
> don't ignore -j flag if JSON support is not compiled-in - bail instead
> (patch 2).
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-25 0:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-24 17:10 [nft PATCH 0/2] Improve a few minor JSON glitches Phil Sutter
2019-06-24 17:10 ` [nft PATCH 1/2] json: Print newline at end of list output Phil Sutter
2019-06-24 17:10 ` [nft PATCH 2/2] main: Bail if non-available JSON was requested Phil Sutter
2019-06-25 0:17 ` [nft PATCH 0/2] Improve a few minor JSON glitches Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).