]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Core configuration: add AllowOverride option to treat syntax
authorNick Kew <niq@apache.org>
Mon, 9 Jan 2012 04:01:06 +0000 (04:01 +0000)
committerNick Kew <niq@apache.org>
Mon, 9 Jan 2012 04:01:06 +0000 (04:01 +0000)
errors in .htaccess as non-fatal.
PR 52439

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1229021 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
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 457d9bdec6aad01d2abf07481027bdce76d04f3b..433014a53bc9d4e3c2e83201ba13c438ee8d00e1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,9 @@ Changes with Apache 2.5.0
 
   *) error log hook: Pass ap_errorlog_info struct.  [Stefan Fritsch]
 
+  *) Core configuration: add AllowOverride option to treat syntax
+     errors in .htaccess as non-fatal.  PR 52439 [Nick Kew]
+
   [Apache 2.5.0-dev includes those bug fixes and changes with the
    Apache 2.4.xx tree as documented below, except as noted.]
 
index 3d357c214ef7e60e33b769c41645ed9d8133f8d0..110a235a1adbb8358b6096cd8600d0ec4820f9b6 100644 (file)
  *                         ap_proxy_strmatch_path, ap_proxy_strmatch_domain,
  *                         ap_proxy_table_unmerge(), proxy_lb_workers.
  * 20111203.1 (2.5.0-dev)  Add ap_list_provider_groups()
+ * 20120109.0 (2.5.0-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 1                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
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 b7d5ce31a66149fed6badc06cca793df84045c50..eb8147b84c313dbf251c94e1af8d2522e4c825ed 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;
         }