httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Seyboth <...@lst.de>
Subject Re: server config directory patch
Date Tue, 09 Jan 2001 18:33:12 GMT
On Fri, Jan 05, 2001 at 08:53:38AM -0600, William A. Rowe, Jr. wrote:
> New feature, new side effects...
> 
> What about a new rule?  All files in a config directory must begin
> and end with an alpha or digit.  This might take care of the vast
> majority of these problems, and allow operators to mv t.conf to
> _backup.conf, and intentionally disable a section of their config?
>
>
> From: Mark J Cox [mailto:mark@awe.com]
> Sent: Friday, January 05, 2001 9:02 AM
> 
> > after a little prodding to come up with a more simple solution  sans regex)
> > by some helpful folks, here's an alternative:
> 
> If we're ignoring ".files" we might also want to avoid other common 
> editor backup files like "files~" and "#files#" and probably a few others.  
> 
> Mark
> 
> > > At least on Linux, vi creates .file.swp when file is edited, which then
> > > prevents the server from starting/restarting (since .file.swp is funky).
> 

A while ago I did the following patch against 1.3.14. It uses fnmatch()
if the last part of the path is a glob to allow the administrator more
fine grained control over what to include.

Implementing it this way is imho more useful than hardcoding a list of
exclude patterns, especially considering the slew of platforms apache
supports. Plus if the path is a directory or the last part does not
contain any wildcards, the current behaviour is retained.

See also http://bugs.apache.org/index.cgi/full/6854. Don't know if such
a change is suitable for the 1.3 series, though.


Index: src/main/http_config.c
===================================================================
RCS file: /cvs/apache/apache-1.3/src/main/http_config.c,v
retrieving revision 1.157
diff -u -r1.157 http_config.c
--- src/main/http_config.c	2000/11/14 09:57:08	1.157
+++ src/main/http_config.c	2000/11/16 10:12:50
@@ -1207,6 +1207,8 @@
 
 void ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp)
 {
+    char *fparent;
+    char *fglob;
     const char *errmsg;
     cmd_parms parms;
     struct stat finfo;
@@ -1226,13 +1228,27 @@
 	    return;
     }
 
-    /* 
+    /*
+     * The last component of the path may be a glob.
+     * Treat plain directories as globbing all their contents.
+     *
      * here we want to check if the candidate file is really a
      * directory, and most definitely NOT a symlink (to prevent
      * horrible loops).  If so, let's recurse and toss it back into
      * the function.
      */
     if (ap_is_rdirectory(fname)) {
+        fparent = fname;
+        fglob = "*";
+    }
+    else {
+        fparent = ap_make_dirstr_parent(p, fname);
+        fglob = fname + strlen(fparent);
+        if (!(ap_is_rdirectory(fparent) && ap_is_fnmatch(fglob)))
+            fglob = NULL;
+    }
+
+    if (fglob) {
 	DIR *dirp;
 	struct DIR_TYPE *dir_entry;
 	int current;
@@ -1245,11 +1261,11 @@
 	 * for this.
 	 */
 	fprintf(stderr, "Processing config directory: %s\n", fname);
-	dirp = ap_popendir(p, fname);
+	dirp = ap_popendir(p, fparent);
 	if (dirp == NULL) {
 	    perror("fopen");
 	    fprintf(stderr, "%s: could not open config directory %s\n",
-		ap_server_argv0, fname);
+		ap_server_argv0, fparent);
 #ifdef NETWARE
 	    clean_parent_exit(1);
 #else
@@ -1259,10 +1275,16 @@
 	candidates = ap_make_array(p, 1, sizeof(fnames));
 	while ((dir_entry = readdir(dirp)) != NULL) {
 	    /* strip out '.' and '..' */
-	    if (strcmp(dir_entry->d_name, ".") &&
-		strcmp(dir_entry->d_name, "..")) {
-		fnew = (fnames *) ap_push_array(candidates);
-		fnew->fname = ap_make_full_path(p, fname, dir_entry->d_name);
+	    if (!strcmp(dir_entry->d_name, ".")  ||
+	        !strcmp(dir_entry->d_name, ".."))
+	        continue;
+	    /* only process files matching the glob */
+	    if (ap_fnmatch(fglob, dir_entry->d_name, 0) == 0) {
+	      fnew = (fnames *) ap_push_array(candidates);
+	      fnew->fname = ap_make_full_path(p, fparent, dir_entry->d_name);
+	    }
+	    else {
+	      fprintf(stderr, " Excluding config: %s\n", dir_entry->d_name);
 	    }
 	}
 	ap_pclosedir(p, dirp);

-- 
Always remember that you are unique. Just like everyone else.

Mime
View raw message