#ifndef APACHE_HTTP_CONFIG_H
#define APACHE_HTTP_CONFIG_H
+#include "ap_hooks.h"
+
#ifdef __cplusplus
extern "C" {
#endif
* (see also mod_so).
*/
- /* init() occurs after config parsing, but before any children are
- * forked.
- * Modules should not rely on the order in which create_server_config
- * and create_dir_config are called.
- */
-#ifdef ULTRIX_BRAIN_DEATH
- void (*init) ();
- void *(*create_dir_config) ();
- void *(*merge_dir_config) ();
- void *(*create_server_config) ();
- void *(*merge_server_config) ();
-#else
- void (*init) (server_rec *, pool *);
void *(*create_dir_config) (pool *p, char *dir);
void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf);
void *(*create_server_config) (pool *p, server_rec *s);
void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf);
-#endif
const command_rec *cmds;
const handler_rec *handlers;
* supposed to handle this was configured wrong).
* type_checker --- Determine MIME type of the requested entity;
* sets content_type, _encoding and _language fields.
- * logger --- log a transaction.
- * post_read_request --- run right after read_request or internal_redirect,
- * and not run during any subrequests.
*/
- int (*translate_handler) (request_rec *);
- int (*ap_check_user_id) (request_rec *);
- int (*auth_checker) (request_rec *);
- int (*access_checker) (request_rec *);
- int (*type_checker) (request_rec *);
- int (*fixer_upper) (request_rec *);
- int (*logger) (request_rec *);
- int (*header_parser) (request_rec *);
-
- /* Regardless of the model the server uses for managing "units of
- * execution", i.e. multi-process, multi-threaded, hybrids of those,
- * there is the concept of a "heavy weight process". That is, a
- * process with its own memory space, file spaces, etc. This method,
- * child_init, is called once for each heavy-weight process before
- * any requests are served. Note that no provision is made yet for
- * initialization per light-weight process (i.e. thread). The
- * parameters passed here are the same as those passed to the global
- * init method above.
- */
-#ifdef ULTRIX_BRAIN_DEATH
- void (*child_init) ();
- void (*child_exit) ();
-#else
- void (*child_init) (server_rec *, pool *);
- void (*child_exit) (server_rec *, pool *);
-#endif
- int (*post_read_request) (request_rec *);
+ void (*register_hooks) (void);
} module;
/* Initializer for the first few module slots, which are only
/* for implementing subconfigs and customized config files */
API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
+/* ap_check_cmd_context() definitions: */
+API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
+
+/* ap_check_cmd_context(): Forbidden in: */
+#define NOT_IN_VIRTUALHOST 0x01 /* <Virtualhost> */
+#define NOT_IN_LIMIT 0x02 /* <Limit> */
+#define NOT_IN_DIRECTORY 0x04 /* <Directory> */
+#define NOT_IN_LOCATION 0x08 /* <Location> */
+#define NOT_IN_FILES 0x10 /* <Files> */
+#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
+#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
+
+
#ifdef CORE_PRIVATE
extern API_VAR_EXPORT module *top_module;
/* For http_main.c... */
-server_rec *ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name);
-void ap_init_modules(pool *p, server_rec *s);
-void ap_child_init_modules(pool *p, server_rec *s);
-void ap_child_exit_modules(pool *p, server_rec *s);
void ap_setup_prelinked_modules(void);
void ap_show_directives(void);
void ap_show_modules(void);
+server_rec *ap_read_config(pool *conf_pool, pool *temp_pool, const char *config_name);
+void ap_post_config_hook(pool *pconf, pool *plog, pool *ptemp, server_rec *s);
+void ap_child_init_hook(pool *pchild, server_rec *s);
/* For http_request.c... */
CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname,
server_rec *main_server, server_rec **);
-void ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp);
-
-/* ap_check_cmd_context() definitions: */
-API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
-
-/* ap_check_cmd_context(): Forbidden in: */
-#define NOT_IN_VIRTUALHOST 0x01 /* <Virtualhost> */
-#define NOT_IN_LIMIT 0x02 /* <Limit> */
-#define NOT_IN_DIRECTORY 0x04 /* <Directory> */
-#define NOT_IN_LOCATION 0x08 /* <Location> */
-#define NOT_IN_FILES 0x10 /* <Files> */
-#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
-#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
-
+void ap_process_resource_config(server_rec *s, const char *fname, pool *p, pool *ptemp);
/* Module-method dispatchers, also for http_request.c */
int ap_translate_name(request_rec *);
-int ap_check_access(request_rec *); /* check access on non-auth basis */
int ap_check_user_id(request_rec *); /* obtain valid username from client auth */
-int ap_check_auth(request_rec *); /* check (validated) user is authorized here */
-int ap_find_types(request_rec *); /* identify MIME type */
-int ap_run_fixups(request_rec *); /* poke around for other metainfo, etc.... */
int ap_invoke_handler(request_rec *);
-int ap_log_transaction(request_rec *r);
-int ap_header_parse(request_rec *);
-int ap_run_post_read_request(request_rec *);
/* for mod_perl */
#endif
+ /* Hooks */
+DECLARE_HOOK(int,header_parser,(request_rec *))
+DECLARE_HOOK(void,pre_config,(pool *pconf,pool *plog,pool *ptemp))
+DECLARE_HOOK(void,post_config,
+ (pool *pconf,pool *plog,pool *ptemp,server_rec *s))
+DECLARE_HOOK(void,open_logs,
+ (pool *pconf,pool *plog,pool *ptemp,server_rec *s))
+DECLARE_HOOK(void,child_init,(pool *pchild, server_rec *s))
+
#ifdef __cplusplus
}
#endif
#ifndef APACHE_HTTP_PROTOCOL_H
#define APACHE_HTTP_PROTOCOL_H
+#include "ap_hooks.h"
+
#ifdef __cplusplus
extern "C" {
#endif
*/
API_EXPORT(int) ap_method_number_of(const char *method);
+ /* Hooks */
+ /*
+ * post_read_request --- run right after read_request or internal_redirect,
+ * and not run during any subrequests.
+ */
+DECLARE_HOOK(int,post_read_request,(request_rec *))
+DECLARE_HOOK(int,log_transaction,(request_rec *))
+DECLARE_HOOK(const char *,http_method,(const request_rec *))
+DECLARE_HOOK(unsigned short,default_port,(const request_rec *))
+
#ifdef __cplusplus
}
#endif
#ifndef APACHE_HTTP_REQUEST_H
#define APACHE_HTTP_REQUEST_H
+#include "ap_hooks.h"
+
#ifdef __cplusplus
extern "C" {
#endif
API_EXPORT(void) ap_die(int type, request_rec *r);
#endif
+ /* Hooks */
+DECLARE_HOOK(int,translate_name,(request_rec *))
+DECLARE_HOOK(int,check_user_id,(request_rec *))
+DECLARE_HOOK(int,fixups,(request_rec *))
+DECLARE_HOOK(int,type_checker,(request_rec *))
+DECLARE_HOOK(int,access_checker,(request_rec *))
+DECLARE_HOOK(int,auth_checker,(request_rec *))
+
#ifdef __cplusplus
}
#endif
return ret;
}
-
+static void register_hooks(void)
+{
+ ap_hook_access_checker(check_dir_access,NULL,NULL,HOOK_MIDDLE);
+}
module MODULE_VAR_EXPORT access_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_access_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
access_cmds,
NULL, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- check_dir_access, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
+#include "http_request.h"
typedef struct auth_config_struct {
char *auth_pwfile;
}
module MODULE_VAR_EXPORT auth_module =
+static void register_hooks(void)
+{
+ ap_hook_check_user_id(authenticate_basic_user,NULL,NULL,HOOK_MIDDLE);
+ ap_hook_auth_checker(check_user_access,NULL,NULL,HOOK_MIDDLE);
+}
+
{
STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_auth_dir_config, /* dir config creater */
+ STANDARD20_MODULE_STUFF,
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
auth_cmds, /* command table */
NULL, /* handlers */
NULL, /* filename translation */
- authenticate_basic_user, /* check_user_id */
- check_user_access, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
-};
+ register_hooks /* register hooks */
}
ap_send_http_header(r);
- if (!r->header_only)
- ap_send_fd(f, r);
+ if (!r->header_only) {
+ fseek(f, 0, SEEK_CUR);
+ ap_send_fd(fileno(f), r);
+ }
ap_pfclose(r->pool, f);
return OK;
module MODULE_VAR_EXPORT asis_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command table */
asis_handlers, /* handlers */
- NULL, /* translate_handler */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* pre-run fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ NULL /* register hooks */
};
module MODULE_VAR_EXPORT cgi_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
+ NULL, /* pre_config */
+ NULL, /* post_config */
+ NULL, /* open_logs */
+ NULL, /* child initializer */
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
create_cgi_config, /* server config */
merge_cgi_config, /* merge server config */
cgi_cmds, /* command table */
cgi_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* fixups */
NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ NULL /* register hooks */
};
{ NULL, NULL }
};
+static void core_open_logs(pool *pconf, pool *plog, pool *ptemp, server_rec *s)
+{
+ ap_open_logs(s, pconf);
+}
+
+static const char *core_method(const request_rec *r)
+ { return "http"; }
+
+static unsigned short core_port(const request_rec *r)
+ { return DEFAULT_HTTP_PORT; }
+
+static void register_hooks(void)
+{
+ ap_hook_translate_name(core_translate,NULL,NULL,HOOK_REALLY_LAST);
+ ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
+ HOOK_REALLY_LAST);
+ ap_hook_http_method(core_method,NULL,NULL,HOOK_REALLY_LAST);
+ ap_hook_default_port(core_port,NULL,NULL,HOOK_REALLY_LAST);
+ ap_hook_open_logs(core_open_logs,NULL,NULL,HOOK_MIDDLE);
+ /* FIXME: I suspect we can eliminate the need for these - Ben */
+ ap_hook_type_checker(do_nothing,NULL,NULL,HOOK_REALLY_LAST);
+ ap_hook_access_checker(do_nothing,NULL,NULL,HOOK_REALLY_LAST);
+}
+
API_VAR_EXPORT module core_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_core_dir_config, /* create per-directory config structure */
merge_core_dir_configs, /* merge per-directory config structures */
create_core_server_config, /* create per-server config structure */
merge_core_server_configs, /* merge per-server config structures */
core_cmds, /* command table */
core_handlers, /* handlers */
- core_translate, /* translate_handler */
- NULL, /* check_user_id */
- NULL, /* check auth */
- do_nothing, /* check access */
- do_nothing, /* type_checker */
- NULL, /* pre-run fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post_read_request */
+ register_hooks /* register hooks */
};
#include "util_date.h" /* For parseHTTPdate and BAD_DATE */
#include <stdarg.h>
+HOOK_STRUCT(
+ HOOK_LINK(post_read_request)
+ HOOK_LINK(log_transaction)
+ HOOK_LINK(http_method)
+ HOOK_LINK(default_port)
+);
+
#define SET_BYTES_SENT(r) \
do { if (r->sent_bodyct) \
ap_bgetopt (r->connection->client, BO_BYTECT, &r->bytes_sent); \
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
"request failed: URI too long");
ap_send_error_response(r, 0);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return r;
}
return NULL;
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
"request failed: error reading the headers");
ap_send_error_response(r, 0);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return r;
}
}
r->header_only = 0;
r->status = HTTP_BAD_REQUEST;
ap_send_error_response(r, 0);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return r;
}
}
"client sent HTTP/1.1 request without hostname "
"(see RFC2068 section 9, and 14.23): %s", r->uri);
ap_send_error_response(r, 0);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return r;
}
if (((expect = ap_table_get(r->headers_in, "Expect")) != NULL) &&
"Expect: %s", expect);
ap_send_error_response(r, 0);
(void) ap_discard_request_body(r);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return r;
}
}
if ((access_status = ap_run_post_read_request(r))) {
ap_die(access_status, r);
- ap_log_transaction(r);
+ ap_run_log_transaction(r);
return NULL;
}
ap_finalize_request_protocol(r);
ap_rflush(r);
}
+
+IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(const char *,http_method,(const request_rec *r),(r),
+ NULL)
+IMPLEMENT_HOOK_RUN_FIRST(unsigned short,default_port,(const request_rec *r),
+ (r),0)
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
-#include "http_conf_globals.h" /* for ap_extended_status */
#include "http_log.h"
#include "http_main.h"
+#if 0
#include "scoreboard.h"
+#endif
#include "fnmatch.h"
+HOOK_STRUCT(
+ HOOK_LINK(translate_name)
+ HOOK_LINK(check_user_id)
+ HOOK_LINK(fixups)
+ HOOK_LINK(type_checker)
+ HOOK_LINK(access_checker)
+ HOOK_LINK(auth_checker)
+)
+
+IMPLEMENT_HOOK_RUN_FIRST(int,translate_name,(request_rec *r),(r),DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,check_user_id,(request_rec *r),(r),DECLINED)
+IMPLEMENT_HOOK_RUN_ALL(int,fixups,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,type_checker,(request_rec *r),(r),DECLINED)
+IMPLEMENT_HOOK_RUN_ALL(int,access_checker,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_RUN_FIRST(int,auth_checker,(request_rec *r),(r),DECLINED)
+
/*****************************************************************
*
* Getting and checking directory configuration. Also checks the
*cp = '\0';
- /* We must not stat() filenames that may cause os-specific system
- * problems, such as "/file/aux" on DOS-abused filesystems.
- * So pretend that they do not exist by returning an ENOENT error.
- * This will force us to drop that part of the path and keep
- * looking back for a "real" file that exists, while still allowing
- * the "invalid" path parts within the PATH_INFO.
- */
- if (!ap_os_is_filename_valid(path)) {
- errno = ENOENT;
- rv = -1;
- }
- else {
- errno = 0;
- rv = stat(path, &r->finfo);
- }
+ /* We must not stat() filenames that may cause os-specific system
+ * problems, such as "/file/aux" on DOS-abused filesystems.
+ * So pretend that they do not exist by returning an ENOENT error.
+ * This will force us to drop that part of the path and keep
+ * looking back for a "real" file that exists, while still allowing
+ * the "invalid" path parts within the PATH_INFO.
+ */
+ if (!ap_os_is_filename_valid(path)) {
+ errno = ENOENT;
+ rv = -1;
+ }
+ else {
+ errno = 0;
+ /* ZZZ change to AP func for File Info */
+ rv = stat(path, &r->finfo);
+ }
if (cp != end)
*cp = '/';
- if (!rv) {
+ if (!rv) { /* ZZZ AP Status check here */
/*
* Aha! Found something. If it was a directory, we will search
* contents of that directory for a multi_match, so the PATH_INFO
* argument starts with the component after that.
*/
-
+ /* ZZZ use AP file type checking defines */
if (S_ISDIR(r->finfo.st_mode) && last_cp) {
r->finfo.st_mode = 0; /* No such file... */
cp = last_cp;
return rnew;
}
- res = ap_translate_name(rnew);
+ res = ap_run_translate_name(rnew);
if (res) {
rnew->status = res;
return rnew;
|| (res = location_walk(rnew))
|| ((ap_satisfies(rnew) == SATISFY_ALL
|| ap_satisfies(rnew) == SATISFY_NOSPEC)
- ? ((res = ap_check_access(rnew))
+ ? ((res = ap_run_access_checker(rnew))
|| (ap_some_auth_required(rnew)
- && ((res = ap_check_user_id(rnew))
- || (res = ap_check_auth(rnew)))))
- : ((res = ap_check_access(rnew))
+ && ((res = ap_run_check_user_id(rnew))
+ || (res = ap_run_auth_checker(rnew)))))
+ : ((res = ap_run_access_checker(rnew))
&& (!ap_some_auth_required(rnew)
- || ((res = ap_check_user_id(rnew))
- || (res = ap_check_auth(rnew)))))
+ || ((res = ap_run_check_user_id(rnew))
+ || (res = ap_run_auth_checker(rnew)))))
)
- || (res = ap_find_types(rnew))
+ || (res = ap_run_type_checker(rnew))
|| (res = ap_run_fixups(rnew))
) {
rnew->status = res;
return rnew;
}
if (rnew->per_dir_config == r->per_dir_config) {
- if ((res = ap_find_types(rnew)) || (res = ap_run_fixups(rnew))) {
+ if ((res = ap_run_type_checker(rnew)) || (res = ap_run_fixups(rnew))) {
rnew->status = res;
}
return rnew;
if (res
|| ((ap_satisfies(rnew) == SATISFY_ALL
|| ap_satisfies(rnew) == SATISFY_NOSPEC)
- ? ((res = ap_check_access(rnew))
+ ? ((res = ap_run_access_checker(rnew))
|| (ap_some_auth_required(rnew)
- && ((res = ap_check_user_id(rnew))
- || (res = ap_check_auth(rnew)))))
- : ((res = ap_check_access(rnew))
+ && ((res = ap_run_check_user_id(rnew))
+ || (res = ap_run_auth_checker(rnew)))))
+ : ((res = ap_run_access_checker(rnew))
&& (!ap_some_auth_required(rnew)
- || ((res = ap_check_user_id(rnew))
- || (res = ap_check_auth(rnew)))))
+ || ((res = ap_run_check_user_id(rnew))
+ || (res = ap_run_auth_checker(rnew)))))
)
- || (res = ap_find_types(rnew))
+ || (res = ap_run_type_checker(rnew))
|| (res = ap_run_fixups(rnew))
) {
rnew->status = res;
return;
}
- if ((access_status = ap_translate_name(r))) {
+ if ((access_status = ap_run_translate_name(r))) {
decl_die(access_status, "translate", r);
return;
}
return;
}
- if ((access_status = ap_header_parse(r))) {
+ if ((access_status = ap_run_header_parser(r))) {
ap_die(access_status, r);
return;
}
switch (ap_satisfies(r)) {
case SATISFY_ALL:
case SATISFY_NOSPEC:
- if ((access_status = ap_check_access(r)) != 0) {
+ if ((access_status = ap_run_access_checker(r)) != 0) {
decl_die(access_status, "check access", r);
return;
}
if (ap_some_auth_required(r)) {
- if (((access_status = ap_check_user_id(r)) != 0) || !ap_auth_type(r)) {
+ if (((access_status = ap_run_check_user_id(r)) != 0) || !ap_auth_type(r)) {
decl_die(access_status, ap_auth_type(r)
? "check user. No user file?"
: "perform authentication. AuthType not set!", r);
return;
}
- if (((access_status = ap_check_auth(r)) != 0) || !ap_auth_type(r)) {
+ if (((access_status = ap_run_auth_checker(r)) != 0) || !ap_auth_type(r)) {
decl_die(access_status, ap_auth_type(r)
? "check access. No groups file?"
: "perform authentication. AuthType not set!", r);
}
break;
case SATISFY_ANY:
- if (((access_status = ap_check_access(r)) != 0) || !ap_auth_type(r)) {
+ if (((access_status = ap_run_access_checker(r)) != 0) || !ap_auth_type(r)) {
if (!ap_some_auth_required(r)) {
decl_die(access_status, ap_auth_type(r)
? "check access"
: "perform authentication. AuthType not set!", r);
return;
}
- if (((access_status = ap_check_user_id(r)) != 0) || !ap_auth_type(r)) {
+ if (((access_status = ap_run_check_user_id(r)) != 0) || !ap_auth_type(r)) {
decl_die(access_status, ap_auth_type(r)
? "check user. No user file?"
: "perform authentication. AuthType not set!", r);
return;
}
- if (((access_status = ap_check_auth(r)) != 0) || !ap_auth_type(r)) {
+ if (((access_status = ap_run_auth_checker(r)) != 0) || !ap_auth_type(r)) {
decl_die(access_status, ap_auth_type(r)
? "check access. No groups file?"
: "perform authentication. AuthType not set!", r);
if (! (r->proxyreq
&& r->parsed_uri.scheme != NULL
&& strcmp(r->parsed_uri.scheme, "http") == 0) ) {
- if ((access_status = ap_find_types(r)) != 0) {
+ if ((access_status = ap_run_type_checker(r)) != 0) {
decl_die(access_status, "find types", r);
return;
}
void ap_process_request(request_rec *r)
{
- int old_stat;
-
- if (ap_extended_status)
- ap_time_process_request(r->connection->child_num, START_PREQUEST);
-
process_request_internal(r);
- old_stat = ap_update_child_status(r->connection->child_num,
- SERVER_BUSY_LOG, r);
-
/*
* We want to flush the last packet if this isn't a pipelining connection
* *before* we start into logging. Suppose that the logging causes a DNS
* this packet, then it'll appear like the link is stalled when really
* it's the application that's stalled.
*/
- ap_bhalfduplex(r->connection->client);
- ap_log_transaction(r);
-
- (void) ap_update_child_status(r->connection->child_num, old_stat, r);
- if (ap_extended_status)
- ap_time_process_request(r->connection->child_num, STOP_PREQUEST);
+ /* TODO: re-implement ap_bhalfduplex... not sure how yet */
+ /* //ap_bhalfduplex(r->connection->client); */
+ ap_run_log_transaction(r);
}
static table *rename_original_env(pool *p, table *t)
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
+#include "http_request.h"
typedef struct handlers_info {
char *name;
static table *hash_buckets[MIME_HASHSIZE];
-static void init_mime(server_rec *s, pool *p)
+static void mime_post_config(pool *p, pool *plog, pool *ptemp, server_rec *s)
{
configfile_t *f;
char l[MAX_STRING_LEN];
int x;
- char *types_confname = ap_get_module_config(s->module_config, &mime_module);
+ const char *types_confname = ap_get_module_config(s->module_config, &mime_module);
if (!types_confname)
types_confname = TYPES_CONFIG_FILE;
return OK;
}
-module MODULE_VAR_EXPORT mime_module =
+static void register_hooks(void)
{
- STANDARD_MODULE_STUFF,
- init_mime, /* initializer */
- create_mime_dir_config, /* dir config creator */
- merge_mime_dir_configs, /* dir config merger */
- NULL, /* server config */
- NULL, /* merge server config */
- mime_cmds, /* command table */
- NULL, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- find_ct, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ ap_hook_type_checker(find_ct,NULL,NULL,HOOK_MIDDLE);
+ ap_hook_post_config(mime_post_config,NULL,NULL,HOOK_MIDDLE);
+}
+
+module MODULE_VAR_EXPORT mime_module = {
+ STANDARD20_MODULE_STUFF,
+ create_mime_dir_config, /* create per-directory config structure */
+ merge_mime_dir_configs, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ mime_cmds, /* command table */
+ NULL, /* handlers */
+ register_hooks /* register hooks */
};
#include "http_config.h"
#include "http_core.h" /* For REMOTE_NAME */
#include "http_log.h"
+#include "http_protocol.h"
#include <limits.h>
module MODULE_VAR_EXPORT config_log_module;
cls->log_fd = ap_piped_log_write_fd(pl);
}
else {
- char *fname = ap_server_root_relative(p, cls->fname);
+ const char *fname = ap_server_root_relative(p, cls->fname);
if ((cls->log_fd = ap_popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, s,
"could not open transfer log file %s.", fname);
return NULL;
}
-static void init_config_log(server_rec *s, pool *p)
+static void init_config_log(pool *pc, pool *p, pool *pt, server_rec *s)
{
/* First, do "physical" server, which gets default log fd and format
* for the virtual servers, if they don't override...
for (s = s->next; s; s = s->next) {
open_multi_logs(s, p);
}
+#ifdef BUFFERED_LOGS
+ /* Now register the last buffer flush with the cleanup engine */
+ ap_register_cleanup(p , s, flush_all_logs, flush_all_logs);
+#endif
}
#ifdef BUFFERED_LOGS
-static void flush_all_logs(server_rec *s, pool *p)
+static void flush_all_logs(server_rec *s)
{
multi_log_state *mls;
array_header *log_list;
}
#endif
+static void register_hooks(void)
+{
+ ap_hook_open_logs(init_config_log,NULL,NULL,HOOK_MIDDLE);
+ ap_hook_log_transaction(multi_log_transaction,NULL,NULL,HOOK_MIDDLE);
+}
+
module MODULE_VAR_EXPORT config_log_module =
{
- STANDARD_MODULE_STUFF,
- init_config_log, /* initializer */
+ STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config */
NULL, /* merge per-dir config */
make_config_log_state, /* server config */
merge_config_log_state, /* merge server config */
config_log_cmds, /* command table */
NULL, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- multi_log_transaction, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
-#ifdef BUFFERED_LOGS
- flush_all_logs, /* child_exit */
-#else
- NULL,
-#endif
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
module action_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_action_dir_config, /* dir config creater */
merge_action_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
action_cmds, /* command table */
action_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ NULL /* register hooks */
};
#include "httpd.h"
#include "http_config.h"
+#include "http_request.h"
typedef struct {
char *real;
return DECLINED;
}
+static void register_hooks(void)
+{
+ static const char * const aszPre[]={ "mod_userdir.c",NULL };
+
+ ap_hook_translate_name(translate_alias_redir,aszPre,NULL,HOOK_MIDDLE);
+ ap_hook_fixups(fixup_redir,NULL,NULL,HOOK_MIDDLE);
+}
+
module MODULE_VAR_EXPORT alias_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_alias_dir_config, /* dir config creater */
merge_alias_dir_config, /* dir merger --- default is to override */
create_alias_config, /* server config */
merge_alias_config, /* merge server configs */
alias_cmds, /* command table */
NULL, /* handlers */
- translate_alias_redir, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- fixup_redir, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
{NULL}
};
-module MODULE_VAR_EXPORT dir_module =
-{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_dir_config, /* dir config creater */
- merge_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- dir_cmds, /* command table */
- dir_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+module MODULE_VAR_EXPORT dir_module = {
+ STANDARD20_MODULE_STUFF,
+ create_dir_config, /* create per-directory config structure */
+ merge_dir_configs, /* merge per-directory config structures */
+ NULL, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ dir_cmds, /* command table */
+ dir_handlers, /* handlers */
+ NULL /* register hooks */
};
module MODULE_VAR_EXPORT imap_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_imap_dir_config, /* dir config creater */
merge_imap_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
imap_cmds, /* command table */
imap_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ NULL /* register hooks */
};
{NULL}
};
+static void register_hooks(void)
+{
+ ap_hook_fixups(fix_encoding,NULL,NULL,HOOK_MIDDLE);
+ ap_hook_type_checker(handle_multi,NULL,NULL,HOOK_MIDDLE);
+}
+
module MODULE_VAR_EXPORT negotiation_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_neg_dir_config, /* dir config creator */
merge_neg_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
negotiation_cmds, /* command table */
negotiation_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- handle_multi, /* type_checker */
- fix_encoding, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
#include "httpd.h"
#include "http_config.h"
+#include "http_request.h"
module userdir_module;
return DECLINED;
}
+static void register_hooks(void)
+{
+ static const char * const aszSucc[]={ "mod_alias.c",NULL };
+
+ ap_hook_translate_name(translate_userdir,NULL,aszSucc,HOOK_MIDDLE);
+}
+
module userdir_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
create_userdir_config, /* server config */
NULL, /* merge server config */
userdir_cmds, /* command table */
NULL, /* handlers */
- translate_userdir, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
#include "httpd.h"
#include "http_config.h"
+#include "http_request.h"
typedef struct {
table *vars;
return OK;
}
+static void register_hooks(void)
+{
+ ap_hook_fixups(fixup_env_module,NULL,NULL,HOOK_MIDDLE);
+}
+
+
module MODULE_VAR_EXPORT env_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
create_env_dir_config, /* dir config creater */
merge_env_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server configs */
env_module_cmds, /* command table */
NULL, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- fixup_env_module, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
+ register_hooks /* register hooks */
};
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
+#include "http_protocol.h"
enum special {
SPECIAL_NOT,
return DECLINED;
}
+static void register_hooks(void)
+{
+ ap_hook_post_read_request(match_headers,NULL,NULL,HOOK_MIDDLE);
+}
+
module MODULE_VAR_EXPORT setenvif_module =
{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
+ STANDARD20_MODULE_STUFF,
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
create_setenvif_config, /* server config */
merge_setenvif_config, /* merge server configs */
setenvif_module_cmds, /* command table */
NULL, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* input header parse */
- NULL, /* child (process) initialization */
- NULL, /* child (process) rundown */
- match_headers /* post_read_request */
+ register_hooks /* register hooks */
};
+
#include "http_vhost.h"
#include "explain.h"
+HOOK_STRUCT(
+ HOOK_LINK(header_parser)
+ HOOK_LINK(pre_config)
+ HOOK_LINK(post_config)
+ HOOK_LINK(open_logs)
+ HOOK_LINK(child_init)
+)
+
+IMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
+IMPLEMENT_HOOK_VOID(pre_config,(pool *pconf,pool *plog,pool *ptemp),
+ (pconf,plog,ptemp))
+IMPLEMENT_HOOK_VOID(post_config,
+ (pool *pconf, pool *plog, pool *ptemp, server_rec *s),
+ (pconf,plog,ptemp,s))
+IMPLEMENT_HOOK_VOID(open_logs,
+ (pool *pconf, pool *plog, pool *ptemp, server_rec *s),
+ (pconf,plog,ptemp,s))
+IMPLEMENT_HOOK_VOID(child_init,(pool *pchild, server_rec *s),(pchild,s))
+
DEF_Explain
/****************************************************************
return create_empty_config(p);
}
-CORE_EXPORT(void *) ap_create_per_dir_config(pool *p)
+void *ap_create_conn_config(pool *p)
{
return create_empty_config(p);
}
-#ifdef EXPLAIN
-
-struct {
- int offset;
- char *method;
-} aMethods[] =
-
-{
-#define m(meth) { XtOffsetOf(module,meth),#meth }
- m(translate_handler),
- m(ap_check_user_id),
- m(auth_checker),
- m(type_checker),
- m(fixer_upper),
- m(logger),
- { -1, "?" },
-#undef m
-};
-
-char *ShowMethod(module *modp, int offset)
-{
- int n;
- static char buf[200];
-
- for (n = 0; aMethods[n].offset >= 0; ++n)
- if (aMethods[n].offset == offset)
- break;
- ap_snprintf(buf, sizeof(buf), "%s:%s", modp->name, aMethods[n].method);
- return buf;
-}
-#else
-#define ShowMethod(modp,offset)
-#endif
-
-/****************************************************************
- *
- * Dispatch through the modules to find handlers for various phases
- * of request handling. These are invoked by http_request.c to actually
- * do the dirty work of slogging through the module structures.
- */
-
-/*
- * Optimized run_method routines. The observation here is that many modules
- * have NULL for most of the methods. So we build optimized lists of
- * everything. If you think about it, this is really just like a sparse array
- * implementation to avoid scanning the zero entries.
- */
-static const int method_offsets[] =
-{
- XtOffsetOf(module, translate_handler),
- XtOffsetOf(module, ap_check_user_id),
- XtOffsetOf(module, auth_checker),
- XtOffsetOf(module, access_checker),
- XtOffsetOf(module, type_checker),
- XtOffsetOf(module, fixer_upper),
- XtOffsetOf(module, logger),
- XtOffsetOf(module, header_parser),
- XtOffsetOf(module, post_read_request)
-};
-#define NMETHODS (sizeof (method_offsets)/sizeof (method_offsets[0]))
-
-static struct {
- int translate_handler;
- int ap_check_user_id;
- int auth_checker;
- int access_checker;
- int type_checker;
- int fixer_upper;
- int logger;
- int header_parser;
- int post_read_request;
-} offsets_into_method_ptrs;
-
-/*
- * This is just one big array of method_ptrs. It's constructed such that,
- * for example, method_ptrs[ offsets_into_method_ptrs.logger ] is the first
- * logger function. You go one-by-one from there until you hit a NULL.
- * This structure was designed to hopefully maximize cache-coolness.
- */
-static handler_func *method_ptrs;
-
-/* routine to reconstruct all these shortcuts... called after every
- * add_module.
- * XXX: this breaks if modules dink with their methods pointers
- */
-static void build_method_shortcuts(void)
-{
- module *modp;
- int how_many_ptrs;
- int i;
- int next_ptr;
- handler_func fp;
-
- if (method_ptrs) {
- /* free up any previous set of method_ptrs */
- free(method_ptrs);
- }
-
- /* first we count how many functions we have */
- how_many_ptrs = 0;
- for (modp = top_module; modp; modp = modp->next) {
- for (i = 0; i < NMETHODS; ++i) {
- if (*(handler_func *) (method_offsets[i] + (char *) modp)) {
- ++how_many_ptrs;
- }
- }
- }
- method_ptrs = malloc((how_many_ptrs + NMETHODS) * sizeof(handler_func));
- if (method_ptrs == NULL) {
- fprintf(stderr, "Ouch! Out of memory in build_method_shortcuts()!\n");
- }
- next_ptr = 0;
- for (i = 0; i < NMETHODS; ++i) {
- /* XXX: This is an itsy bit presumptuous about the alignment
- * constraints on offsets_into_method_ptrs. I can't remember if
- * ANSI says this has to be true... -djg */
- ((int *) &offsets_into_method_ptrs)[i] = next_ptr;
- for (modp = top_module; modp; modp = modp->next) {
- fp = *(handler_func *) (method_offsets[i] + (char *) modp);
- if (fp) {
- method_ptrs[next_ptr++] = fp;
- }
- }
- method_ptrs[next_ptr++] = NULL;
- }
-}
-
-
-static int run_method(request_rec *r, int offset, int run_all)
-{
- int i;
-
- for (i = offset; method_ptrs[i]; ++i) {
- handler_func mod_handler = method_ptrs[i];
-
- if (mod_handler) {
- int result;
-
- result = (*mod_handler) (r);
-
- if (result != DECLINED && (!run_all || result != OK))
- return result;
- }
- }
-
- return run_all ? OK : DECLINED;
-}
-
-int ap_translate_name(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.translate_handler, 0);
-}
-
-int ap_check_access(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.access_checker, 1);
-}
-
-int ap_find_types(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.type_checker, 0);
-}
-
-int ap_run_fixups(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.fixer_upper, 1);
-}
-
-int ap_log_transaction(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.logger, 1);
-}
-
-int ap_header_parse(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.header_parser, 1);
-}
-
-int ap_run_post_read_request(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.post_read_request, 1);
-}
-
-/* Auth stuff --- anything that defines one of these will presumably
- * want to define something for the other. Note that check_auth is
- * separate from check_access to make catching some config errors easier.
- */
-
-int ap_check_user_id(request_rec *r)
-{
- return run_method(r, offsets_into_method_ptrs.ap_check_user_id, 0);
-}
-
-int ap_check_auth(request_rec *r)
+CORE_EXPORT(void *) ap_create_per_dir_config(pool *p)
{
- return run_method(r, offsets_into_method_ptrs.auth_checker, 0);
+ return create_empty_config(p);
}
/*
return HTTP_INTERNAL_SERVER_ERROR;
}
+int g_bDebugHooks;
+const char *g_szCurrentHookName;
+
+static void register_hooks(module *m)
+ {
+ if(m->register_hooks)
+ {
+ if(getenv("SHOW_HOOKS"))
+ {
+ printf("Registering hooks for %s\n",m->name);
+ g_bDebugHooks=1;
+ }
+ g_szCurrentHookName=m->name;
+ m->register_hooks();
+ }
+ }
+
/* One-time setup for precompiled modules --- NOT to be done on restart */
API_EXPORT(void) ap_add_module(module *m)
m->name = tmp;
}
#endif /*_OSD_POSIX*/
+
+ /* FIXME: is this the right place to call this? */
+ register_hooks(m);
}
/*
*/
for (m = ap_prelinked_modules; *m != NULL; m++)
ap_add_module(*m);
+
+ ap_sort_hooks();
}
API_EXPORT(const char *) ap_find_module_name(module *m)
"access to be safe");
return HTTP_FORBIDDEN;
}
- }
/* cache it */
new = ap_palloc(r->pool, sizeof(struct htaccess_result));
(*m->create_dir_config)(p, NULL));
}
-void ap_init_modules(pool *p, server_rec *s)
+void ap_post_config_hook(pool *pconf, pool *plog, pool *ptemp, server_rec *s)
{
- module *m;
-
- for (m = top_module; m; m = m->next)
- if (m->init)
- (*m->init) (s, p);
- build_method_shortcuts();
- init_handlers(p);
+ ap_run_post_config(pconf,plog,ptemp,s);
+ init_handlers(pconf);
}
-void ap_child_init_modules(pool *p, server_rec *s)
+void ap_child_init_hook(pool *pchild, server_rec *s)
{
- module *m;
-
- for (m = top_module; m; m = m->next)
- if (m->child_init)
- (*m->child_init) (s, p);
-}
-
-void ap_child_exit_modules(pool *p, server_rec *s)
-{
- module *m;
-
-#ifdef SIGHUP
- signal(SIGHUP, SIG_IGN);
-#endif
-#ifdef SIGUSR1
- signal(SIGUSR1, SIG_IGN);
-#endif
-
- for (m = top_module; m; m = m->next)
- if (m->child_exit)
- (*m->child_exit) (s, p);
+ /* TODO: uh this seems ugly, is there a better way? */
+ ap_child_init_alloc();
+ ap_run_child_init(pchild,s);
}
/********************************************************************
for (n = 0; ap_loaded_modules[n]; ++n)
printf(" %s\n", ap_loaded_modules[n]->name);
}
+