httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject [PATCH] improve config dir processing
Date Mon, 27 May 2002 09:15:46 GMT
Currently config directory processing isn't very useful in practice
because all files in the config dir are loaded - so if you use an editor
which creates backup files, the backup file will still be loaded.

A simple way to fix this is to only load files in the config dir which
match the pattern "[A-Za-z0-9]*.conf", as in the following patch (which
also removes the noise produced on stderr when processing config dirs)

--- server/config.c	20 May 2002 15:05:43 -0000	1.151
+++ server/config.c	27 May 2002 09:09:31 -0000
@@ -75,6 +75,7 @@
 #include "apr_strings.h"
 #include "apr_portable.h"
 #include "apr_file_io.h"
+#include "apr_fnmatch.h"
 
 #define APR_WANT_STDIO
 #define APR_WANT_STRFUNC
@@ -1442,7 +1443,6 @@
          * entries here and store 'em away. Recall we need full pathnames
          * for this.
          */
-        fprintf(stderr, "Processing config directory: %s\n", fname);
         rv = apr_dir_open(&dirp, fname, p);
         if (rv != APR_SUCCESS) {
             fprintf(stderr, "%s: could not open config directory %s: %s\n",
@@ -1455,7 +1455,9 @@
         while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
             /* strip out '.' and '..' */
             if (strcmp(dirent.name, ".")
-                && strcmp(dirent.name, "..")) {
+                && strcmp(dirent.name, "..")
+                && apr_fnmatch("[A-Za-z0-9]*.conf", dirent.name,
+                               FNM_PERIOD) == APR_SUCCESS) {
                 fnew = (fnames *) apr_array_push(candidates);
                 fnew->fname = ap_make_full_path(p, fname, dirent.name);
             }
@@ -1472,7 +1474,6 @@
              */
             for (current = 0; current < candidates->nelts; ++current) {
                 fnew = &((fnames *) candidates->elts)[current];
-                fprintf(stderr, " Processing config file: %s\n", fnew->fname);
                 ap_process_resource_config(s, fnew->fname, conftree, p, ptemp);
             }
         }

Mime
View raw message