You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@organic.com> on 1996/07/22 20:43:25 UTC

patch for

Here's a patch that implements something we discusses a month or so ago;
the ability to conditionalize config files based on which modules were
installed. It allows you to do, for example (to use a complex example):

<IfModule dbm_auth_module>
AuthDBMUserFile htpasswd.dbm
</IfModule>
<IfModule !dbm_auth_module>
<IfModule digest_module>
AuthDigestFile htdigest
</IfModule>
<IfModule !digest_module>
AuthUserFile htpasswd
</IfModule>
</IfModule>

Basically, it lets you specifiy a set of directives as being applicatble
only if a certain module is (or is not) installed. And it's, as I've
shown, nestable. I think it'd be useful enough to include in the
distribution.

Here's the patch:

Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.18
diff -c -r1.18 http_core.c
*** http_core.c	1996/06/12 18:14:31	1.18
--- http_core.c	1996/07/22 18:39:47
***************
*** 65,70 ****
--- 65,72 ----
  #include "util_md5.h"
  #include "scoreboard.h"
  
+ extern char *module_names[];
+ 
  /* Server core module... This module provides support for really basic
   * server operations, including options and commands which control the
   * operation of other modules.  Consider this the bureaucracy module.
***************
*** 575,580 ****
--- 577,614 ----
      return NULL;
  }
  
+ char *end_ifmod (cmd_parms *cmd, void *dummy) {
+     return NULL;
+ }
+ 
+ char *start_ifmod (cmd_parms *cmd, void *dummy, char *arg)
+ {
+     char *endp = strrchr (arg, '>');
+     char l[MAX_STRING_LEN];
+     int i, not = (arg[0] == '!');
+     int found = 0;
+     int nest = 1;
+ 
+     if (endp) *endp = '\0';
+     if (not) arg++;
+ 
+     for (i=0; module_names[i]; i++)
+       if (!strcasecmp(arg, module_names[i]))
+ 	found++;
+ 
+     if ((!not && found) || (not && !found))
+       return NULL;
+ 
+     while (nest && !(cfg_getline (l, MAX_STRING_LEN, cmd->infile))) {
+         if (!strncasecmp(l, "<IfModule", 9))
+ 	  nest++;
+ 	if (!strcasecmp(l, "</IfModule>"))
+ 	  nest--;
+     }
+ 
+     return NULL;
+ }
+ 
  /* httpd.conf commands... beginning with the <VirtualHost> business */
  
  char *end_virthost_magic = "</Virtualhost> out of place";
***************
*** 834,839 ****
--- 868,875 ----
  { "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, "Keep-Alive timeout duration (sec)"},
  { "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, "Maximum Keep-Alive requests per connection (0 to disable)" },
  { "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG, NULL },
+ { "<IfModule", start_ifmod, NULL, OR_ALL, RAW_ARGS, NULL },
+ { "</IfModule>", end_ifmod, NULL, OR_ALL, NO_ARGS, NULL },
  { "ContentDigest", set_content_md5, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, "whether or not to send a Content-MD5 header with each request" },
  { "CacheNegotiatedDocs", },
  { "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1, NULL },


-- Alexei Kosut <ak...@organic.com>            The Apache HTTP Server 
   http://www.nueva.pvt.k12.ca.us/~akosut/      http://www.apache.org/


Re: patch for

Posted by Brian Behlendorf <br...@organic.com>.
On Mon, 22 Jul 1996, Alexei Kosut wrote:
> Here's a patch that implements something we discusses a month or so ago;
> the ability to conditionalize config files based on which modules were
> installed. 

While it's beyond my capabilities to say whether this does the right thing
or not, I'd like to state that such functionality is desperately needed
for robustness's sake.  If it gets approved, I'd like to go through and
revamp our config files to make each module-based directive conditional on
the module it matches, and then include sample directives for all other
in-the-distribution-but-not-default-set modules, like the proxy module.

	Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/JOBS