[netfilter-cvslog] r3470 - in trunk: iptables nfsim-testsuite

rusty at netfilter.org rusty at netfilter.org
Mon Dec 20 06:29:53 CET 2004


Author: rusty at netfilter.org
Date: 2004-12-20 06:29:52 +0100 (Mon, 20 Dec 2004)
New Revision: 3470

Modified:
   trunk/iptables/ip6tables.c
   trunk/iptables/iptables.c
   trunk/nfsim-testsuite/test.sh
Log:
Implement IPTABLES_LIB_DIR and IP6TABLES_LIB_DIR environment variables, and set them in testsuite if we're running iptables within tree.


Modified: trunk/iptables/ip6tables.c
===================================================================
--- trunk/iptables/ip6tables.c	2004-12-20 05:12:49 UTC (rev 3469)
+++ trunk/iptables/ip6tables.c	2004-12-20 05:29:52 UTC (rev 3470)
@@ -204,6 +204,8 @@
 const char *program_version;
 const char *program_name;
 
+static char *lib_dir;
+
 /* Keeping track of external matches and targets: linked lists.  */
 struct ip6tables_match *ip6tables_matches = NULL;
 struct ip6tables_target *ip6tables_targets = NULL;
@@ -732,12 +734,12 @@
 
 #ifndef NO_SHARED_LIBS
 	if (!ptr && tryload != DONT_LOAD) {
-		char path[sizeof(IP6T_LIB_DIR) + sizeof("/libip6t_.so")
+		char path[strlen(lib_dir) + sizeof("/libip6t_.so")
 			 + strlen(name)];
 		if (!icmphack)
-			sprintf(path, IP6T_LIB_DIR "/libip6t_%s.so", name);
+			sprintf(path, "%s/libip6t_%s.so", lib_dir, name);
 		else
-			sprintf(path, IP6T_LIB_DIR "/libip6t_%s.so", "icmpv6");
+			sprintf(path, "%s/libip6t_%s.so", lib_dir, "icmpv6");
 		if (dlopen(path, RTLD_NOW)) {
 			/* Found library.  If it didn't register itself,
 			   maybe they specified target as match. */
@@ -985,9 +987,9 @@
 
 #ifndef NO_SHARED_LIBS
 	if (!ptr && tryload != DONT_LOAD) {
-		char path[sizeof(IP6T_LIB_DIR) + sizeof("/libip6t_.so")
+		char path[strlen(lib_dir) + sizeof("/libip6t_.so")
 			 + strlen(name)];
-		sprintf(path, IP6T_LIB_DIR "/libip6t_%s.so", name);
+		sprintf(path, "%s/libip6t_%s.so", lib_dir, name);
 		if (dlopen(path, RTLD_NOW)) {
 			/* Found library.  If it didn't register itself,
 			   maybe they specified match as a target. */
@@ -1721,6 +1723,10 @@
 
 	memset(&fw, 0, sizeof(fw));
 
+	lib_dir = getenv("IP6TABLES_LIB_DIR");
+	if (!lib_dir)
+		lib_dir = IP6T_LIB_DIR;
+
 	/* re-set optind to 0 in case do_command gets called
 	 * a second time */
 	optind = 0;

Modified: trunk/iptables/iptables.c
===================================================================
--- trunk/iptables/iptables.c	2004-12-20 05:12:49 UTC (rev 3469)
+++ trunk/iptables/iptables.c	2004-12-20 05:29:52 UTC (rev 3470)
@@ -218,6 +218,8 @@
 	u_int8_t num;
 };
 
+static char *lib_dir;
+
 /* Primitive headers... */
 /* defined in netinet/in.h */
 #if 0
@@ -675,9 +677,9 @@
 
 #ifndef NO_SHARED_LIBS
 	if (!ptr && tryload != DONT_LOAD) {
-		char path[sizeof(IPT_LIB_DIR) + sizeof("/libipt_.so")
+		char path[strlen(lib_dir) + sizeof("/libipt_.so")
 			 + strlen(name)];
-		sprintf(path, IPT_LIB_DIR "/libipt_%s.so", name);
+		sprintf(path, "%s/libipt_%s.so", lib_dir, name);
 		if (dlopen(path, RTLD_NOW)) {
 			/* Found library.  If it didn't register itself,
 			   maybe they specified target as match. */
@@ -985,9 +987,9 @@
 
 #ifndef NO_SHARED_LIBS
 	if (!ptr && tryload != DONT_LOAD) {
-		char path[sizeof(IPT_LIB_DIR) + sizeof("/libipt_.so")
+		char path[strlen(lib_dir) + sizeof("/libipt_.so")
 			 + strlen(name)];
-		sprintf(path, IPT_LIB_DIR "/libipt_%s.so", name);
+		sprintf(path, "%s/libipt_%s.so", lib_dir, name);
 		if (dlopen(path, RTLD_NOW)) {
 			/* Found library.  If it didn't register itself,
 			   maybe they specified match as a target. */
@@ -1718,6 +1720,10 @@
 
 	memset(&fw, 0, sizeof(fw));
 
+	lib_dir = getenv("IPTABLES_LIB_DIR");
+	if (!lib_dir)
+		lib_dir = IPT_LIB_DIR;
+
 	/* re-set optind to 0 in case do_command gets called
 	 * a second time */
 	optind = 0;

Modified: trunk/nfsim-testsuite/test.sh
===================================================================
--- trunk/nfsim-testsuite/test.sh	2004-12-20 05:12:49 UTC (rev 3469)
+++ trunk/nfsim-testsuite/test.sh	2004-12-20 05:29:52 UTC (rev 3470)
@@ -116,6 +116,7 @@
 if [ -z "$NFSIM_IPTABLES_PREFIX" ]; then
     if [ -x ../iptables/iptables ]; then
 	NFSIM_IPTABLES_PREFIX=../iptables
+	IPTABLES_LIB_DIR=../iptables/extensions
     fi
 fi
 if [ -z "$NFSIM_IPTABLES_PREFIX" ]; then
@@ -123,7 +124,7 @@
 else
     IPTABLES=$NFSIM_IPTABLES_PREFIX/iptables
 fi
-export IPTABLES NFSIM_IPTABLES_PREFIX
+export IPTABLES NFSIM_IPTABLES_PREFIX IPTABLES_LIB_DIR
 
 IPTABLES_VERSION=$($IPTABLES --version | tr ' ' '\n' | grep '^[v0-9.-]*$' | sed 's/v//')
 echo Using `which $IPTABLES` version $IPTABLES_VERSION




More information about the netfilter-cvslog mailing list