| 2450 | #endif |
| 2451 | |
| 2452 | static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg) |
| 2453 | { |
| 2454 | const char *errmsg; |
| 2455 | const char *endp = ap_strrchr_c(arg, '>'); |
| 2456 | int old_overrides = cmd->override; |
| 2457 | char *old_path = cmd->path; |
| 2458 | core_dir_config *conf; |
| 2459 | ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool); |
| 2460 | ap_regex_t *r = NULL; |
| 2461 | const command_rec *thiscmd = cmd->cmd; |
| 2462 | |
| 2463 | const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT); |
| 2464 | if (err != NULL) { |
| 2465 | return err; |
| 2466 | } |
| 2467 | |
| 2468 | if (endp == NULL) { |
| 2469 | return unclosed_directive(cmd); |
| 2470 | } |
| 2471 | |
| 2472 | arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg); |
| 2473 | |
| 2474 | if (!arg[0]) { |
| 2475 | return missing_container_arg(cmd); |
| 2476 | } |
| 2477 | |
| 2478 | cmd->path = ap_getword_conf(cmd->pool, &arg); |
| 2479 | cmd->override = OR_ALL|ACCESS_CONF; |
| 2480 | |
| 2481 | if (!strcmp(cmd->path, "~")) { |
| 2482 | cmd->path = ap_getword_conf(cmd->pool, &arg); |
| 2483 | if (!cmd->path) |
| 2484 | return "<Directory ~ > block must specify a path"; |
| 2485 | r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); |
| 2486 | if (!r) { |
| 2487 | return "Regex could not be compiled"; |
| 2488 | } |
| 2489 | } |
| 2490 | else if (thiscmd->cmd_data) { /* <DirectoryMatch> */ |
| 2491 | r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); |
| 2492 | if (!r) { |
| 2493 | return "Regex could not be compiled"; |
| 2494 | } |
| 2495 | } |
| 2496 | else if (strcmp(cmd->path, "/") != 0) |
| 2497 | { |
| 2498 | char *newpath; |
| 2499 | |
| 2500 | /* |
| 2501 | * Ensure that the pathname is canonical, and append the trailing / |
| 2502 | */ |
| 2503 | apr_status_t rv = apr_filepath_merge(&newpath, NULL, cmd->path, |
| 2504 | APR_FILEPATH_TRUENAME, cmd->pool); |
| 2505 | if (rv != APR_SUCCESS && rv != APR_EPATHWILD) { |
| 2506 | return apr_pstrcat(cmd->pool, "<Directory \"", cmd->path, |
| 2507 | "\"> path is invalid.", NULL); |
| 2508 | } |
| 2509 |
nothing calls this directly
no test coverage detected