From 357d59dcfcbd125e2aa8c07b30cea9635efec2a7 Mon Sep 17 00:00:00 2001 From: Martin Josefsson Date: Mon, 27 Dec 2004 19:49:28 +0000 Subject: Fix setting lib_dir in ip*tables-{save,restore} --- include/ip6tables.h | 4 ++++ include/iptables.h | 4 ++++ include/iptables_common.h | 1 + ip6tables-restore.c | 6 +++++- ip6tables-save.c | 4 ++++ ip6tables-standalone.c | 4 ++++ ip6tables.c | 11 +---------- iptables-restore.c | 6 +++++- iptables-save.c | 4 ++++ iptables-standalone.c | 4 ++++ iptables.c | 11 +---------- 11 files changed, 37 insertions(+), 22 deletions(-) diff --git a/include/ip6tables.h b/include/ip6tables.h index 8360617c..d4dadd88 100644 --- a/include/ip6tables.h +++ b/include/ip6tables.h @@ -4,6 +4,10 @@ #include "iptables_common.h" #include "libiptc/libip6tc.h" +#ifndef IP6T_LIB_DIR +#define IP6T_LIB_DIR "/usr/local/lib/iptables" +#endif + struct ip6tables_rule_match { struct ip6tables_rule_match *next; diff --git a/include/iptables.h b/include/iptables.h index 5aca69a6..6d997f7c 100644 --- a/include/iptables.h +++ b/include/iptables.h @@ -4,6 +4,10 @@ #include "iptables_common.h" #include "libiptc/libiptc.h" +#ifndef IPT_LIB_DIR +#define IPT_LIB_DIR "/usr/local/lib/iptables" +#endif + #ifndef IPPROTO_SCTP #define IPPROTO_SCTP 132 #endif diff --git a/include/iptables_common.h b/include/iptables_common.h index ca65594e..db5e93f6 100644 --- a/include/iptables_common.h +++ b/include/iptables_common.h @@ -26,6 +26,7 @@ extern int iptables_insmod(const char *modname, const char *modprobe); void exit_error(enum exittype, char *, ...)__attribute__((noreturn, format(printf,2,3))); extern const char *program_name, *program_version; +extern char *lib_dir; #ifdef NO_SHARED_LIBS # ifdef _INIT diff --git a/ip6tables-restore.c b/ip6tables-restore.c index 76dddcba..6909c8d7 100644 --- a/ip6tables-restore.c +++ b/ip6tables-restore.c @@ -7,7 +7,7 @@ * Rusty Russell * This code is distributed under the terms of GNU GPL v2 * - * $Id: ip6tables-restore.c,v 1.22 2004/05/26 16:04:48 gandalf Exp $ + * $Id$ */ #include @@ -116,6 +116,10 @@ int main(int argc, char *argv[]) program_version = IPTABLES_VERSION; line = 0; + lib_dir = getenv("IP6TABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IP6T_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/ip6tables-save.c b/ip6tables-save.c index 9deed33c..37b1f197 100644 --- a/ip6tables-save.c +++ b/ip6tables-save.c @@ -322,6 +322,10 @@ int main(int argc, char *argv[]) program_name = "ip6tables-save"; program_version = IPTABLES_VERSION; + lib_dir = getenv("IP6TABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IP6T_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/ip6tables-standalone.c b/ip6tables-standalone.c index 7391ccfb..36dde331 100644 --- a/ip6tables-standalone.c +++ b/ip6tables-standalone.c @@ -46,6 +46,10 @@ main(int argc, char *argv[]) program_name = "ip6tables"; program_version = IPTABLES_VERSION; + lib_dir = getenv("IP6TABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IP6T_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/ip6tables.c b/ip6tables.c index aac95316..aa1e148b 100644 --- a/ip6tables.c +++ b/ip6tables.c @@ -50,10 +50,6 @@ #define FALSE 0 #endif -#ifndef IP6T_LIB_DIR -#define IP6T_LIB_DIR "/usr/local/lib/iptables" -#endif - #ifndef PROC_SYS_MODPROBE #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe" #endif @@ -195,8 +191,7 @@ static int inverse_for_options[NUMBER_OF_OPT] = const char *program_version; const char *program_name; - -static char *lib_dir; +char *lib_dir; /* Keeping track of external matches and targets: linked lists. */ struct ip6tables_match *ip6tables_matches = NULL; @@ -1718,10 +1713,6 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle) 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; diff --git a/iptables-restore.c b/iptables-restore.c index 284f25c6..42aa2a27 100644 --- a/iptables-restore.c +++ b/iptables-restore.c @@ -4,7 +4,7 @@ * * This code is distributed under the terms of GNU GPL v2 * - * $Id: iptables-restore.c,v 1.35 2004/06/25 11:18:57 kadlec Exp $ + * $Id$ */ #include @@ -119,6 +119,10 @@ main(int argc, char *argv[]) program_version = IPTABLES_VERSION; line = 0; + lib_dir = getenv("IPTABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IPT_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/iptables-save.c b/iptables-save.c index d825130e..6c7267e2 100644 --- a/iptables-save.c +++ b/iptables-save.c @@ -335,6 +335,10 @@ main(int argc, char *argv[]) program_name = "iptables-save"; program_version = IPTABLES_VERSION; + lib_dir = getenv("IPTABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IPT_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/iptables-standalone.c b/iptables-standalone.c index 244db5fe..257b6777 100644 --- a/iptables-standalone.c +++ b/iptables-standalone.c @@ -52,6 +52,10 @@ main(int argc, char *argv[]) program_name = "iptables"; program_version = IPTABLES_VERSION; + lib_dir = getenv("IPTABLES_LIB_DIR"); + if (!lib_dir) + lib_dir = IPT_LIB_DIR; + #ifdef NO_SHARED_LIBS init_extensions(); #endif diff --git a/iptables.c b/iptables.c index 7c003ad1..ca0a66fa 100644 --- a/iptables.c +++ b/iptables.c @@ -47,10 +47,6 @@ #define FALSE 0 #endif -#ifndef IPT_LIB_DIR -#define IPT_LIB_DIR "/usr/local/lib/iptables" -#endif - #ifndef PROC_SYS_MODPROBE #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe" #endif @@ -195,6 +191,7 @@ static int inverse_for_options[NUMBER_OF_OPT] = const char *program_version; const char *program_name; +char *lib_dir; /* Keeping track of external matches and targets: linked lists. */ struct iptables_match *iptables_matches = NULL; @@ -210,8 +207,6 @@ struct pprot { u_int8_t num; }; -static char *lib_dir; - /* Primitive headers... */ /* defined in netinet/in.h */ #if 0 @@ -1715,10 +1710,6 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle) 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; -- cgit v1.2.3