Created
May 12, 2022 17:44
-
-
Save adsr/086537d66469bf0f289521a01534abbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/httpd.h b/include/httpd.h | |
index 2057ec31b2..e9f850c310 100644 | |
--- a/include/httpd.h | |
+++ b/include/httpd.h | |
@@ -812,40 +812,42 @@ typedef struct request_rec request_rec; | |
typedef struct conn_state_t conn_state_t; | |
/* ### would be nice to not include this from httpd.h ... */ | |
/* This comes after we have defined the request_rec type */ | |
#include "apr_uri.h" | |
/** | |
* @brief A structure that represents one process | |
*/ | |
struct process_rec { | |
/** Global pool. Cleared upon normal exit */ | |
apr_pool_t *pool; | |
/** Configuration pool. Cleared upon restart */ | |
apr_pool_t *pconf; | |
/** The program name used to execute the program */ | |
const char *short_name; | |
/** The command line arguments */ | |
const char * const *argv; | |
/** Number of command line arguments passed to the program */ | |
int argc; | |
+ | |
+ const struct htaccess_result *htaccess; | |
}; | |
/** | |
* @brief A structure that represents the current request | |
*/ | |
struct request_rec { | |
/** The pool associated with the request */ | |
apr_pool_t *pool; | |
/** The connection to the client */ | |
conn_rec *connection; | |
/** The virtual host for this request */ | |
server_rec *server; | |
/** Pointer to the redirected request if this is an external redirect */ | |
request_rec *next; | |
/** Pointer to the previous request if this is an internal redirect */ | |
request_rec *prev; | |
/** Pointer to the main request if this is a sub-request | |
* (see http_request.h) */ | |
diff --git a/server/config.c b/server/config.c | |
index be889dbf2f..95eea35872 100644 | |
--- a/server/config.c | |
+++ b/server/config.c | |
@@ -1989,110 +1989,113 @@ apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name, | |
const char **full_name) | |
{ | |
*full_name = ap_make_full_path(r->pool, dir_name, access_name); | |
return ap_pcfg_openfile(conffile, r->pool, *full_name); | |
} | |
AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, | |
request_rec *r, int override, | |
int override_opts, apr_table_t *override_list, | |
const char *d, const char *access_names) | |
{ | |
ap_configfile_t *f = NULL; | |
cmd_parms parms; | |
const char *filename; | |
const struct htaccess_result *cache; | |
struct htaccess_result *new; | |
ap_conf_vector_t *dc = NULL; | |
apr_status_t status; | |
/* firstly, search cache */ | |
- for (cache = r->htaccess; cache != NULL; cache = cache->next) { | |
+ for (cache = r->server->process->htaccess; cache != NULL; cache = cache->next) { | |
if (cache->override == override && strcmp(cache->dir, d) == 0) { | |
+// printf("cache_hit for %s\n", d); | |
*result = cache->htaccess; | |
return OK; | |
} | |
} | |
parms = default_parms; | |
parms.override = override; | |
parms.override_opts = override_opts; | |
parms.override_list = override_list; | |
- parms.pool = r->pool; | |
- parms.temp_pool = r->pool; | |
+ parms.pool = r->server->process->pool; | |
+ parms.temp_pool = r->server->process->pool; | |
parms.server = r->server; | |
- parms.path = apr_pstrdup(r->pool, d); | |
+ parms.path = apr_pstrdup(r->server->process->pool, d); | |
/* loop through the access names and find the first one */ | |
while (access_names[0]) { | |
const char *access_name = ap_getword_conf(r->pool, &access_names); | |
filename = NULL; | |
status = ap_run_open_htaccess(r, d, access_name, &f, &filename); | |
if (status == APR_SUCCESS) { | |
const char *errmsg; | |
ap_directive_t *temptree = NULL; | |
- dc = ap_create_per_dir_config(r->pool); | |
+ dc = ap_create_per_dir_config(r->server->process->pool); | |
parms.config_file = f; | |
- errmsg = ap_build_config(&parms, r->pool, r->pool, &temptree); | |
+ errmsg = ap_build_config(&parms, r->server->process->pool, r->server->process->pool, &temptree); | |
if (errmsg == NULL) | |
errmsg = ap_walk_config(temptree, &parms, dc); | |
ap_cfg_closefile(f); | |
if (errmsg) { | |
ap_log_rerror(APLOG_MARK, APLOG_ALERT, 0, r, | |
"%s: %s", filename, errmsg); | |
return HTTP_INTERNAL_SERVER_ERROR; | |
} | |
*result = dc; | |
break; | |
} | |
else { | |
if (!APR_STATUS_IS_ENOENT(status) | |
&& !APR_STATUS_IS_ENOTDIR(status)) { | |
ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r, APLOGNO(00529) | |
"%s pcfg_openfile: unable to check htaccess file, " | |
"ensure it is readable and that '%s' " | |
"is executable", | |
filename, d); | |
apr_table_setn(r->notes, "error-notes", | |
"Server unable to read htaccess file, denying " | |
"access to be safe"); | |
return HTTP_FORBIDDEN; | |
} | |
} | |
} | |
+// printf("cache_set for %s\n", parms.path); | |
+ | |
/* cache it */ | |
- new = apr_palloc(r->pool, sizeof(struct htaccess_result)); | |
+ new = apr_palloc(r->server->process->pool, sizeof(struct htaccess_result)); | |
new->dir = parms.path; | |
new->override = override; | |
new->override_opts = override_opts; | |
new->htaccess = dc; | |
/* add to head of list */ | |
- new->next = r->htaccess; | |
- r->htaccess = new; | |
+ new->next = r->server->process->htaccess; | |
+ r->server->process->htaccess = new; | |
return OK; | |
} | |
AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, | |
const char *hostname, | |
server_rec *main_server, | |
server_rec **ps) | |
{ | |
server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec)); | |
/* TODO: this crap belongs in http_core */ | |
s->process = main_server->process; | |
s->server_admin = NULL; | |
s->server_hostname = NULL; | |
s->server_scheme = NULL; | |
s->error_fname = NULL; | |
s->timeout = 0; | |
s->keep_alive_timeout = 0; | |
s->keep_alive = -1; | |
diff --git a/server/main.c b/server/main.c | |
index 62e06df045..81f051d41b 100644 | |
--- a/server/main.c | |
+++ b/server/main.c | |
@@ -331,40 +331,41 @@ static process_rec *init_process(int *argc, const char * const * *argv) | |
} | |
apr_pool_abort_set(abort_on_oom, cntx); | |
apr_pool_tag(cntx, "process"); | |
ap_open_stderr_log(cntx); | |
/* Now we have initialized apr and our logger, no more | |
* exceptional error reporting required for the lifetime | |
* of this server process. | |
*/ | |
process = apr_palloc(cntx, sizeof(process_rec)); | |
process->pool = cntx; | |
process->pconf = NULL; | |
reset_process_pconf(process); | |
process->argc = *argc; | |
process->argv = *argv; | |
process->short_name = apr_filepath_name_get((*argv)[0]); | |
+ process->htaccess = NULL; | |
return process; | |
} | |
static void usage(process_rec *process) | |
{ | |
const char *bin = process->argv[0]; | |
int pad_len = strlen(bin); | |
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, | |
"Usage: %s [-D name] [-d directory] [-f file]", bin); | |
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, | |
" %*s [-C \"directive\"] [-c \"directive\"]", pad_len, " "); | |
#ifdef WIN32 | |
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, | |
" %*s [-w] [-k start|restart|stop|shutdown] [-n service_name]", | |
pad_len, " "); | |
ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, | |
" %*s [-k install|config|uninstall] [-n service_name]", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment