altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone

Blame SOURCES/httpd-2.4.6-pre_htaccess.patch

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