Implement IPTABLES_LIB_DIR and IP6TABLES_LIB_DIR environment variables, and set them in testsuite if we're running iptables within tree.
diff --git a/ip6tables.c b/ip6tables.c
index 7cdf457..ced26a5 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -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;