Skip to contentSkip to conversation

Make iptables-restore usable over a pipe

PATCH Applied Henrik Nordstrom 2 participants 2 messages May 12, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Make iptables-restore usable over a pipe

The attached patch flushes stdout between commands to make output operations (-L etc) in iptables-restore usable over a pipe. stdio by defaut buffers output if not connected to a terminal.

Regards
Henrik

ip6tables-restore.c +1 -0
Index: iptables/ip6tables-restore.c
===================================================================
@@ -436,6 +436,7 @@ int main(int argc, char *argv[])
 					 &newargv[2], &handle);
 
 			free_argv();
+			fflush(stdout);
 		}
 		if (!ret) {
 			fprintf(stderr, "%s: line %u failed\n",
iptables-restore.c +1 -0
Index: iptables/iptables-restore.c
===================================================================
@@ -442,6 +442,7 @@ main(int argc, char *argv[])
 					 &newargv[2], &handle);
 
 			free_argv();
+			fflush(stdout);
 		}
 		if (tablename && (strcmp(tablename, curtable) != 0))
 			continue;
#1 lore raw
Quoted 3 lines · Henrik Nordstrom

The attached patch flushes stdout between commands to make output operations (-L etc) in iptables-restore usable over a pipe. stdio by defaut buffers output if not connected to a terminal.

Applied, thanks.