Coincidentally I have been working on adding globbing support to 
include in the httpd config parser. I have only done light testing,
nothing in production yet but the patch provided below has not given
me any trouble in my test environment yet. Any feedback is welcome!
-Matt

Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/httpd/parse.y,v
retrieving revision 1.128
diff -u -p -u -p -r1.128 parse.y
--- parse.y     27 Feb 2022 20:30:30 -0000      1.128
+++ parse.y     2 Jun 2022 20:29:46 -0000
@@ -52,6 +52,7 @@
 #include <string.h>
 #include <ifaddrs.h>
 #include <syslog.h>
+#include <glob.h>
 
 #include "httpd.h"
 #include "http.h"
@@ -165,16 +166,21 @@ grammar           : /* empty */
 
 include                : INCLUDE STRING                {
                        struct file     *nfile;
+                       glob_t g;
 
-                       if ((nfile = pushfile($2, 0)) == NULL) {
-                               yyerror("failed to include file %s", $2);
-                               free($2);
-                               YYERROR;
+                       memset(&g, 0, sizeof(g));
+                       glob($2, GLOB_NOCHECK, NULL, &g);
+                       for(int i = 0; i < g.gl_pathc; ++i) {
+                               if ((nfile = pushfile(g.gl_pathv[i], 0)) == 
NULL) {
+                                       yyerror("failed to include file %s", 
g.gl_pathv[i]);
+                                       free(g.gl_pathv[i]);
+                                       YYERROR;
+                               }
+                               file = nfile;
+                               lungetc('\n');
                        }
+                       globfree(&g);
                        free($2);
-
-                       file = nfile;
-                       lungetc('\n');
                }
                ;
 

Reply via email to