On Sun, Aug 5, 2012 at 11:05 AM, Jeff Trawick <[email protected]> wrote:
> On Sun, Aug 5, 2012 at 11:00 AM, Steinar H. Gunderson
> <[email protected]> wrote:
>> On Wed, Aug 01, 2012 at 01:58:16PM -0400, Jeff Trawick wrote:
>>> Your post-perdir-config patch has been committed to trunk with r1368121.
>>
>> Thanks!
>>
>>> Attached is a patch to trunk that allows you to hook in to the stat
>>> calls from directory walk. Call apr_stat() like core_dirwalk_stat()
>>> but check for APR_STATUS_IS_EACCES(rv) and decide whether to run
>>> lingering close and exit. Let us know how that goes.
>>>
>>> You still need the parse-htaccess patch for now.
>>
>> I backported this to 2.4.2, and changed mpm-itk to hook into that function
>> with the following hook:
>>
>> static apr_status_t itk_dirwalk_stat(apr_finfo_t *finfo, request_rec *r,
>> apr_int32_t wanted)
>> {
>> apr_status_t status = apr_stat(finfo, r->filename, wanted, r->pool);
>> if (ap_has_irreversibly_setuid && APR_STATUS_IS_EACCES(status)) {
>> ap_log_rerror(APLOG_MARK, APLOG_WARNING, status, r,
>> "Couldn't read %s, closing connection.",
>> r->filename);
>> ap_lingering_close(r->connection);
>> clean_child_exit(0);
>> }
>> return status;
>> }
>>
>> Seems to work great, from my limited testing. As an extra bonus, I can easily
>> call clean_child_exit() (which runs more cleanup hooks) instead of exit(),
>> since this is in the MPM's own .c file.
>
> Great! I'll do something about the remaining patch "before long".
It has been a while :)
The dirwalk_stat hook has now been committed:
http://svn.apache.org/viewvc?view=revision&revision=1388447
Attached is a patch that adds a hook called just before htaccess is
opened. See if you can use that to resolve the remaining issue.
>
>>
>> /* Steinar */
>> --
>> Homepage: http://www.sesse.net/
>
>
>
> --
> Born in Roswell... married an alien...
> http://emptyhammock.com/
--
Born in Roswell... married an alien...
http://emptyhammock.com/
Index: server/config.c
===================================================================
--- server/config.c (revision 1388440)
+++ server/config.c (working copy)
@@ -80,6 +80,7 @@
APR_HOOK_LINK(quick_handler)
APR_HOOK_LINK(optional_fn_retrieve)
APR_HOOK_LINK(test_config)
+ APR_HOOK_LINK(pre_htaccess)
)
AP_IMPLEMENT_HOOK_RUN_ALL(int, header_parser,
@@ -171,6 +172,9 @@
AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
(r, lookup), DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, pre_htaccess, (request_rec *r, const char
*filename),
+ (r, filename), DECLINED)
+
/* hooks with no args are implemented last, after disabling APR hook probes */
#if defined(APR_HOOK_PROBES_ENABLED)
#undef APR_HOOK_PROBES_ENABLED
@@ -2078,6 +2082,7 @@
struct htaccess_result *new;
ap_conf_vector_t *dc = NULL;
apr_status_t status;
+ int rc;
/* firstly, search cache */
for (cache = r->htaccess; cache != NULL; cache = cache->next) {
@@ -2104,6 +2109,10 @@
*/
filename = ap_make_full_path(r->pool, d,
ap_getword_conf(r->pool, &access_name));
+ rc = ap_run_pre_htaccess(r, filename);
+ if (rc != DECLINED && rc != OK) {
+ return rc;
+ }
status = ap_pcfg_openfile(&f, r->pool, filename);
if (status == APR_SUCCESS) {
Index: include/http_config.h
===================================================================
--- include/http_config.h (revision 1388440)
+++ include/http_config.h (working copy)
@@ -1322,6 +1322,15 @@
AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
/**
+ * Allow modules to perform a check immediately prior to opening htaccess.
+ * @param r The current request
+ * @param filename The htaccess file which will be processed
+ * @return HTTP status code to fail the operation, or DECLINED to let later
+ * modules decide
+ */
+AP_DECLARE_HOOK(int,pre_htaccess,(request_rec *r, const char *filename))
+
+/**
* A generic pool cleanup that will reset a pointer to NULL. For use with
* apr_pool_cleanup_register.
* @param data The address of the pointer