[iptables PATCH 3/5] extensions: connlabel: Allow connlabel.conf override

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check for environment variable XT_CONNLABEL_CFG and if set use its value
as path to connlabel.conf.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 extensions/libxt_connlabel.c   | 6 ++++--
 extensions/libxt_connlabel.man | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/extensions/libxt_connlabel.c b/extensions/libxt_connlabel.c
index d06bb27a7c2e9..9a2f9ce34647e 100644
--- a/extensions/libxt_connlabel.c
+++ b/extensions/libxt_connlabel.c
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <xtables.h>
 #include <linux/netfilter/xt_connlabel.h>
 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
@@ -39,11 +40,12 @@ static void connlabel_open(void)
 	if (map)
 		return;
 
-	map = nfct_labelmap_new(NULL);
+	fname = getenv("XT_CONNLABEL_CFG") ?: nfct_labels_get_path();
+
+	map = nfct_labelmap_new(fname);
 	if (map != NULL)
 		return;
 
-	fname = nfct_labels_get_path();
 	if (errno) {
 		xtables_error(RESOURCE_PROBLEM,
 			"cannot open %s: %s", fname, strerror(errno));
diff --git a/extensions/libxt_connlabel.man b/extensions/libxt_connlabel.man
index bdaa51e8b033f..c6312a88ed35c 100644
--- a/extensions/libxt_connlabel.man
+++ b/extensions/libxt_connlabel.man
@@ -19,6 +19,8 @@ option was negated).
 .PP
 This match depends on libnetfilter_conntrack 1.0.4 or later.
 Label translation is done via the \fB/etc/xtables/connlabel.conf\fP configuration file.
+To use label names defined in a different file, \fBXT_CONNLABEL_CFG\fP
+environment variable may be set to the full path of that file.
 .PP
 Example:
 .IP
-- 
2.20.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux