]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix building without regex support
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 5 Sep 2014 23:02:26 +0000 (19:02 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 5 Sep 2014 23:04:05 +0000 (19:04 -0400)
.travis.yml
configure
configure.ac
src/include/radiusd.h
src/include/tmpl.h
src/lib/valuepair.c
src/main/parser.c
src/main/realms.c
src/main/util.c
src/main/valuepair.c
src/main/version.c

index fc0a677e59ffe8e758e4f183fc800ef6331d8be5..f7fb30b1e8423f7cd246a974dee935078d4dfe1d 100644 (file)
@@ -69,6 +69,6 @@ before_install:
       libyubikey-dev
   - sudo apt-get install -qq -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" libmysqlclient-dev
 before_script:
-  - CFLAGS="${BUILD_CFLAGS}" ./configure -C --enable-werror --prefix=$HOME/freeradius --with-shared-libs=$LIBS_SHARED --with-threads=$LIBS_OPTIONAL --with-udpfromto=$LIBS_OPTIONAL --with-openssl=$LIBS_OPTIONAL
+  - CFLAGS="${BUILD_CFLAGS}" ./configure -C --enable-werror --prefix=$HOME/freeradius --with-shared-libs=$LIBS_SHARED --with-threads=$LIBS_OPTIONAL --with-udpfromto=$LIBS_OPTIONAL --with-openssl=$LIBS_OPTIONAL --with-regex=$LIBS_OPTIONAL
   - make
 script: if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make travis-test; fi
index 35048e90044cfdc5feea9f95d62aaeba94b9fa1b..f15072dafc4ca8d402884b4b2c5cfa22dcd9c5cf 100755 (executable)
--- a/configure
+++ b/configure
@@ -764,6 +764,7 @@ with_execinfo_lib_dir
 with_execinfo_include_dir
 with_pcre_lib_dir
 with_pcre_include_dir
+with_regex
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1450,6 +1451,8 @@ Optional Packages:
   --with-pcre-lib-dir=DIR directory in which to look for pcre library files
   --with-pcre-include-dir=DIR
                           directory in which to look for pcre include files
+  --with-regex            Whether to build with regular expressions
+                          (default=yes)
 
 Some influential environment variables:
   CC          C compiler command
@@ -10670,8 +10673,23 @@ if test "${with_pcre_include_dir+set}" = set; then :
 fi
 
 
-REGEX=no
-smart_try_dir=$pcre_include_dir
+REGEX=
+
+# Check whether --with-regex was given.
+if test "${with_regex+set}" = set; then :
+  withval=$with_regex;  case "$withval" in
+    no)
+       REGEX=no
+       ;;
+    *)
+       ;;
+  esac
+
+fi
+
+
+if test "x$REGEX" = "x"; then
+  smart_try_dir=$pcre_include_dir
 
 
 ac_safe=`echo "pcreposix.h" | sed 'y%./+-%__pm%'`
@@ -10898,8 +10916,8 @@ fi
 
 smart_prefix=
 
-if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
-  smart_try_dir=$pcre_lib_dir
+  if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
+    smart_try_dir=$pcre_lib_dir
 
 
 sm_lib_safe=`echo "pcre" | sed 'y%./+-%__p_%'`
@@ -11074,18 +11092,20 @@ if test "x$smart_lib" != "x"; then
   SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
 fi
 
-  if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
-    REGEX=yes
+    if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
+      REGEX=yes
 
-    smart_try_dir=$pcre_lib_dir
+      smart_try_dir=$pcre_lib_dir
 
 $as_echo "#define HAVE_PCRE 1" >>confdefs.h
 
 
-                    LIBS=$(echo "$LIBS" | sed -e 's/-lpcre/-lpcre -lpcreposix/')
+                              LIBS=$(echo "$LIBS" | sed -e 's/-lpcre/-lpcre -lpcreposix/')
+    fi
   fi
 fi
-if test "x$REGEX" != "xyes"; then
+
+if test "x$REGEX" = "x"; then
   smart_try_dir=
 
 
@@ -11331,7 +11351,6 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
 
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-        REGEX_EXTENDED=yes
 
 $as_echo "#define HAVE_REG_EXTENDED 1" >>confdefs.h
 
index 8a95bbbccf168f54cfd8181269b6547081e5b2de..76466ecc45aa3707bde008d428802520e089ac80 100644 (file)
@@ -1636,7 +1636,7 @@ AC_ARG_WITH(pcre-lib-dir,
   esac ]
 )
 
-dnl extra argument: --with-pcre-include--dir
+dnl extra argument: --with-pcre-include-dir
 pcre_include_dir=
 AC_ARG_WITH(pcre-include-dir,
 [AS_HELP_STRING([--with-pcre-include-dir=DIR],
@@ -1653,32 +1653,48 @@ AC_ARG_WITH(pcre-include-dir,
   esac ]
 )
 
-REGEX=no
+dnl extra argument: --with-regex
+REGEX=
+AC_ARG_WITH(regex,
+[AS_HELP_STRING([--with-regex],
+[Whether to build with regular expressions (default=yes)])],
+[ case "$withval" in
+    no)
+       REGEX=no
+       ;;
+    *)
+       ;;
+  esac ]
+)
+
 dnl #
 dnl #  First look for PCRE
 dnl #
-smart_try_dir=$pcre_include_dir
-FR_SMART_CHECK_INCLUDE(pcreposix.h)
-if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
-  smart_try_dir=$pcre_lib_dir
-  FR_SMART_CHECK_LIB(pcre, pcre_compile)
-  if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
-    REGEX=yes
-
+if test "x$REGEX" = "x"; then
+  smart_try_dir=$pcre_include_dir
+  FR_SMART_CHECK_INCLUDE(pcreposix.h)
+  if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
     smart_try_dir=$pcre_lib_dir
-    AC_DEFINE(HAVE_PCRE, [1], [define this if we have libpcre])
-    
-    dnl #
-    dnl #  Hack to get -L<path> and -lpcreposix at the start
-    dnl #  of the linker arguments.
-    dnl #
-    LIBS=$(echo "$LIBS" | sed -e 's/-lpcre/-lpcre -lpcreposix/')
+    FR_SMART_CHECK_LIB(pcre, pcre_compile)
+    if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
+      REGEX=yes
+
+      smart_try_dir=$pcre_lib_dir
+      AC_DEFINE(HAVE_PCRE, [1], [define this if we have libpcre])
+
+      dnl #
+      dnl #  Hack to get -L<path> and -lpcreposix at the start
+      dnl #  of the linker arguments.
+      dnl #
+      LIBS=$(echo "$LIBS" | sed -e 's/-lpcre/-lpcre -lpcreposix/')
+    fi
   fi
 fi
+
 dnl #
 dnl #  If no PCRE, fallback to POSIX regular expressions
 dnl #
-if test "x$REGEX" != "xyes"; then
+if test "x$REGEX" = "x"; then
   smart_try_dir=
   FR_SMART_CHECK_INCLUDE(regex.h)
   if test "x$ac_cv_header_regex_h" = "xyes"; then
@@ -1693,7 +1709,6 @@ if test "x$REGEX" != "xyes"; then
       ],
       [
         AC_MSG_RESULT(yes)
-        REGEX_EXTENDED=yes
         AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)])
       ],
       [
index ff252f21cc62a2c8e6f9639d03cbf468a31b3652..024bc6e8eb5d1730e6d202b0196f6dd5ca7ef7b6 100644 (file)
@@ -552,8 +552,11 @@ uint32_t   rad_pps(uint32_t *past, uint32_t *present, time_t *then, struct timeval
 int            rad_expand_xlat(REQUEST *request, char const *cmd,
                                int max_argc, char *argv[], bool can_fail,
                                size_t argv_buflen, char *argv_buf);
+#ifdef HAVE_REGEX
 void           rad_regcapture(REQUEST *request, int compare, char const *value,
                               regmatch_t rxmatch[]);
+#endif
+
 void           verify_request(char const *file, int line, REQUEST *request);   /* only for special debug builds */
 #ifdef HAVE_GRP_H
 bool           fr_getgid(char const *name, gid_t *gid);
index b920168319cdcff117ccf845b977c03126334806..d607720458e6949cae36324d948c002f1001df5e 100644 (file)
@@ -135,10 +135,12 @@ typedef struct value_pair_tmpl_t {
                        size_t                  length;         //!< of the vpd data
                } literal;
                xlat_exp_t      *xlat;   //!< pre-parsed xlat_exp_t
+#ifdef HAVE_REGEX
                struct {
                        regex_t                 *comp;          //!< pre-parsed regex_t
                        bool                    iflag;          //!< Case insensitive
                } preg;
+#endif
        } data;
 } value_pair_tmpl_t;
 
@@ -150,8 +152,10 @@ typedef struct value_pair_tmpl_t {
 
 #define tmpl_xlat      data.xlat
 
-#define tmpl_preg      data.preg.comp
-#define tmpl_iflag     data.preg.iflag
+#ifdef HAVE_REGEX
+#  define tmpl_preg    data.preg.comp
+#  define tmpl_iflag   data.preg.iflag
+#endif
 
 #define tmpl_value     data.literal.value
 #define tmpl_length    data.literal.length
index 2e7fa2357175108ac30d263e98e9da5f4b903bcd..0ea02f5b35c96271c5df8bf7c2fc97cf804bb441 100644 (file)
@@ -1835,14 +1835,12 @@ VALUE_PAIR *pairmake(TALLOC_CTX *ctx, VALUE_PAIR **vps,
        case T_OP_REG_EQ:       /* =~ */
        case T_OP_REG_NE:       /* !~ */
        {
-
-               int compare;
-               regex_t reg;
 #ifndef WITH_REGEX
                fr_strerror_printf("Regular expressions are not supported");
                return NULL;
-
 #else
+               int compare;
+               regex_t reg;
 
                /*
                 *      Someone else will fill in the value.
index 34f4dd73a3a5b4e15c887736e724adda34446fec..15608054b23d0fdfdce4bab9c7514b162c1bc436 100644 (file)
@@ -640,8 +640,8 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st
                        }
 
                        c->data.map = map_from_str(c, lhs, lhs_type, op, rhs, rhs_type,
-                                                    REQUEST_CURRENT, PAIR_LIST_REQUEST,
-                                                    REQUEST_CURRENT, PAIR_LIST_REQUEST);
+                                                  REQUEST_CURRENT, PAIR_LIST_REQUEST,
+                                                  REQUEST_CURRENT, PAIR_LIST_REQUEST);
                        if (!c->data.map) {
                                /*
                                 *      If strings are T_BARE_WORD and they start with '&',
@@ -665,7 +665,11 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st
                        }
 
                        if (c->data.map->src->type == TMPL_TYPE_REGEX) {
+#ifdef HAVE_REGEX
                                c->data.map->src->tmpl_iflag = i_flag;
+#else
+                               return_0("Server was built without support for regular expressions");
+#endif
                        }
 
                        /*
index e14a65138933f4d825f91d2b8d3dcda68e34e5d6..a09fcf0eb62a7ad55f2c6a109b4999e7c9f21eab 100644 (file)
@@ -1807,8 +1807,11 @@ static int realm_add(realm_config_t *rc, CONF_SECTION *cs)
        return 0;
 }
 
-
+#ifdef HAVE_REGEX
 int realm_realm_add(REALM *r, CONF_SECTION *cs)
+#else
+int realm_realm_add(REALM *r, UNUSED CONF_SECTION *cs)
+#endif
 {
        /*
         *      The structs aren't mutex protected.  Refuse to destroy
index ef5998c8a5f391fc047fa6246ad5455c6b1973dd..2e8b307a187a474b12e47015729e714a4d90fc2c 100644 (file)
@@ -784,6 +784,7 @@ int rad_expand_xlat(REQUEST *request, char const *cmd,
        return argc;
 }
 
+#ifdef HAVE_REGEX
 /** Adds subcapture values to request data
  *
  * Allows use of %{n} expansions.
@@ -844,6 +845,7 @@ void rad_regcapture(REQUEST *request, int compare, char const *value, regmatch_t
                request_data_add(request, request, REQUEST_DATA_REGEX | i, p, true);
        }
 }
+#endif
 
 #ifndef NDEBUG
 /*
index b37cfa5b7e5899724d21a171da1971c28d8fc839..eeed7ad6158e990c9d8548bea7d1839502f163ac 100644 (file)
@@ -65,7 +65,11 @@ static struct cmp *cmp;
  * @return 0 if check and vp are equal, -1 if vp value is less than check value, 1 is vp value is more than check
  *     value, -2 on error.
  */
+#ifdef HAVE_REGEX
 int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
+#else
+int radius_compare_vps(UNUSED REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
+#endif
 {
        int ret = 0;
 
index 948de9a9152b8ceaf86a925d8abfc8f729aa7468..0aba383d64181229dcc234b1ec0565a6d05351ed 100644 (file)
@@ -234,9 +234,13 @@ void version(void)
 #ifdef HAVE_PCRE
        DEBUG3("  regex-pcre");
 #else
-#ifdef HAVE_REGEX
+#  ifdef HAVE_REGEX
+#    ifdef HAVE_REG_EXTENDED
+       DEBUG3("  regex-posix-extended");
+#    else
        DEBUG3("  regex-posix");
-#endif
+#    endif
+#  endif
 #endif
 
 #ifdef WITH_SESSION_MGMT