You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@zyzzyva.com> on 1997/03/05 01:10:37 UTC

Re: [Feature Suggestion] Config includes

> 
> Does anyone else think it would be a good idea to add an include file
> directive to the config system?  I would like to have a set of
> controlled administrative CGI's for my customers to change certain
> aspects of the server config.  The CGI's would handle format
> and whatnot so as not to crash the server.  Basically, it would
> make it possible for the CGI's to avoid parsing and editing
> the entire config, just selected portions.

I have code that does this that has not made it in due to code 
freeze. Had I realized that we weren't in code freeze until this 
past weekend.... :)

I'll include the function below. This can be passed a file or 
directory. IF passed a directory, it will recurse the directory 
structure looking for .htaccess files. My intent was to use this to 
have a separate configuration registry that used the filesystem for 
organization.

> I could use resource config, but I'm already using that so my
> httpd.conf doesn't get incredibly huge. I *had* a patch that let
> me do this ages ago (1.0.5, I think) but I've changed companies
> since then.
> 
> Well, if this isn't too horribly difficult and its not
> already there and just not documented.
> 
> Basically it would be helpful if I could include EXTRA access config
> and resource config info.
> 
> If you think this is a good idea, I'll see about working up a patch
> for 1.2 when I get some free time.
> 
> ---
> Jason S. Clary <jc...@futurefx.com>
> http://www.futurefx.com/~jclary/
> ---



Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.70
diff -c -r1.70 http_core.c
*** http_core.c	1997/02/17 10:46:06	1.70
--- http_core.c	1997/03/05 00:09:32
***************
*** 820,825 ****
--- 820,857 ----
      return errmsg;
  }
  
+ const char *include_config (cmd_parms *cmd, void *dummy, char *name)
+ {
+     char *nname;
+     DIR *vdir;
+     struct DIR_TYPE *vdir_entry;
+     core_server_config *conf;
+ 
+     
+     conf = get_module_config(cmd->server->module_config, &core_module);
+ 
+     name = server_root_relative(cmd->pool, name);
+     
+     if ((vdir = opendir(name)) != NULL) {
+ 	while ((vdir_entry = readdir(vdir)) != NULL) {
+ 	    if ((strcmp(vdir_entry->d_name, "..")) <= 0)
+ 		continue;
+ 
+ 	    nname = pstrcat(cmd->pool, name, vdir_entry->d_name, NULL);
+ 
+ 	    if (is_directory(nname))
+ 		nname = pstrcat(cmd->pool, nname, "/", NULL);
+ 
+ 	    include_config(cmd, dummy, nname);
+ 	}
+ 	closedir(vdir);
+     }
+     else if ((strstr(name, conf->access_name)) != NULL)
+ 	process_resource_config(cmd->server, name, cmd->pool, cmd->temp_pool);
+ 
+     return NULL;
+ }
+ 
  const char *add_module_command (cmd_parms *cmd, void *dummy, char *arg)
  {
      if (add_named_module (arg))
***************
*** 1242,1247 ****
--- 1274,1282 ----
  { "Listen", set_listener, NULL, RSRC_CONF, TAKE1,
        "a port number or a numeric IP address and a port number"},
  { "SendBufferSize", set_send_buffer_size, NULL, RSRC_CONF, TAKE1, "send buffer size in bytes"},
+ { "IncludeConf", include_config, NULL, RSRC_CONF, RAW_ARGS, "configuration resource" },
  { "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE,
    "the name of a module" },
  { "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, NULL },


Re: [Feature Suggestion] Config includes

Posted by Dean Gaudet <dg...@arctic.org>.
My comments on this last time it came up can be summed up:  use m4.  Right
now you have to restart the server anyhow to pull in the new config, so
why not just make your restart script do a remake first.  But anyhow as
long as it's a straight text include, and we stop there, and we don't add
macros and other funky crap it's fine with me as an add-on, but it
shouldn't make 1.2.

Dean