From a10282422b9386a2192c1603bad82b81dfcb46e7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 18 Dec 2011 16:24:36 +0100 Subject: sysctl: enable pattern matching with path Pattern matching support in `sysctl: implement --pattern option' commit did not work when variable path was defined, for example $ sysctl net.ipv4 -r arp.ignore gave no output. Reason being was tht the pattern was matched agains the specified argument and not the output variable list. Signed-off-by: Sami Kerola --- sysctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sysctl.c b/sysctl.c index ee03ee9..b4e0dea 100644 --- a/sysctl.c +++ b/sysctl.c @@ -164,11 +164,6 @@ static int ReadSetting(const char *restrict const name) { outname = xstrdup(name); slashdot(outname,'/','.'); /* change / to . */ - if (pattern && !pattern_match(outname, pattern)){ - free(outname); - return 0; - } - /* used to open the file */ tmpname = xmalloc(strlen(name)+strlen(PROC_PATH)+2); strcpy(tmpname, PROC_PATH); @@ -198,6 +193,11 @@ static int ReadSetting(const char *restrict const name) { goto out; } + if (pattern && !pattern_match(outname, pattern)){ + free(outname); + return 0; + } + fp = fopen(tmpname, "r"); if (!fp) { -- cgit v1.2.1