$OpenBSD: patch-src_config_directives_c,v 1.9 2021/11/12 16:06:07 sthen Exp $

OpenBSD will not implement wordexp(3); use glob(3) instead

Index: src/config_directives.c
--- src/config_directives.c.orig
+++ src/config_directives.c
@@ -9,7 +9,7 @@
  */
 #include "all.h"
 
-#include <wordexp.h>
+#include <glob.h>
 
 /*******************************************************************************
  * Include functions.
@@ -18,6 +18,7 @@
 CFGFUN(include, const char *pattern) {
     DLOG("include %s\n", pattern);
 
+#ifdef HAVE_WORDEXP
     wordexp_t p;
     const int ret = wordexp(pattern, &p, 0);
     if (ret != 0) {
@@ -27,6 +28,17 @@ CFGFUN(include, const char *pattern) {
     }
     char **w = p.we_wordv;
     for (size_t i = 0; i < p.we_wordc; i++) {
+#else
+    glob_t p;
+    const int ret = glob(pattern, GLOB_ERR, NULL, &p );
+    if (ret != 0) {
+        ELOG("glob(%s): error %d\n", pattern, ret);
+        result->has_errors = true;
+        return;
+    }
+    char **w = p.gl_pathv;
+    for (size_t i = 0; i < p.gl_pathc; i++) {
+#endif
         char resolved_path[PATH_MAX] = {'\0'};
         if (realpath(w[i], resolved_path) == NULL) {
             LOG("Skipping %s: %s\n", w[i], strerror(errno));
@@ -86,7 +98,11 @@ CFGFUN(include, const char *pattern) {
                 break;
         }
     }
+#ifdef HAVE_WORDEXP
     wordfree(&p);
+#else
+    globfree(&p);
+#endif
 }
 
 /*******************************************************************************
