From f472d90b141d0e9f0c1033012d6d2be1338b7b1f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 7 Sep 2015 17:09:45 +0200 Subject: flowtop: Don't attempt to set sysctl values if initial read fails Bail out early if we fail to read the current sysctl variable values for net/netfilter/nf_conntrack_acct and net/netfilter/nf_conntrack_timestamp Otherwise we'll not be able restore the previous value on exit/panic. Moreover, if we fail to read the sysctl file, we usually also lack the permissions to write it. Signed-off-by: Tobias Klauser --- flowtop.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'flowtop.c') diff --git a/flowtop.c b/flowtop.c index 0d36a0a..9df4bdb 100644 --- a/flowtop.c +++ b/flowtop.c @@ -1132,6 +1132,7 @@ static void conntrack_acct_enable(void) if (sysctl_get_int("net/netfilter/nf_conntrack_acct", &sysctl.nfct_acct)) { fprintf(stderr, "Can't read net/netfilter/nf_conntrack_acct: %s\n", strerror(errno)); + return; } if (sysctl.nfct_acct == 1) @@ -1148,6 +1149,7 @@ static void conntrack_tstamp_enable(void) if (sysctl_get_int("net/netfilter/nf_conntrack_timestamp", &sysctl.nfct_tstamp)) { fprintf(stderr, "Can't read net/netfilter/nf_conntrack_timestamp: %s\n", strerror(errno)); + return; } if (sysctl.nfct_tstamp == 1) -- cgit v1.2.3-54-g00ecf