]> granicus.if.org Git - apache/blobdiff - server/core.c
Avoid calling access control hooks for internal requests with
[apache] / server / core.c
index ea7b14afb3e72b7337e943012756c977d86efb7e..f6c987643ce5ab988536f1deb52ea6797291dcc6 100644 (file)
@@ -389,7 +389,7 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
         conf->etag_add =
             (conf->etag_add & (~ new->etag_remove)) | new->etag_add;
         conf->etag_remove =
-            (conf->opts_remove & (~ new->etag_add)) | new->etag_remove;
+            (conf->etag_remove & (~ new->etag_add)) | new->etag_remove;
         conf->etag_bits =
             (conf->etag_bits & (~ conf->etag_remove)) | conf->etag_add;
     }
@@ -1164,6 +1164,9 @@ static const char *set_document_root(cmd_parms *cmd, void *dummy,
 
     /* Make it absolute, relative to ServerRoot */
     arg = ap_server_root_relative(cmd->pool, arg);
+    if (arg == NULL) {
+        return "DocumentRoot must be a directory";
+    }
 
     /* TODO: ap_configtestonly && ap_docrootcheck && */
     if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
@@ -1992,6 +1995,70 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     return NULL;
 }
+static const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+    const char *errmsg;
+    const char *endp = ap_strrchr_c(arg, '>');
+    int old_overrides = cmd->override;
+    char *old_path = cmd->path;
+    core_dir_config *conf;
+    const command_rec *thiscmd = cmd->cmd;
+    core_dir_config *c = mconfig;
+    ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION);
+    const char *condition;
+    int expr_err = 0;
+
+    if (err != NULL) {
+        return err;
+    }
+
+    if (endp == NULL) {
+        return unclosed_directive(cmd);
+    }
+
+    arg = apr_pstrndup(cmd->pool, arg, endp - arg);
+
+    if (!arg[0]) {
+        return missing_container_arg(cmd);
+    }
+
+    //cmd->path = "*";
+    condition = ap_getword_conf(cmd->pool, &arg);
+    /* Only if not an .htaccess file */
+    if (!old_path) {
+        cmd->override = OR_ALL|ACCESS_CONF;
+    }
+
+    /* initialize our config and fetch it */
+    conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
+                                 &core_module, cmd->pool);
+
+    conf->condition = ap_expr_parse(cmd->pool, condition, &expr_err);
+    if (expr_err) {
+        return "Cannot parse condition clause";
+    }
+
+    errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
+    if (errmsg != NULL)
+        return errmsg;
+
+    conf->d = cmd->path;
+    conf->d_is_fnmatch = 0;
+    conf->r = NULL;
+
+    ap_add_file_conf(c, new_file_conf);
+
+    if (*arg != '\0') {
+        return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
+                           "> arguments not supported.", NULL);
+    }
+
+    cmd->path = old_path;
+    cmd->override = old_overrides;
+
+    return NULL;
+}
 
 static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
 {
@@ -3036,7 +3103,7 @@ AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
                 /* uuh, too much. */
                 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                               "Request exceeded the limit of %d subrequest "
-                              "nesting levels due to probable confguration "
+                              "nesting levels due to probable configuration "
                               "error. Use 'LimitInternalRecursion' to increase "
                               "the limit if necessary. Use 'LogLevel debug' to "
                               "get a backtrace.", slimit);
@@ -3206,6 +3273,8 @@ AP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO,
   "Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"),
 AP_INIT_TAKE1("Define", set_define, NULL, RSRC_CONF,
               "Define the existance of a variable.  Same as passing -D to the command line."),
+AP_INIT_RAW_ARGS("<If", ifsection, NULL, OR_ALL,
+  "Container for directives to be conditionally applied"),
 
 /* Old resource config file commands */
 
@@ -3368,7 +3437,7 @@ AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF,
 #endif
 #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF,
-              ap_available_mutexes_string),
+              AP_AVAILABLE_MUTEXES_STRING),
 #endif
 #ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
 AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF,
@@ -3683,6 +3752,7 @@ static int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pte
 
     set_banner(pconf);
     ap_setup_make_content_type(pconf);
+    ap_setup_auth_internal(ptemp);
     return OK;
 }
 
@@ -3893,7 +3963,6 @@ static void register_hooks(apr_pool_t *p)
     /* FIXME: I suspect we can eliminate the need for these do_nothings - Ben */
     ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_fixups(core_override_type,NULL,NULL,APR_HOOK_REALLY_FIRST);
-    ap_hook_access_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
     ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
     APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL,
                       APR_HOOK_MIDDLE);