summaryrefslogtreecommitdiffstats
path: root/xtables.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2009-01-27 15:59:06 +0100
committerJan Engelhardt <jengelh@medozas.de>2009-01-27 23:14:30 +0100
commit39bf9c8214d3073a496a8a1eff91046a8d6fbbdf (patch)
tree2dd9a61eb114cdaaa6fe44f895784f112d24ca56 /xtables.c
parent2338efd8f799d8373dc196c797bda9690283b698 (diff)
libxtables: prefix/order - libdir
Consolidate the libdir variable initialization code into xtables.c. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'xtables.c')
-rw-r--r--xtables.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/xtables.c b/xtables.c
index fb5cc628..85bd76c0 100644
--- a/xtables.c
+++ b/xtables.c
@@ -44,7 +44,8 @@
#define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe"
#endif
-char *lib_dir;
+/* Search path for Xtables .so files */
+static const char *xtables_libdir;
/* the path to command to load kernel module */
const char *xtables_modprobe_program;
@@ -53,6 +54,20 @@ const char *xtables_modprobe_program;
struct xtables_match *xtables_matches;
struct xtables_target *xtables_targets;
+void xtables_init(void)
+{
+ xtables_libdir = getenv("XTABLES_LIBDIR");
+ if (xtables_libdir != NULL)
+ return;
+ xtables_libdir = getenv("IPTABLES_LIB_DIR");
+ if (xtables_libdir != NULL) {
+ fprintf(stderr, "IPTABLES_LIB_DIR is deprecated, "
+ "use XTABLES_LIBDIR.\n");
+ return;
+ }
+ xtables_libdir = XTABLES_LIBDIR;
+}
+
/**
* xtables_*alloc - wrappers that exit on failure
*/
@@ -398,7 +413,8 @@ xtables_find_match(const char *name, enum xtables_tryload tryload,
#ifndef NO_SHARED_LIBS
if (!ptr && tryload != XTF_DONT_LOAD && tryload != XTF_DURING_LOAD) {
- ptr = load_extension(lib_dir, afinfo.libprefix, name, false);
+ ptr = load_extension(xtables_libdir, afinfo.libprefix,
+ name, false);
if (ptr == NULL && tryload == XTF_LOAD_MUST_SUCCEED)
exit_error(PARAMETER_PROBLEM,
@@ -457,7 +473,8 @@ xtables_find_target(const char *name, enum xtables_tryload tryload)
#ifndef NO_SHARED_LIBS
if (!ptr && tryload != XTF_DONT_LOAD && tryload != XTF_DURING_LOAD) {
- ptr = load_extension(lib_dir, afinfo.libprefix, name, true);
+ ptr = load_extension(xtables_libdir, afinfo.libprefix,
+ name, true);
if (ptr == NULL && tryload == XTF_LOAD_MUST_SUCCEED)
exit_error(PARAMETER_PROBLEM,