diff --git a/ChangeLog b/ChangeLog index d9d6f6c..0ff2914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +vNEXT: + Added USELIBPCRE to make use of regex engine + optional. + v1.17: 09MAR2015 Support RFC5952-style IPv6 addresses, e.g. [::]:443. diff --git a/Makefile b/Makefile index 342ef13..001e7f5 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ VERSION=$(shell ./genver.sh -r) USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files) +USELIBPCRE=1 # Use libpcre? (necessary to use regex probe) USELIBWRAP?= # Use libwrap? USELIBCAP= # Use libcap? COV_TEST= # Perform test coverage? @@ -29,6 +30,10 @@ ifneq ($(strip $(USELIBWRAP)),) CPPFLAGS+=-DLIBWRAP endif +ifneq ($(strip $(USELIBPCRE)),) + CPPFLAGS+=-DLIBPCRE +endif + ifneq ($(strip $(USELIBCONFIG)),) LIBS:=$(LIBS) -lconfig CPPFLAGS+=-DLIBCONFIG diff --git a/probe.c b/probe.c index a2b2218..c5500b5 100644 --- a/probe.c +++ b/probe.c @@ -21,7 +21,9 @@ #define _GNU_SOURCE #include +#ifdef LIBPCRE #include +#endif #include #include "probe.h" @@ -244,6 +246,7 @@ static int is_adb_protocol(const char *p, int len, struct proto *proto) static int regex_probe(const char *p, int len, struct proto *proto) { +#ifdef LIBPCRE regex_t **probe = proto->data; regmatch_t pos = { 0, len }; @@ -251,6 +254,11 @@ static int regex_probe(const char *p, int len, struct proto *proto) /* try them all */; return (*probe != NULL); +#else + /* Should never happen as we check when loading config file */ + fprintf(stderr, "FATAL: regex probe called but not built in\n"); + exit(5); +#endif } /* diff --git a/sslh-main.c b/sslh-main.c index 607b44f..2029856 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -25,7 +25,9 @@ #ifdef LIBCONFIG #include #endif +#ifdef LIBPCRE #include +#endif #include "common.h" #include "probe.h" @@ -174,6 +176,7 @@ static int config_listen(config_t *config, struct addrinfo **listen) #ifdef LIBCONFIG static void setup_regex_probe(struct proto *p, config_setting_t* probes) { +#ifdef LIBPCRE int num_probes, errsize, i, res; char *err; const char * expr; @@ -201,6 +204,10 @@ static void setup_regex_probe(struct proto *p, config_setting_t* probes) exit(1); } } +#else + fprintf(stderr, "line %d: regex probe specified but not compiled in\n", config_setting_source_line(probes)); + exit(5); +#endif } #endif