--- bird-1.3.7.orig/conf/cf-lex.l 2012-04-27 07:24:32.783039201 -0700 +++ bird-1.3.7/conf/cf-lex.l 2012-04-27 07:34:11.563053857 -0700 @@ -31,6 +31,8 @@ #include #include #include +#include +#include #define PARSER 1 @@ -251,6 +253,8 @@ new_include(void) { char *fname, *p = NULL; + glob_t g; + int x; if ((fname = strchr(yytext, '"')) != NULL) { @@ -259,15 +263,22 @@ if (ifs_depth >= MAX_INCLUDE_DEPTH) cf_error("Max include depth reached."); - /* Save current stack */ - ifs->stack = YY_CURRENT_BUFFER; - /* Prepare new stack */ - ifs->next = new_stack(ifs); - ifs = ifs->next; - strcpy(ifs->conf_fname, fname); /* XXX: strlcpy should be here */ - ifs->conf_fd = cf_open_hook(fname); + glob(fname, GLOB_NOESCAPE, NULL, &g); + for(x = g.gl_pathc - 1; x >= 0; x--) { + struct stat fileStat; + stat(g.gl_pathv[x], &fileStat); + if(!(fileStat.st_mode & S_IFDIR)) { + /* Save current stack */ + ifs->stack = YY_CURRENT_BUFFER; + /* Prepare new stack */ + ifs->next = new_stack(ifs); + ifs = ifs->next; + strcpy(ifs->conf_fname, g.gl_pathv[x]); /* XXX: strlcpy should be here */ + ifs->conf_fd = cf_open_hook(g.gl_pathv[x]); - yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + } + } } }