diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2014-04-22 13:42:19 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2014-04-22 13:46:53 +0200 |
commit | 0f86cd6c1dcc2129285e6081751bae3a53058aeb (patch) | |
tree | ca67e2a0f8233ed6f075b6c9535763d41135bd7c | |
parent | b043dddbf0591e67c9c9e4e78df8b9e1c9cafd06 (diff) |
conf: Use configuration file path from Makefile instead of hardcoded paths
Currently, the path to the configuration files is hardcoded to
$PREFIX/etc/netsniff-ng.
If we want to keep the configuration files outside of prefix (e.g.
during development), we need to pass the complete path as specified in
$ETCDIRE (and $ETCDIR respectively, which could e.g. be overriden on the
command line during build install) as a preprocessor define.
This way, we can e.g. install the configuration files to /etc while
installing the binaries in /usr/local with:
$ make PREFIX=/usr/local ETCDIR=/etc
$ make PREFIX=/usr/local ETCDIR=/etc install
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | bpf_parser.y | 4 | ||||
-rw-r--r-- | dissector_eth.c | 6 | ||||
-rw-r--r-- | geoip.c | 14 | ||||
-rw-r--r-- | mausezahn/Makefile | 1 | ||||
-rw-r--r-- | oui.c | 2 | ||||
-rw-r--r-- | trafgen_parser.y | 4 |
7 files changed, 16 insertions, 17 deletions
@@ -91,7 +91,7 @@ CFLAGS_MIN += -D_LARGEFILE64_SOURCE CFLAGS_MIN += -D_FILE_OFFSET_BITS=64 CFLAGS_MIN += -DVERSION_STRING=\"$(VERSION_STRING)\" CFLAGS_MIN += -DVERSION_LONG=\"$(VERSION_LONG)\" -CFLAGS_MIN += -DPREFIX_STRING=\"$(PREFIX)\" +CFLAGS_MIN += -DETCDIRE_STRING=\"$(ETCDIRE)\" WFLAGS_DEF = -Wall diff --git a/bpf_parser.y b/bpf_parser.y index 0cf2a75..26ec125 100644 --- a/bpf_parser.y +++ b/bpf_parser.y @@ -749,8 +749,8 @@ int compile_filter(char *file, int verbose, int bypass, int format, base = basename((b = xstrdup(file))); slprintf(tmp_file, sizeof(tmp_file), "%s/.tmp-%u-%s", dir, rand(), base); - slprintf(cmd, sizeof(cmd), "cpp -I" PREFIX_STRING - "/etc/netsniff-ng/ %s > %s", file, tmp_file); + slprintf(cmd, sizeof(cmd), "cpp -I" ETCDIRE_STRING " %s > %s", + file, tmp_file); if (system(cmd) != 0) panic("Failed to invoke C preprocessor!\n"); diff --git a/dissector_eth.c b/dissector_eth.c index 3beff72..4a696c5 100644 --- a/dissector_eth.c +++ b/dissector_eth.c @@ -119,15 +119,15 @@ static void dissector_init_ports(enum ports which) switch (which) { case PORTS_UDP: - file = PREFIX_STRING "/etc/netsniff-ng/udp.conf"; + file = ETCDIRE_STRING "/udp.conf"; table = ð_ports_udp; break; case PORTS_TCP: - file = PREFIX_STRING "/etc/netsniff-ng/tcp.conf"; + file = ETCDIRE_STRING "/tcp.conf"; table = ð_ports_tcp; break; case PORTS_ETHER: - file = PREFIX_STRING "/etc/netsniff-ng/ether.conf"; + file = ETCDIRE_STRING "/ether.conf"; table = ð_ether_types; break; default: @@ -33,37 +33,37 @@ struct file { static const struct file files[] = { [GEOIP_CITY_EDITION_REV1] = { .desc = "City IPv4", - .local = PREFIX_STRING "/etc/netsniff-ng/city4.dat", + .local = ETCDIRE_STRING "/city4.dat", .remote = "/GeoLiteCity.dat.gz", .possible_prefix = PRE, }, [GEOIP_CITY_EDITION_REV1_V6] = { .desc = "City IPv6", - .local = PREFIX_STRING "/etc/netsniff-ng/city6.dat", + .local = ETCDIRE_STRING "/city6.dat", .remote = "/GeoLiteCityv6.dat.gz", .possible_prefix = PRE "/GeoLiteCityv6-beta", }, [GEOIP_COUNTRY_EDITION] = { .desc = "Country IPv4", - .local = PREFIX_STRING "/etc/netsniff-ng/country4.dat", + .local = ETCDIRE_STRING "/country4.dat", .remote = "/GeoIP.dat.gz", .possible_prefix = PRE "/GeoLiteCountry", }, [GEOIP_COUNTRY_EDITION_V6] = { .desc = "Country IPv6", - .local = PREFIX_STRING "/etc/netsniff-ng/country6.dat", + .local = ETCDIRE_STRING "/country6.dat", .remote = "/GeoIPv6.dat.gz", .possible_prefix = PRE, }, [GEOIP_ASNUM_EDITION] = { .desc = "AS Numbers IPv4", - .local = PREFIX_STRING "/etc/netsniff-ng/asname4.dat", + .local = ETCDIRE_STRING "/asname4.dat", .remote = "/GeoIPASNum.dat.gz", .possible_prefix = PRE "/asnum", }, [GEOIP_ASNUM_EDITION_V6] = { .desc = "AS Numbers IPv6", - .local = PREFIX_STRING "/etc/netsniff-ng/asname6.dat", + .local = ETCDIRE_STRING "/asname6.dat", .remote = "/GeoIPASNumv6.dat.gz", .possible_prefix = PRE "/asnum", }, @@ -526,7 +526,7 @@ static void init_mirrors(void) FILE *fp; char buff[256]; - fp = fopen(PREFIX_STRING "/etc/netsniff-ng/geoip.conf", "r"); + fp = fopen(ETCDIRE_STRING "/geoip.conf", "r"); if (!fp) panic("Cannot open geoip.conf!\n"); diff --git a/mausezahn/Makefile b/mausezahn/Makefile index 5aa46f5..7943738 100644 --- a/mausezahn/Makefile +++ b/mausezahn/Makefile @@ -67,7 +67,6 @@ mausezahn-objs = str.o \ mausezahn-eflags = -O2 -I. -I.. \ -DVERSION_STRING=\"$(VERSION_STRING)\" \ - -DPREFIX_STRING=\"$(PREFIX)\" \ -DVERSION_LONG=\"$(VERSION_LONG)\" mausezahn-confs = @@ -43,7 +43,7 @@ void dissector_init_oui(void) if (initialized) return; - fp = fopen(PREFIX_STRING "/etc/netsniff-ng/oui.conf", "r"); + fp = fopen(ETCDIRE_STRING "/oui.conf", "r"); if (!fp) panic("No oui.conf found!\n"); diff --git a/trafgen_parser.y b/trafgen_parser.y index 93755e9..fd7da76 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -593,8 +593,8 @@ int compile_packets(char *file, int verbose, int cpu, bool invoke_cpp) base = basename((b = xstrdup(file))); slprintf(tmp_file, sizeof(tmp_file), "%s/.tmp-%u-%s", dir, rand(), base); - slprintf(cmd, sizeof(cmd), "cpp -I" PREFIX_STRING - "/etc/netsniff-ng/ %s > %s", file, tmp_file); + slprintf(cmd, sizeof(cmd), "cpp -I" ETCDIRE_STRING " %s > %s", + file, tmp_file); if (system(cmd) != 0) panic("Failed to invoke C preprocessor!\n"); |