Instead of temporarily replacing host's connlabel.conf, make use of XT_CONNLABEL_CFG env variable to point the extension at a temporary file. Change extension test to copy the sample connlabel.conf there and modify that location instead of the host's one. Signed-off-by: Phil Sutter <phil@xxxxxx> --- extensions/.gitignore | 1 + extensions/libxt_connlabel.t | 13 +++---------- iptables-test.py | 2 ++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/extensions/.gitignore b/extensions/.gitignore index b1260f0b66469..64eaa4ecbb9e6 100644 --- a/extensions/.gitignore +++ b/extensions/.gitignore @@ -5,5 +5,6 @@ /GNUmakefile /initext.c /initext?.c +/libxt_connlabel.conf.tmp /matches.man /targets.man diff --git a/extensions/libxt_connlabel.t b/extensions/libxt_connlabel.t index aad1032b5a8bb..b6ef92f50fd09 100644 --- a/extensions/libxt_connlabel.t +++ b/extensions/libxt_connlabel.t @@ -1,18 +1,11 @@ :INPUT,FORWARD,OUTPUT -# Backup the connlabel.conf, then add some label maps for test -@[ -f /etc/xtables/connlabel.conf ] && mv /etc/xtables/connlabel.conf /tmp/connlabel.conf.bak -@mkdir -p /etc/xtables -@echo "40 bit40" > /etc/xtables/connlabel.conf -@echo "41 bit41" >> /etc/xtables/connlabel.conf -@echo "128 bit128" >> /etc/xtables/connlabel.conf +@cp -f extensions/libxt_connlabel.conf.test extensions/libxt_connlabel.conf.tmp -m connlabel --label "bit40";=;OK -m connlabel ! --label "bit40";=;OK -m connlabel --label "bit41" --set;=;OK -m connlabel ! --label "bit41" --set;=;OK -m connlabel --label "bit128";;FAIL -@echo > /etc/xtables/connlabel.conf +@echo > extensions/libxt_connlabel.conf.tmp -m connlabel --label "abc";;FAIL -@rm -f /etc/xtables/connlabel.conf +@rm -f extensions/libxt_connlabel.conf.tmp -m connlabel --label "abc";;FAIL -# Restore the original connlabel.conf -@[ -f /tmp/connlabel.conf.bak ] && mv /tmp/connlabel.conf.bak /etc/xtables/connlabel.conf diff --git a/iptables-test.py b/iptables-test.py index 532dee7c9000f..5855b985a082d 100755 --- a/iptables-test.py +++ b/iptables-test.py @@ -341,6 +341,8 @@ def main(): os.putenv("XTABLES_LIBDIR", os.path.abspath(EXTENSIONS_PATH)) os.putenv("PATH", "%s/iptables:%s" % (os.path.abspath(os.path.curdir), os.getenv("PATH"))) + os.putenv("XT_CONNLABEL_CFG", os.path.abspath("extensions") \ + + '/libxt_connlabel.conf.tmp') test_files = 0 tests = 0 -- 2.20.1