httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject RE: [PATCH] PR #6397
Date Sun, 01 Oct 2000 20:45:11 GMT
I like this patch alot, +1, but...

what all will it break -within- Apache?  mod_status?  or will
ap_process_resource_config record these sufficiently and will 
mod_status then walk this list?

> -----Original Message-----
> From: Jim Jagielski [mailto:jim@jaguNET.com]
> Sent: Sunday, October 01, 2000 3:17 PM
> To: new-httpd@apache.org
> Subject: [PATCH] PR #6397
> 
> 
> Here's my suggested patch for PR #6397. It's a bit more in 
> keeping with
> current coding, and maybe a bit more vocal.
> 
> Index: src/CHANGES
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/CHANGES,v
> retrieving revision 1.1582
> diff -u -r1.1582 CHANGES
> --- src/CHANGES	2000/09/28 13:32:31	1.1582
> +++ src/CHANGES	2000/10/01 20:13:14
> @@ -1,5 +1,11 @@
>  Changes with Apache 1.3.13
>  
> +  *) Add support for a "conf directory" which operates similar to
> +     /etc/rc.d/init. Basically, if a config file is actually a
> +     directory, all the files in that directory will be parsed
> +     as conf files. PR #6397 [Jim Jagielski, Lionel Clark
> +     <bishop@platypus.bc.ca>]
> +
>    *) Initial support added for mod_proxy under MPE/iX.
>       [Mark Bixby <mark_bixby@hp.com>]
>  
> Index: src/include/ap_mmn.h
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/include/ap_mmn.h,v
> retrieving revision 1.50
> diff -u -r1.50 ap_mmn.h
> --- src/include/ap_mmn.h	2000/07/30 17:26:31	1.50
> +++ src/include/ap_mmn.h	2000/10/01 20:13:15
> @@ -229,6 +229,7 @@
>   * 19990320.7           - add ap_strcasestr()
>   * 19990320.8           - add request_rec.case_preserved_filename
>   * 19990320.9           - renamed alloc.h to ap_alloc.h
> + * 19990320.10          - add ap_is_rdirectory()
>   */
>  
>  #define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
> @@ -236,7 +237,7 @@
>  #ifndef MODULE_MAGIC_NUMBER_MAJOR
>  #define MODULE_MAGIC_NUMBER_MAJOR 19990320
>  #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 9                     /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 10                    /* 0...n */
>  
>  /* Useful for testing for features. */
>  #define AP_MODULE_MAGIC_AT_LEAST(major,minor)		\
> Index: src/include/httpd.h
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/include/httpd.h,v
> retrieving revision 1.315
> diff -u -r1.315 httpd.h
> --- src/include/httpd.h	2000/09/22 18:17:48	1.315
> +++ src/include/httpd.h	2000/10/01 20:13:17
> @@ -1090,6 +1090,7 @@
>  API_EXPORT(uid_t) ap_uname2id(const char *name);
>  API_EXPORT(gid_t) ap_gname2id(const char *name);
>  API_EXPORT(int) ap_is_directory(const char *name);
> +API_EXPORT(int) ap_is_rdirectory(const char *name);
>  API_EXPORT(int) ap_can_exec(const struct stat *);
>  API_EXPORT(void) ap_chdir_file(const char *file);
>  
> Index: src/main/http_config.c
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/main/http_config.c,v
> retrieving revision 1.153
> diff -u -r1.153 http_config.c
> --- src/main/http_config.c	2000/06/01 23:42:24	1.153
> +++ src/main/http_config.c	2000/10/01 20:13:18
> @@ -1187,6 +1187,18 @@
>      ap_cfg_closefile(parms.config_file);
>  }
>  
> +typedef struct {
> +    char *filename;
> +} fnames;
> +
> +static int fname_alphasort(const void *fn1, const void *fn2)
> +{
> +    const fnames *f1 = fn1;
> +    const fnames *f2 = fn2;
> +
> +    return strcmp(f1->filename,f2->filename);
> +}
> +
>  void ap_process_resource_config(server_rec *s, char *fname, 
> pool *p, pool *ptemp)
>  {
>      const char *errmsg;
> @@ -1208,6 +1220,62 @@
>  	    return;
>      }
>  
> +    /* 
> +     * 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)) {
> +	DIR *dirp;
> +	struct DIR_TYPE *dir_entry;
> +	int current;
> +	array_header *candidates = NULL;
> +	fnames *fnew;
> +
> +	/*
> +	 * first course of business is to grok all the directory
> +	 * entries here and store 'em away. Recall we need full 
> pathnames
> +	 * for this.
> +	 */
> +	fprintf(stderr, "Processing config directory: %s\n", fname);
> +	dirp = ap_popendir(p, fname);
> +	if (dirp == NULL) {
> +	    perror("fopen");
> +	    fprintf(stderr, "%s: could not open config directory %s\n",
> +		ap_server_argv0, fname);
> +#ifdef NETWARE
> +	    clean_parent_exit(1);
> +#else
> +	    exit(1);
> +#endif
> +	}
> +	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->filename = ap_make_full_path(p, fname, 
> dir_entry->d_name);
> +	    }
> +	}
> +	ap_pclosedir(p, dirp);
> +	if (candidates->nelts != 0) {
> +            qsort((void *) candidates->elts, candidates->nelts,
> +              sizeof(fnames), fname_alphasort);
> +	    /*
> +	     * Now recurse these... we handle errors and subdirectories
> +	     * via the recursion, which is nice
> +	     */
> +	    for (current = 0; current < candidates->nelts; ++current) {
> +	        fnew = &((fnames *) candidates->elts)[current];
> +		fprintf(stderr, " Processing config file: 
> %s\n", fnew->filename);
> +		ap_process_resource_config(s, fnew->filename, p, ptemp);
> +	    }
> +	}
> +	return;
> +    }
> +    
>      /* GCC's initialization extensions are soooo nice here... */
>  
>      parms = default_parms;
> @@ -1242,7 +1310,6 @@
>  
>      ap_cfg_closefile(parms.config_file);
>  }
> -
>  
>  int ap_parse_htaccess(void **result, request_rec *r, int override,
>  		   const char *d, const char *access_name)
> Index: src/main/util.c
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/main/util.c,v
> retrieving revision 1.187
> diff -u -r1.187 util.c
> --- src/main/util.c	2000/09/22 18:33:17	1.187
> +++ src/main/util.c	2000/10/01 20:13:20
> @@ -1652,6 +1652,20 @@
>      return (S_ISDIR(finfo.st_mode));
>  }
>  
> +/*
> + * see ap_is_directory() except this one is symlink aware, so it
> + * checks for a "real" directory
> + */
> +API_EXPORT(int) ap_is_rdirectory(const char *path)
> +{
> +    struct stat finfo;
> +
> +    if (lstat(path, &finfo) == -1)
> +	return 0;		/* in error condition, just return no */
> +
> +    return ((!(S_ISLNK(finfo.st_mode))) && (S_ISDIR(finfo.st_mode)));
> +}
> +
>  API_EXPORT(char *) ap_make_full_path(pool *a, const char *src1,
>  				  const char *src2)
>  {
> -- 
> ==============================================================
> =============
>    Jim Jagielski   [|]   jim@jaguNET.com   [|]   
http://www.jaguNET.com/
                "Are you suggesting coconuts migrate??"


Mime
View raw message