summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2008-01-20 13:32:50 +0000
committerPatrick McHardy <kaber@trash.net>2008-01-20 13:32:50 +0000
commit23976ac5efe5d45d78ee6f05e487a1b9feb46655 (patch)
tree0770d61d70bbfcd045c92a3aab57478512761eec
parenta7b0707bd83bac30a92871872dab79ec8cebebbb (diff)
print warning when dlopen fails
If the file exists but could not be loaded, print the dlerror(). Often it is a missing symbol. Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
-rw-r--r--xtables.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/xtables.c b/xtables.c
index 0a2fdb1d..673ba763 100644
--- a/xtables.c
+++ b/xtables.c
@@ -307,6 +307,9 @@ void parse_interface(const char *arg, char *vianame, unsigned char *mask)
struct xtables_match *find_match(const char *name, enum xt_tryload tryload,
struct xtables_rule_match **matches)
{
+#ifndef NO_SHARED_LIBS
+ struct stat sb;
+#endif
struct xtables_match *ptr;
const char *icmp6 = "icmp6";
@@ -347,12 +350,16 @@ struct xtables_match *find_match(const char *name, enum xt_tryload tryload,
/* 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)
@@ -395,6 +402,9 @@ struct xtables_match *find_match(const char *name, enum xt_tryload tryload,
struct xtables_target *find_target(const char *name, enum xt_tryload tryload)
{
+#ifndef NO_SHARED_LIBS
+ struct stat sb;
+#endif
struct xtables_target *ptr;
/* Standard target? */
@@ -420,12 +430,16 @@ struct xtables_target *find_target(const char *name, enum xt_tryload tryload)
/* 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,