]> granicus.if.org Git - apache/commitdiff
Merge r1229021 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 31 Jan 2012 17:32:50 +0000 (17:32 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 31 Jan 2012 17:32:50 +0000 (17:32 +0000)
Core configuration: add AllowOverride option to treat syntax
errors in .htaccess as non-fatal.
PR 52439

Submitted by: niq
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1238698 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/core.xml
include/ap_mmn.h
include/http_config.h
include/http_core.h
server/config.c
server/core.c

diff --git a/CHANGES b/CHANGES
index fbbfcccc35924a51ac9b91e417df38ef7a5bc362..e9a1aeedeabcbc0f7dda4dad3a230c9cf529cfb0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@ Changes with Apache 2.4.1
      when no custom ErrorDocument is specified for status code 400.  
      [Eric Covener]
 
+  *) Core configuration: add AllowOverride option to treat syntax
+     errors in .htaccess as non-fatal. PR 52439 [Nick Kew, Jim Jagielski]
+
   *) core: Fix memory consumption in core output filter with streaming
      bucket types like CGI or PIPE.  [Joe Orton, Stefan Fritsch]
 
index edc0df35c484e3bd439ece67b8d433466e945a89..264279ffbf3b3b9342cb7c179bcd3655bccaccb5 100644 (file)
@@ -413,6 +413,11 @@ NoDecode option available in 2.3.12 and later.</compatibility>
       module="mod_authz_host">Deny</directive> and <directive
       module="mod_authz_host">Order</directive>).</dd>
 
+      <dt>Nonfatal</dt>
+
+      <dd>
+      Allow use of AllowOverride option to treat syntax errors in .htaccess as non-fatal.</dt>
+
       <dt>Options[=<var>Option</var>,...]</dt>
 
       <dd>
index d3726ef562015ba02ad8e7d48caf2812fe46b1e4..7df163b7c77ee72d13da5c0d515cae6ed18319e6 100644 (file)
  *                         ap_proxy_sec2hex(), ap_proxy_make_fake_req(),
  *                         ap_proxy_strmatch_path, ap_proxy_strmatch_domain,
  *                         ap_proxy_table_unmerge(), proxy_lb_workers.
+ * 20120109.0 (2.4.1-dev)  Changes sizeof(overrides_t) in core config.
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20111203
+#define MODULE_MAGIC_NUMBER_MAJOR 20120109
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                   /* 0...n */
 
index 30ec368594b0b68fe40a48154f2723b93faed15a..951d64399ab39cb03fb643ec67a5c6b1bc61e69c 100644 (file)
@@ -242,6 +242,13 @@ struct command_struct {
 #define EXEC_ON_READ 256     /**< force directive to execute a command
                 which would modify the configuration (like including another
                 file, or IFModule */
+/* Flags to determine whether syntax errors in .htaccess should be
+ * treated as nonfatal (log and ignore errors)
+ */
+#define NONFATAL_OVERRIDE 512    /* Violation of AllowOverride rule */
+#define NONFATAL_UNKNOWN 1024    /* Unrecognised directive */
+#define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN)
+
 /** this directive can be placed anywhere */
 #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
 
index 81b36c75078b889df16296b526d99e1e26b0d784..c4f4bacfa7f9702d5254ee6f1733fa3518130418 100644 (file)
@@ -446,7 +446,7 @@ AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num);
 
 
 typedef unsigned char allow_options_t;
-typedef unsigned char overrides_t;
+typedef unsigned int overrides_t;
 
 /*
  * Bits of info that go into making an ETag for a file
index 409ca0695ad13a7b86f9811e70fecaad71f3c2fc..96ab9c9d579d7148688750b5d270e329812627be 100644 (file)
@@ -848,8 +848,19 @@ static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
          if(apr_table_get(parms->override_list, cmd->name) != NULL)
               override_list_ok = 1;
 
-    if ((parms->override & cmd->req_override) == 0 && !override_list_ok)
-        return apr_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
+    if ((parms->override & cmd->req_override) == 0 && !override_list_ok) {
+        if (parms->override & NONFATAL_OVERRIDE) {
+            ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, parms->temp_pool,
+                          APLOGNO(02295)
+                          "%s in .htaccess forbidden by AllowOverride",
+                          cmd->name);
+            return NULL;
+        }
+        else {
+            return apr_pstrcat(parms->pool, cmd->name,
+                               " not allowed here", NULL);
+        }
+    }
 
     parms->info = cmd->cmd_data;
     parms->cmd = cmd;
@@ -1251,11 +1262,20 @@ static const char *ap_walk_config_sub(const ap_directive_t *current,
 
     if (ml == NULL) {
         parms->err_directive = current;
-        return apr_pstrcat(parms->pool, "Invalid command '",
-                           current->directive,
-                           "', perhaps misspelled or defined by a module "
-                           "not included in the server configuration",
-                           NULL);
+        if (parms->override & NONFATAL_UNKNOWN) {
+            ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, parms->temp_pool,
+                          APLOGNO(02296) "Unknown directive %s "
+                          "perhaps misspelled or defined by a module "
+                          "not included in the server configuration", dir);
+            return NULL;
+        }
+        else {
+            return apr_pstrcat(parms->pool, "Invalid command '",
+                               current->directive,
+                               "', perhaps misspelled or defined by a module "
+                               "not included in the server configuration",
+                               NULL);
+        }
     }
 
     for ( ; ml != NULL; ml = ml->next) {
index f0a29dd5d4a6c2653ec2df58f9114377ca8d2a1f..23537f5c0e89aae3f89361b3eefff706da0f3b45 100644 (file)
@@ -1619,6 +1619,17 @@ static const char *set_override(cmd_parms *cmd, void *d_, const char *l)
         else if (!strcasecmp(w, "Indexes")) {
             d->override |= OR_INDEXES;
         }
+        else if (!strcasecmp(w, "Nonfatal")) {
+            if (!strcasecmp(v, "Override")) {
+                d->override |= NONFATAL_OVERRIDE;
+            }
+            else if (!strcasecmp(v, "Unknown")) {
+                d->override |= NONFATAL_UNKNOWN;
+            }
+            else if (!strcasecmp(v, "All")) {
+                d->override |= NONFATAL_ALL;
+            }
+        }
         else if (!strcasecmp(w, "None")) {
             d->override = OR_NONE;
         }