+ return 1;
+
+#ifdef HAVE_REGEX_H
+ if (check->operator == T_OP_REG_EQ) {
+ int i, compare;
+ regex_t reg;
+ char name[1024];
+ char value[1024];
+ regmatch_t rxmatch[REQUEST_MAX_REGEX + 1];
+
+ snprintf(name, sizeof(name), "%%{%s}", check->name);
+ radius_xlat(value, sizeof(value), name, request, NULL);
+
+ /*
+ * Include substring matches.
+ */
+ compare = regcomp(®, check->vp_strvalue, REG_EXTENDED);
+ if (compare != 0) {
+ char buffer[256];
+ regerror(compare, ®, buffer, sizeof(buffer));
+
+ RDEBUG("Invalid regular expression %s: %s",
+ check->vp_strvalue, buffer);
+ return -1;
+ }
+ compare = regexec(®, value, REQUEST_MAX_REGEX + 1,
+ rxmatch, 0);
+ regfree(®);
+
+ /*
+ * Add %{0}, %{1}, etc.
+ */
+ for (i = 0; i <= REQUEST_MAX_REGEX; i++) {
+ char *p;
+ char buffer[sizeof(check->vp_strvalue)];
+
+ /*
+ * Didn't match: delete old
+ * match, if it existed.
+ */
+ if ((compare != 0) ||
+ (rxmatch[i].rm_so == -1)) {
+ p = request_data_get(request, request,
+ REQUEST_DATA_REGEX | i);
+ if (p) {
+ free(p);
+ continue;
+ }
+
+ /*
+ * No previous match
+ * to delete, stop.
+ */
+ break;
+ }
+
+ /*
+ * Copy substring into buffer.
+ */
+ memcpy(buffer, value + rxmatch[i].rm_so,
+ rxmatch[i].rm_eo - rxmatch[i].rm_so);
+ buffer[rxmatch[i].rm_eo - rxmatch[i].rm_so] = '\0';
+
+ /*
+ * Copy substring, and add it to
+ * the request.
+ *
+ * Note that we don't check
+ * for out of memory, which is
+ * the only error we can get...
+ */
+ p = strdup(buffer);
+ request_data_add(request, request,
+ REQUEST_DATA_REGEX | i,
+ p, free);
+ }
+ if (compare == 0) return 0;
+ return -1;
+ }
+
+ if (check->operator == T_OP_REG_NE) {
+ int compare;
+ regex_t reg;
+ char name[1024];
+ char value[1024];
+ regmatch_t rxmatch[REQUEST_MAX_REGEX + 1];
+
+ snprintf(name, sizeof(name), "%%{%s}", check->name);
+ radius_xlat(value, sizeof(value), name, request, NULL);
+
+ /*
+ * Include substring matches.
+ */
+ compare = regcomp(®, (char *)check->vp_strvalue,
+ REG_EXTENDED);
+ if (compare != 0) {
+ char buffer[256];
+ regerror(compare, ®, buffer, sizeof(buffer));
+
+ RDEBUG("Invalid regular expression %s: %s",
+ check->vp_strvalue, buffer);
+ return -1;
+ }
+ compare = regexec(®, value, REQUEST_MAX_REGEX + 1,
+ rxmatch, 0);
+ regfree(®);
+
+ if (compare != 0) return 0;
+ return -1;
+
+ }
+#endif