Blame SOURCES/httpd-2.4.6-pre_htaccess.patch

75a229
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
75a229
index 89c4140..82a0acb 100644
75a229
--- a/include/ap_mmn.h
75a229
+++ b/include/ap_mmn.h
75a229
@@ -418,6 +418,7 @@
75a229
  *                         ap_proxy_pass_brigade()
75a229
  * 20120211.22 (2.4.5-dev) No longer prevent usage of strtoul()
75a229
  * 20120211.23 (2.4.5-dev) Add ap_proxy_clear_connection()
75a229
+ * 20120211.24 (2.4.7-dev) add open_htaccess hook.
75a229
  */
75a229
 
75a229
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
75a229
@@ -425,7 +426,7 @@
75a229
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
75a229
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
75a229
 #endif
75a229
-#define MODULE_MAGIC_NUMBER_MINOR 23                   /* 0...n */
75a229
+#define MODULE_MAGIC_NUMBER_MINOR 24                   /* 0...n */
75a229
 
75a229
 /**
75a229
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
75a229
diff --git a/include/http_config.h b/include/http_config.h
75a229
index 7ee3760..c93c3b2 100644
75a229
--- a/include/http_config.h
75a229
+++ b/include/http_config.h
75a229
@@ -1322,6 +1322,31 @@ AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
75a229
 AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
75a229
 
75a229
 /**
75a229
+ * Allow modules to open htaccess files or perform operations before doing so
75a229
+ * @param r The current request
75a229
+ * @param dir_name The directory for which the htaccess file should be opened
75a229
+ * @param access_name The filename  for which the htaccess file should be opened
75a229
+ * @param conffile Where the pointer to the opened ap_configfile_t must be
75a229
+ *        stored
75a229
+ * @param full_name Where the full file name of the htaccess file must be
75a229
+ *        stored.
75a229
+ * @return APR_SUCCESS on success,
75a229
+ *         APR_ENOENT or APR_ENOTDIR if no htaccess file exists,
75a229
+ *         AP_DECLINED to let later modules do the opening,
75a229
+ *         any other error code on error.
75a229
+ */
75a229
+AP_DECLARE_HOOK(apr_status_t,open_htaccess,
75a229
+                (request_rec *r, const char *dir_name, const char *access_name,
75a229
+                 ap_configfile_t **conffile, const char **full_name))
75a229
+
75a229
+/**
75a229
+ * Core internal function, use ap_run_open_htaccess() instead.
75a229
+ */
75a229
+apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name,
75a229
+        const char *access_name, ap_configfile_t **conffile,
75a229
+        const char **full_name);
75a229
+
75a229
+/**
75a229
  * A generic pool cleanup that will reset a pointer to NULL. For use with
75a229
  * apr_pool_cleanup_register.
75a229
  * @param data The address of the pointer
75a229
diff --git a/server/config.c b/server/config.c
75a229
index c1aae17..265744e 100644
75a229
--- a/server/config.c
75a229
+++ b/server/config.c
75a229
@@ -80,6 +80,7 @@ APR_HOOK_STRUCT(
75a229
            APR_HOOK_LINK(quick_handler)
75a229
            APR_HOOK_LINK(optional_fn_retrieve)
75a229
            APR_HOOK_LINK(test_config)
75a229
+           APR_HOOK_LINK(open_htaccess)
75a229
 )
75a229
 
75a229
 AP_IMPLEMENT_HOOK_RUN_ALL(int, header_parser,
75a229
@@ -171,6 +172,12 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(int, handler, (request_rec *r),
75a229
 AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
75a229
                             (r, lookup), DECLINED)
75a229
 
75a229
+AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, open_htaccess,
75a229
+                            (request_rec *r, const char *dir_name, const char *access_name,
75a229
+                             ap_configfile_t **conffile, const char **full_name),
75a229
+                            (r, dir_name, access_name, conffile, full_name),
75a229
+                            AP_DECLINED)
75a229
+
75a229
 /* hooks with no args are implemented last, after disabling APR hook probes */
75a229
 #if defined(APR_HOOK_PROBES_ENABLED)
75a229
 #undef APR_HOOK_PROBES_ENABLED
75a229
@@ -2073,14 +2080,23 @@ AP_DECLARE(int) ap_process_config_tree(server_rec *s,
75a229
     return OK;
75a229
 }
75a229
 
75a229
+apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name,
75a229
+                              const char *access_name,
75a229
+                              ap_configfile_t **conffile,
75a229
+                              const char **full_name)
75a229
+{
75a229
+    *full_name = ap_make_full_path(r->pool, dir_name, access_name);
75a229
+    return ap_pcfg_openfile(conffile, r->pool, *full_name);
75a229
+}
75a229
+
75a229
 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
75a229
                                        request_rec *r, int override,
75a229
                                        int override_opts, apr_table_t *override_list,
75a229
-                                       const char *d, const char *access_name)
75a229
+                                       const char *d, const char *access_names)
75a229
 {
75a229
     ap_configfile_t *f = NULL;
75a229
     cmd_parms parms;
75a229
-    char *filename = NULL;
75a229
+    const char *filename;
75a229
     const struct htaccess_result *cache;
75a229
     struct htaccess_result *new;
75a229
     ap_conf_vector_t *dc = NULL;
75a229
@@ -2104,15 +2120,11 @@ AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
75a229
     parms.path = apr_pstrdup(r->pool, d);
75a229
 
75a229
     /* loop through the access names and find the first one */
75a229
-    while (access_name[0]) {
75a229
-        /* AFAICT; there is no use of the actual 'filename' against
75a229
-         * any canonicalization, so we will simply take the given
75a229
-         * name, ignoring case sensitivity and aliases
75a229
-         */
75a229
-        filename = ap_make_full_path(r->pool, d,
75a229
-                                     ap_getword_conf(r->pool, &access_name));
75a229
-        status = ap_pcfg_openfile(&f, r->pool, filename);
75a229
+    while (access_names[0]) {
75a229
+        const char *access_name = ap_getword_conf(r->pool, &access_names);
75a229
 
75a229
+        filename = NULL;
75a229
+        status = ap_run_open_htaccess(r, d, access_name, &f, &filename);
75a229
         if (status == APR_SUCCESS) {
75a229
             const char *errmsg;
75a229
             ap_directive_t *temptree = NULL;
75a229
diff --git a/server/core.c b/server/core.c
75a229
index f3965ca..85f876b 100644
75a229
--- a/server/core.c
75a229
+++ b/server/core.c
75a229
@@ -4930,6 +4930,7 @@ static void register_hooks(apr_pool_t *p)
75a229
     ap_hook_insert_network_bucket(core_insert_network_bucket, NULL, NULL,
75a229
                                   APR_HOOK_REALLY_LAST);
75a229
     ap_hook_dirwalk_stat(core_dirwalk_stat, NULL, NULL, APR_HOOK_REALLY_LAST);
75a229
+    ap_hook_open_htaccess(ap_open_htaccess, NULL, NULL, APR_HOOK_REALLY_LAST);
75a229
     
75a229
     /* register the core's insert_filter hook and register core-provided
75a229
      * filters