summaryrefslogtreecommitdiffstats
path: root/iptables/iptables-restore.c
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2020-04-21 01:15:42 -0700
committerPablo Neira Ayuso <pablo@netfilter.org>2020-05-11 14:08:24 +0200
commit1fd8d5f2e1577496f5431099589bd638ef5d5997 (patch)
tree5ca66b9670ffdd69d1c27ca0f0684350d85eb489 /iptables/iptables-restore.c
parent9dd0c484767c9fa3852b23c790d3d5e84e510beb (diff)
iptables: flush stdout after every verbose log.
Ensures that each logged line is flushed to stdout after it's written, and not held in any buffer. Places to modify found via: git grep -C5 'fputs[(]buffer, stdout[)];' On Android iptables-restore -v is run as netd daemon's child process and fed actions via pipe. '#PING' is used to verify the child is still responsive, and thus needs to be unbuffered. Luckily if you're running iptables-restore in verbose mode you probably either don't care about performance or - like Android - actually need this. Test: builds, required on Android for ip6?tables-restore netd subprocess health monitoring. Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/iptables-restore.c')
-rw-r--r--iptables/iptables-restore.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index b0a51d49..fea04842 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -178,8 +178,10 @@ ip46tables_restore_main(const struct iptables_restore_cb *cb,
if (buffer[0] == '\n')
continue;
else if (buffer[0] == '#') {
- if (verbose)
+ if (verbose) {
fputs(buffer, stdout);
+ fflush(stdout);
+ }
continue;
} else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) {
if (!testing) {