[PATCH 10/21] print dlopen error

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

 



If the file exists but could not be loaded, print the dlerror().
Often it is a missing symbol.

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxxxxxxx>

---
 xtables.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Index: iptables-modules/xtables.c
===================================================================
--- iptables-modules.orig/xtables.c
+++ iptables-modules/xtables.c
@@ -309,6 +309,7 @@ struct xtables_match *find_match(const c
 {
 	struct xtables_match *ptr;
 	const char *icmp6 = "icmp6";
+	struct stat sb;
 
 	/* This is ugly as hell. Nonetheless, there is no way of changing
 	 * this without hurting backwards compatibility */
@@ -347,12 +348,16 @@ struct xtables_match *find_match(const c
 			/* Found library.  If it didn't register itself,
 			   maybe they specified target as match. */
 			ptr = find_match(name, DONT_LOAD, NULL);
+		else if (stat(path, &sb) == 0)
+			fprintf(stderr, "%s: %s\n", path, dlerror());
 
 		if (ptr == NULL) {
 			sprintf(path, "%s/%s%s.so", lib_dir, afinfo.libprefix,
 				name);
 			if (dlopen(path, RTLD_NOW) != NULL)
 				ptr = find_match(name, DONT_LOAD, NULL);
+			else if (stat(path, &sb) == 0)
+				fprintf(stderr, "%s: %s\n", path, dlerror());
 		}
 
 		if (ptr == NULL && tryload == LOAD_MUST_SUCCEED)
@@ -396,6 +401,7 @@ struct xtables_match *find_match(const c
 struct xtables_target *find_target(const char *name, enum xt_tryload tryload)
 {
 	struct xtables_target *ptr;
+	struct stat sb;
 
 	/* Standard target? */
 	if (strcmp(name, "") == 0
@@ -420,12 +426,16 @@ struct xtables_target *find_target(const
 			/* Found library.  If it didn't register itself,
 			   maybe they specified match as a target. */
 			ptr = find_target(name, DONT_LOAD);
+		else if (stat(path, &sb) == 0)
+			fprintf(stderr, "%s: %s\n", path, dlerror());
 
 		if (ptr == NULL) {
 			sprintf(path, "%s/%s%s.so", lib_dir, afinfo.libprefix,
 				name);
 			if (dlopen(path, RTLD_NOW) != NULL)
 				ptr = find_target(name, DONT_LOAD);
+			else if (stat(path, &sb) == 0)
+				fprintf(stderr, "%s: %s\n", path, dlerror());
 		}
 		if (ptr == NULL && tryload == LOAD_MUST_SUCCEED)
 			exit_error(PARAMETER_PROBLEM,
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux