#include "httpd.h" #include "http_config.h" #include "http_core.h" #include "http_log.h" #include "http_protocol.h" #include "http_vhost.h" #include "apr_strings.h" module AP_MODULE_DECLARE_DATA ignore_authcomponent_module; typedef struct { int enable; } ignore_authcomponent_server_cfg; void *ignore_authcomponent_create_dir_cfg (apr_pool_t *p, char *dummy) { ignore_authcomponent_server_cfg *cfg = (ignore_authcomponent_server_cfg *)apr_pcalloc (p, sizeof(ignore_authcomponent_server_cfg)); if (!cfg) return NULL; cfg->enable = 0; return (void *)cfg; } static const char *ignore_authcomponent_enable (cmd_parms *cmd, void *config, int flag) { server_rec *s = cmd->server; ignore_authcomponent_server_cfg *cfg = (ignore_authcomponent_server_cfg *)config; if (!cfg) return NULL; cfg->enable = flag; return NULL; } static int ignore_authcomponent (request_rec *r) { ignore_authcomponent_server_cfg *cfg = (ignore_authcomponent_server_cfg *)ap_get_module_config (r->per_dir_config, &ignore_authcomponent_module); if (!cfg) return DECLINED; if (!cfg->enable) return DECLINED; if (!r->parsed_uri.hostinfo) return DECLINED; char *org_path = r->parsed_uri.path; r->parsed_uri.path = apr_psprintf (r->connection->pool, "/%s%s", r->parsed_uri.hostinfo, r->parsed_uri.path); if (r->uri == org_path) r->uri = r->parsed_uri.path; return DECLINED; } static const command_rec ignore_authcomponent_cmds[] = { AP_INIT_FLAG ( "IgnoreAuthComponent", ignore_authcomponent_enable, NULL, RSRC_CONF, "Ignore URI Authoritiy Component as defined in RFC 2396, 3.2" ), { NULL } }; static void register_hooks(apr_pool_t *p) { ap_hook_post_read_request (ignore_authcomponent, NULL, NULL, APR_HOOK_FIRST); } module AP_MODULE_DECLARE_DATA ignore_authcomponent_module = { STANDARD20_MODULE_STUFF, ignore_authcomponent_create_dir_cfg, NULL, NULL, NULL, ignore_authcomponent_cmds, register_hooks, };