httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r931435 - in /httpd/httpd/trunk: include/ap_mmn.h include/http_config.h server/config.c server/core.c
Date Wed, 07 Apr 2010 04:51:46 GMT
Author: wrowe
Date: Wed Apr  7 04:51:46 2010
New Revision: 931435

URL: http://svn.apache.org/viewvc?rev=931435&view=rev
Log:
First order simplification; Add IncludeOptional for introducing
wildcard pattern matches or specific includes which may be omitted.
Refactors ap_process_resource_config() to deal efficiently with 
a single file, and renames the new _ex() flavor per list discussion
to  ap_process_fnmatch_configs() for wildcard processing.

Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/http_config.h
    httpd/httpd/trunk/server/config.c
    httpd/httpd/trunk/server/core.c

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=931435&r1=931434&r2=931435&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Wed Apr  7 04:51:46 2010
@@ -217,16 +217,16 @@
  * 20100208.0 (2.3.6-dev)  ap_socache_provider_t API changes to store and iterate
  * 20100208.1 (2.3.6-dev)  Added forward member to proxy_conn_rec
  * 20100208.2 (2.3.7-dev)  Added ap_log_command_line().
- * 20100223.1 (2.3.7-dev)  LDAP client_certs per-server moved to per-dir
- *
+ * 20100208.3 (2.3.7-dev)  LDAP client_certs per-server moved to per-dir
+ * 20100208.4 (2.3.7-dev)  Added ap_process_fnmatch_configs().
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20100223
+#define MODULE_MAGIC_NUMBER_MAJOR 20100208
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 4                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=931435&r1=931434&r2=931435&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_config.h (original)
+++ httpd/httpd/trunk/include/http_config.h Wed Apr  7 04:51:46 2010
@@ -65,12 +65,6 @@ enum cmd_how {
     TAKE_ARGV			/**< an argc and argv are passed */
 };
 
-enum strict_how {
-    AP_OPTIONAL, /* directory and file wildcards succeed on no-match */
-    AP_MIXED, /* directory wildcards fail, file wildcards succeed on no match */
-    AP_STRICT /* directory and file wildcards fail on no-match */
-};
-
 /**
  * This structure is passed to a command which is being invoked,
  * to carry a large variety of miscellaneous data which is all of
@@ -907,34 +901,35 @@ AP_CORE_DECLARE(const char *) ap_init_vi
                                                    server_rec **ps);
 
 /**
- * Process the config file for Apache
+ * Process a config file for Apache
  * @param s The server rec to use for the command parms
  * @param fname The name of the config file
  * @param conftree The root node of the created config tree
  * @param p Pool for general allocation
  * @param ptemp Pool for temporary allocation
- * @param strict Whether a no-match wildcard should be fatal
  */
-AP_DECLARE(const char *) ap_process_resource_config_ex(server_rec *s,
-                                                       const char *fname,
-                                                       ap_directive_t **conftree,
-                                                       apr_pool_t *p,
-                                                       apr_pool_t *ptemp,
-                                                       enum strict_how strict);
+AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
+                                                    const char *fname,
+                                                    ap_directive_t **conftree,
+                                                    apr_pool_t *p,
+                                                    apr_pool_t *ptemp);
 
 /**
- * Process the config file for Apache
+ * Process all matching files as Apache configs
  * @param s The server rec to use for the command parms
- * @param fname The name of the config file
+ * @param fname The filename pattern of the config file
  * @param conftree The root node of the created config tree
  * @param p Pool for general allocation
  * @param ptemp Pool for temporary allocation
+ * @param optional Whether a no-match wildcard is allowed
+ * @see apr_fnmatch for pattern handling
  */
-AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
+AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
                                                     const char *fname,
                                                     ap_directive_t **conftree,
                                                     apr_pool_t *p,
-                                                    apr_pool_t *ptemp);
+                                                    apr_pool_t *ptemp,
+                                                    int optional);
 
 /**
  * Process all directives in the config tree

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=931435&r1=931434&r2=931435&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Wed Apr  7 04:51:46 2010
@@ -1553,16 +1553,52 @@ static int fname_alphasort(const void *f
     return strcmp(f1->fname,f2->fname);
 }
 
+AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
+                                                    const char *fname,
+                                                    ap_directive_t **conftree,
+                                                    apr_pool_t *p,
+                                                    apr_pool_t *ptemp)
+{
+    ap_configfile_t *cfp;
+    cmd_parms parms;
+    apr_status_t rv;
+    const char *error;
+
+    parms = default_parms;
+    parms.pool = p;
+    parms.temp_pool = ptemp;
+    parms.server = s;
+    parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
+    parms.override_opts = OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
+
+    rv = ap_pcfg_openfile(&cfp, p, fname);
+    if (rv != APR_SUCCESS) {
+        char errmsg[120];
+        return apr_psprintf(p, "Could not open configuration file %s: %s",
+                            fname, apr_strerror(rv, errmsg, sizeof errmsg));
+    }
+
+    parms.config_file = cfp;
+    error = ap_build_config(&parms, p, ptemp, conftree);
+    ap_cfg_closefile(cfp);
+
+    if (error) {
+        return apr_psprintf(p, "Syntax error on line %d of %s: %s",
+                            parms.err_directive->line_num,
+                            parms.err_directive->filename, error);
+    }
+
+    return NULL;
+}
+
 static const char *process_resource_config_nofnmatch(server_rec *s,
                                                      const char *fname,
                                                      ap_directive_t **conftree,
                                                      apr_pool_t *p,
                                                      apr_pool_t *ptemp,
                                                      unsigned depth,
-                                                     enum strict_how strict)
+                                                     int optional)
 {
-    cmd_parms parms;
-    ap_configfile_t *cfp;
     const char *error;
     apr_status_t rv;
 
@@ -1616,7 +1652,7 @@ static const char *process_resource_conf
                 fnew = &((fnames *) candidates->elts)[current];
                 error = process_resource_config_nofnmatch(s, fnew->fname,
                                                           conftree, p, ptemp,
-                                                          depth, strict);
+                                                          depth, optional);
                 if (error) {
                     return error;
                 }
@@ -1626,32 +1662,7 @@ static const char *process_resource_conf
         return NULL;
     }
 
-    /* GCC's initialization extensions are soooo nice here... */
-    parms = default_parms;
-    parms.pool = p;
-    parms.temp_pool = ptemp;
-    parms.server = s;
-    parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
-    parms.override_opts = OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
-
-    rv = ap_pcfg_openfile(&cfp, p, fname);
-    if (rv != APR_SUCCESS) {
-        char errmsg[120];
-        return apr_psprintf(p, "Could not open configuration file %s: %s",
-                            fname, apr_strerror(rv, errmsg, sizeof errmsg));
-    }
-
-    parms.config_file = cfp;
-    error = ap_build_config(&parms, p, ptemp, conftree);
-    ap_cfg_closefile(cfp);
-
-    if (error) {
-        return apr_psprintf(p, "Syntax error on line %d of %s: %s",
-                            parms.err_directive->line_num,
-                            parms.err_directive->filename, error);
-    }
-
-    return NULL;
+    return ap_process_resource_config(s, fname, conftree, p, ptemp);
 }
 
 static const char *process_resource_config_fnmatch(server_rec *s,
@@ -1661,7 +1672,7 @@ static const char *process_resource_conf
                                                    apr_pool_t *p,
                                                    apr_pool_t *ptemp,
                                                    unsigned depth,
-                                                   enum strict_how strict)
+                                                   int optional)
 {
     const char *rest;
     apr_status_t rv;
@@ -1684,12 +1695,12 @@ static const char *process_resource_conf
         if (!rest) {
             return process_resource_config_nofnmatch(s, path,
                                                      conftree, p,
-                                                     ptemp, 0, strict);
+                                                     ptemp, 0, optional);
         }
         else {
             return process_resource_config_fnmatch(s, path, rest,
                                                    conftree, p,
-                                                   ptemp, 0, strict);
+                                                   ptemp, 0, optional);
         }
     }
 
@@ -1740,12 +1751,12 @@ static const char *process_resource_conf
             if (!rest) {
                 error = process_resource_config_nofnmatch(s, fnew->fname,
                                                           conftree, p,
-                                                          ptemp, 0, strict);
+                                                          ptemp, 0, optional);
             }
             else {
                 error = process_resource_config_fnmatch(s, fnew->fname, rest,
                                                         conftree, p,
-                                                        ptemp, 0, strict);
+                                                        ptemp, 0, optional);
             }
             if (error) {
                 return error;
@@ -1754,33 +1765,21 @@ static const char *process_resource_conf
     }
     else {
 
-        /* Support for the three states of strictness:
-         *
-         * AP_OPTIONAL - directory and file wildcards succeed on no-match, we don't
-         * need to do anything here for this case.
-         * AP_MIXED - directory wildcards fail on no match, file wildcards succeed
-         * on no match. Use rest to tell between the two.
-         * AP_STRICT - both directory and file wildcards fail on no-match.
-         */
-        if (AP_STRICT == strict) {
-            return apr_psprintf(p, "No matches for the wildcard '%s' in '%s' with "
-                    "strict wildcard matching, failing", fname, path);
-        }
-        else if (AP_MIXED == strict && rest) {
+        if (!optional) {
             return apr_psprintf(p, "No matches for the wildcard '%s' in '%s', failing "
-                    "(use Include optional if required)", fname, path);
+                                   "(use IncludeOptional if required)", fname, path);
         }
     }
 
     return NULL;
 }
 
-AP_DECLARE(const char *) ap_process_resource_config_ex(server_rec *s,
-                                                       const char *fname,
-                                                       ap_directive_t **conftree,
-                                                       apr_pool_t *p,
-                                                       apr_pool_t *ptemp,
-                                                       enum strict_how strict)
+AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
+                                                    const char *fname,
+                                                    ap_directive_t **conftree,
+                                                    apr_pool_t *p,
+                                                    apr_pool_t *ptemp,
+                                                    int optional)
 {
     /* XXX: lstat() won't work on the wildcard pattern...
      */
@@ -1796,8 +1795,7 @@ AP_DECLARE(const char *) ap_process_reso
     }
 
     if (!apr_fnmatch_test(fname)) {
-        return process_resource_config_nofnmatch(s, fname, conftree, p, ptemp,
-                                                 0, strict);
+        return ap_process_resource_config(s, fname, conftree, p, ptemp);
     }
     else {
         apr_status_t status;
@@ -1816,22 +1814,13 @@ AP_DECLARE(const char *) ap_process_reso
 
         /* walk the filepath */
         return process_resource_config_fnmatch(s, rootpath, filepath, conftree, p, ptemp,
-                                                 0, strict);
+                                               0, optional);
 
     }
 
     return NULL;
 }
 
-AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
-                                                    const char *fname,
-                                                    ap_directive_t **conftree,
-                                                    apr_pool_t *p,
-                                                    apr_pool_t *ptemp)
-{
-    return ap_process_resource_config_ex(s, fname, conftree, p, ptemp, AP_MIXED);
-}
-
 AP_DECLARE(int) ap_process_config_tree(server_rec *s,
                                        ap_directive_t *conftree,
                                        apr_pool_t *p,

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=931435&r1=931434&r2=931435&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Wed Apr  7 04:51:46 2010
@@ -2567,33 +2567,14 @@ static const char *set_use_canonical_phy
 }
 
 static const char *include_config (cmd_parms *cmd, void *dummy,
-                                   const char *arg1, const char *arg2)
+                                   const char *name)
 {
     ap_directive_t *conftree = NULL;
-    const char *name;
-    enum strict_how strict;
     const char *conffile, *error;
     unsigned *recursion;
+    int optional = (int)cmd->cmd->cmd_data;
     void *data;
 
-    if (arg2) {
-        name = arg2;
-        if (!strcmp(arg1, "optional")) {
-            strict = AP_OPTIONAL;
-        }
-        else if (!strcmp(arg1, "strict")) {
-            strict = AP_STRICT;
-        }
-        else {
-            return apr_pstrcat(cmd->pool, "Invalid Include modifier '",
-                               arg1, "', should be 'optional' or 'strict'", NULL);
-        }
-    }
-    else {
-        name = arg1;
-        strict = AP_MIXED;
-    }
-
     apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool);
     if (data) {
         recursion = data;
@@ -2606,8 +2587,8 @@ static const char *include_config (cmd_p
 
     if (++*recursion > AP_MAX_INCLUDE_DEPTH) {
         *recursion = 0;
-        return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u. "
-                            "You have probably a recursion somewhere.",
+        return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u, "
+                            "There appears to be a recursion.",
                             AP_MAX_INCLUDE_DEPTH);
     }
 
@@ -2618,8 +2599,9 @@ static const char *include_config (cmd_p
                            name, NULL);
     }
 
-    error = ap_process_resource_config_ex(cmd->server, conffile,
-                                       &conftree, cmd->pool, cmd->temp_pool, strict);
+    error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree, 
+                                       cmd->pool, cmd->temp_pool, 
+                                       optional);
     if (error) {
         *recursion = 0;
         return error;
@@ -3321,10 +3303,14 @@ AP_INIT_TAKE1("UseCanonicalPhysicalPort"
   "Whether to use the physical Port when constructing URLs"),
 /* TODO: RlimitFoo should all be part of mod_cgi, not in the core */
 /* TODO: ListenBacklog in MPM */
-AP_INIT_TAKE12("Include", include_config, NULL,
+AP_INIT_TAKE1("Include", include_config, NULL,
+  (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
+  "Name(s) of the config file(s) to be included; fails if the wildcard does "
+  "not match at least one file"),
+AP_INIT_TAKE1("IncludeOptional", include_config, (void*)1,
   (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
-  "Name of the config file to be included, ignore file wildcards with no "
-  "matching files, fail directory wildcards with no matching directories"),
+  "Name or pattern of the config file(s) to be included; ignored if the file "
+  "does not exist or the pattern does not match any files"),
 AP_INIT_TAKE1("LogLevel", set_loglevel, NULL, RSRC_CONF,
   "Level of verbosity in error logging"),
 AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,



Mime
View raw message