105 lines
2.3 KiB
Diff
105 lines
2.3 KiB
Diff
diff --git Makefile Makefile
|
|
index ef77957..4d3857d 100644
|
|
--- Makefile
|
|
+++ Makefile
|
|
@@ -1,6 +1,8 @@
|
|
# Configuration
|
|
|
|
VERSION=$(shell ./genver.sh -r)
|
|
+ENABLE_REGEX=1
|
|
+USELIBPCRE=1
|
|
USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files)
|
|
USELIBWRAP?= # Use libwrap?
|
|
USELIBCAP= # Use libcap?
|
|
@@ -22,6 +24,15 @@ CFLAGS ?=-Wall -g $(CFLAGS_COV)
|
|
LIBS=
|
|
OBJS=common.o sslh-main.o probe.o
|
|
|
|
+ifneq ($(strip $(ENABLE_REGEX)),)
|
|
+ CPPFLAGS+=-DENABLE_REGEX
|
|
+endif
|
|
+
|
|
+ifneq ($(strip $(USELIBPCRE)),)
|
|
+ LIBS:=$(LIBS) -lpcre
|
|
+ CPPFLAGS+=-DLIBPCRE
|
|
+endif
|
|
+
|
|
ifneq ($(strip $(USELIBWRAP)),)
|
|
LIBS:=$(LIBS) -lwrap
|
|
CPPFLAGS+=-DLIBWRAP
|
|
diff --git probe.c probe.c
|
|
index 8cff937..1e8c060 100644
|
|
--- probe.c
|
|
+++ probe.c
|
|
@@ -21,7 +21,13 @@
|
|
|
|
#define _GNU_SOURCE
|
|
#include <stdio.h>
|
|
+#ifdef ENABLE_REGEX
|
|
+#ifdef LIBPCRE
|
|
+#include <pcreposix.h>
|
|
+#else
|
|
#include <regex.h>
|
|
+#endif
|
|
+#endif
|
|
#include <ctype.h>
|
|
#include "probe.h"
|
|
|
|
@@ -226,6 +232,7 @@ static int is_tls_protocol(const char *p, int len, struct proto *proto)
|
|
|
|
static int regex_probe(const char *p, int len, struct proto *proto)
|
|
{
|
|
+#ifdef ENABLE_REGEX
|
|
regex_t **probe = proto->data;
|
|
regmatch_t pos = { 0, len };
|
|
|
|
@@ -233,6 +240,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 sslh-main.c sslh-main.c
|
|
index 9cc8a06..be54698 100644
|
|
--- sslh-main.c
|
|
+++ sslh-main.c
|
|
@@ -25,7 +25,13 @@
|
|
#ifdef LIBCONFIG
|
|
#include <libconfig.h>
|
|
#endif
|
|
+#ifdef ENABLE_REGEX
|
|
+#ifdef LIBPCRE
|
|
+#include <pcreposix.h>
|
|
+#else
|
|
#include <regex.h>
|
|
+#endif
|
|
+#endif
|
|
|
|
#include "common.h"
|
|
#include "probe.h"
|
|
@@ -174,6 +180,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 ENABLE_REGEX
|
|
int num_probes, errsize, i, res;
|
|
char *err;
|
|
const char * expr;
|
|
@@ -201,6 +208,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
|
|
|