diff mbox series

[Patches] iptables and ip6tables: Warning on use of -L

Message ID 97c771aa-8ba0-8750-369f-5c68cf587cab@familie-kuntze.de
State RFC
Delegated to: Pablo Neira
Headers show
Series [Patches] iptables and ip6tables: Warning on use of -L | expand

Commit Message

Noel Kuntze March 30, 2018, 10:17 p.m. UTC
Hello List,

I wrote two patches (one for iptables and one for ip6tables) to warn when -L is used. It encourages the use of iptables-save instead.
You can find them attached to this mail. I'm not subscribed to the list, so please CC me in any answers or send to me directly, too.
The changes are so short, that not license should be required.

The call to isatty() could set errno, if stdin is not a tty. The patches don't set errno to 0, if isatty() failed.

Kind regards

Noel
diff mbox series

Patch

From 0bbb5033ee524f247f625126a32e92d4fb37f8c2 Mon Sep 17 00:00:00 2001
From: Noel Kuntze <noel@familie-kuntze.de>
Date: Fri, 30 Mar 2018 19:20:12 +0200
Subject: [PATCH 2/2] Print warning when using ip6tables -L/--list from a tty

---
 iptables/ip6tables.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index 49bd006f..e9052736 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -933,6 +933,10 @@  list_entries(const xt_chainlabel chain, int rulenum, int verbose, int numeric,
 	unsigned int format;
 	const char *this;
 
+	if (isatty(fileno(stdin))) {
+		fprintf(stderr, "Warning: do not use ip6tables to list the rules. Use ip6tables-save instead.\n");
+	}
+
 	format = FMT_OPTIONS;
 	if (!verbose)
 		format |= FMT_NOCOUNTS;
-- 
2.16.3