httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <gyo...@laserlink.net>
Subject RE: server config directory patch
Date Fri, 05 Jan 2001 12:32:36 GMT
hi again...

after a little prodding to come up with a more simple solution (sans regex)
by some helpful folks, here's an alternative:

--- http_config.c.old   Thu Jan  4 11:38:14 2001
+++ http_config.c       Thu Jan  4 11:49:43 2001
@@ -1252,9 +1252,8 @@
        }
        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, "..")) {
+           /* strip out '.' and '..' as well as hidden '.files' */
+           if (strncmp(dir_entry->d_name, ".", 1)) {
                fnew = (fnames *) ap_push_array(candidates);
                fnew->fname = ap_make_full_path(p, fname,
dir_entry->d_name);
            }

--Geoff

> -----Original Message-----
> From: Geoffrey Young [mailto:gyoung@laserlink.net]
> Sent: Wednesday, January 03, 2001 10:25 AM
> To: new-httpd@apache.org
> Subject: server config directory patch
> 
> 
> hi all...
> 
> here's a little patch that avoids parsing .files when loading 
> up server
> config directories.  
> 
> 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).
> Not that you can't spend 3 seconds and remove the file, but I 
> was thinking
> that maybe avoiding .files was a good idea in general...
> 
> The regex looks for /. in the path+file, which is unix 
> specific, but I don't
> think windows assigns the same meaning to .files, so it may 
> be a non-issue
> for them.
> 
> anyway, I realize it's late to get it into 1.3.15 (if anyone 
> is interested
> at all, that is - it's really no biggie) so I'm just offering 
> it up for what
> it's worth.  I'm not a C programmer at all, and I wasn't sure 
> whether I
> needed to call ap_pregfree() explicitly, so feel free to 
> clean it up as
> necessary...
> 
> --Geoff
> 
> BTW, http://dev.apache.org/from-cvs/ is 404, which is why 
> this patch is
> against 1.3.14 and not cvs, sorry :)
> 
> 
> --- http_config.c.old   Tue Oct  3 12:39:40 2000
> +++ http_config.c       Wed Jan  3 09:23:41 2001
> @@ -1204,6 +1204,7 @@
>      const char *errmsg;
>      cmd_parms parms;
>      struct stat finfo;
> +    regex_t *r = NULL;
>  
>      fname = ap_server_root_relative(p, fname);
>  
> @@ -1269,8 +1270,17 @@
>              */
>             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, p, ptemp);
> +                /*
> +                * use regex to skip .files
> +                */
> +                r = ap_pregcomp(p, "/\\.", REG_EXTENDED);
> +                if (!ap_regexec(r, fnew->fname, 0, NULL, 0)) {
> +                 fprintf(stderr, " Skipping config file: %s\n",
> fnew->fname);
> +                } 
> +                else {
> +                 fprintf(stderr, " Processing config file: %s\n",
> fnew->fname);
> +                 ap_process_resource_config(s, fnew->fname, 
> p, ptemp);
> +                }
>             }
>         }
>         return;
> 

Mime
View raw message