002-no_regex_probes.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 3aefaf300478cd6fbc4892d5baaf70521ed323af Mon Sep 17 00:00:00 2001
  2. From: Yves Rutschle <git1@rutschle.net>
  3. Date: Thu, 9 Jul 2015 15:31:42 +0200
  4. Subject: [PATCH] Added Makefile option to build without libpcre
  5. ---
  6. --- a/Makefile
  7. +++ b/Makefile
  8. @@ -2,6 +2,7 @@
  9. VERSION=$(shell ./genver.sh -r)
  10. USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files)
  11. +USELIBPCRE=1 # Use libpcre? (necessary to use regex probe)
  12. USELIBWRAP?= # Use libwrap?
  13. USELIBCAP= # Use libcap?
  14. COV_TEST= # Perform test coverage?
  15. @@ -27,6 +28,10 @@ ifneq ($(strip $(USELIBWRAP)),)
  16. CPPFLAGS+=-DLIBWRAP
  17. endif
  18. +ifneq ($(strip $(USELIBPCRE)),)
  19. + CPPFLAGS+=-DLIBPCRE
  20. +endif
  21. +
  22. ifneq ($(strip $(USELIBCONFIG)),)
  23. LIBS:=$(LIBS) -lconfig
  24. CPPFLAGS+=-DLIBCONFIG
  25. --- a/probe.c
  26. +++ b/probe.c
  27. @@ -21,7 +21,9 @@
  28. #define _GNU_SOURCE
  29. #include <stdio.h>
  30. +#ifdef LIBPCRE
  31. #include <regex.h>
  32. +#endif
  33. #include <ctype.h>
  34. #include "probe.h"
  35. @@ -226,6 +228,7 @@ static int is_tls_protocol(const char *p
  36. static int regex_probe(const char *p, int len, struct proto *proto)
  37. {
  38. +#ifdef LIBPCRE
  39. regex_t **probe = proto->data;
  40. regmatch_t pos = { 0, len };
  41. @@ -233,6 +236,11 @@ static int regex_probe(const char *p, in
  42. /* try them all */;
  43. return (*probe != NULL);
  44. +#else
  45. + /* Should never happen as we check when loading config file */
  46. + fprintf(stderr, "FATAL: regex probe called but not built in\n");
  47. + exit(5);
  48. +#endif
  49. }
  50. /*
  51. --- a/sslh-main.c
  52. +++ b/sslh-main.c
  53. @@ -25,7 +25,9 @@
  54. #ifdef LIBCONFIG
  55. #include <libconfig.h>
  56. #endif
  57. +#ifdef LIBPCRE
  58. #include <regex.h>
  59. +#endif
  60. #include "common.h"
  61. #include "probe.h"
  62. @@ -174,6 +176,7 @@ static int config_listen(config_t *confi
  63. #ifdef LIBCONFIG
  64. static void setup_regex_probe(struct proto *p, config_setting_t* probes)
  65. {
  66. +#ifdef LIBPCRE
  67. int num_probes, errsize, i, res;
  68. char *err;
  69. const char * expr;
  70. @@ -201,6 +204,10 @@ static void setup_regex_probe(struct pro
  71. exit(1);
  72. }
  73. }
  74. +#else
  75. + fprintf(stderr, "line %d: regex probe specified but not compiled in\n", config_setting_source_line(probes));
  76. + exit(5);
  77. +#endif
  78. }
  79. #endif