I do not understand why it is believed that people will generate 
better configurations if they split the parts out into different
files.

Adding that kind of trick to an already established grammer rarely works
well.  It only works in narrowly constrained uses of the old grammer,
because now one must consider what is in the included files.  At that
point, why the extra files?  It does not require less brainpower, it
potentially requires more, when the included files start interfering
with the core.

This feels ripe for abuse, and of not much use.


mfre...@mulethew.com wrote:

> 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