Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 524731739A for ; Mon, 2 Mar 2015 14:30:05 +0000 (UTC) Received: (qmail 86652 invoked by uid 500); 2 Mar 2015 14:30:04 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 86589 invoked by uid 500); 2 Mar 2015 14:30:04 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 86578 invoked by uid 99); 2 Mar 2015 14:30:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 14:30:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of minfrin@sharp.fm designates 80.168.143.5 as permitted sender) Received: from [80.168.143.5] (HELO monica.sharp.fm) (80.168.143.5) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 14:29:59 +0000 Received: from [192.168.88.159] (unknown [192.168.88.159]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: minfrin@sharp.fm) by monica.sharp.fm (Postfix) with ESMTPSA id 700A080784 for ; Mon, 2 Mar 2015 14:29:37 +0000 (GMT) From: Graham Leggett Content-Type: multipart/mixed; boundary="Apple-Mail=_45D0CC1C-F3FE-48EC-AA5C-62586ED908E8" Subject: [Patch] DirectoryMatch/LocationMatch and configuration paths Message-Id: <05B811A5-1B6E-4417-BC3B-172673A78817@sharp.fm> Date: Mon, 2 Mar 2015 16:29:36 +0200 To: dev@httpd.apache.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) X-Mailer: Apple Mail (2.2070.6) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_45D0CC1C-F3FE-48EC-AA5C-62586ED908E8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi all, A long standing problem in httpd has been the behaviour of the = LocationMatch/DirectoryMatch with respect to the path passed to the per = directory configuration. The problem is summed up by the following = comment in http_config.h: /** If configuring for a directory, pathname of that directory. * NOPE! That's what it meant previous to the existence of = <Files>, * <Location> and regex matching. Now the only usefulness = that can be * derived from this field is whether a command is being called in a * server context (path =3D=3D NULL) or being called in a dir = context * (path !=3D NULL). */ char *path; In the case of LocationMatch and DirectoryMatch, the value of path is = simply the raw regular expression. The problem is that some modules - mod_dav and mod_dav_svn in = particular, *do* use this path, and right now it means that if =E2=80=9CDA= V on=E2=80=9D or =E2=80=9CDAV svn=E2=80=9D finds itself in a = LocationMatch container, the regex is used as the base path, and the = request fails. I have created a patch that adds an optional path in front of the = regular expression in LocationMatch/DirectoryMatch/FileMatch, so you can = do this: [^/]+)/> DAV on This gives mod_dav the option to receive a valid path, and so work = inside DirectoryMatch (and mod_dav_svn has the option to receive a valid = path, and so work inside LocationMatch, more on that in follow = messages). The above config does have a limitation though, in that all possible = matches on CUSTOMERNAME all end up sharing the same dav filesystem. What = if you want one dedicated dav filesystem per customer? Next patch = addresses that. Regards, Graham =E2=80=94 --Apple-Mail=_45D0CC1C-F3FE-48EC-AA5C-62586ED908E8 Content-Disposition: attachment; filename=httpd-core-regex3.patch Content-Type: application/octet-stream; name="httpd-core-regex3.patch" Content-Transfer-Encoding: 7bit Index: server/core.c =================================================================== --- server/core.c (revision 1663123) +++ server/core.c (working copy) @@ -2200,6 +2200,7 @@ char *old_path = cmd->path; core_dir_config *conf; ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool); + const char *regex; ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; @@ -2223,15 +2224,20 @@ if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - if (!cmd->path) - return " block must specify a path"; - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + if (!*cmd->path) { + return " block must specify a regex"; + } + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED | USE_ICASE); if (!r) { return "Regex could not be compiled"; } } else if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED | USE_ICASE); if (!r) { return "Regex could not be compiled"; } @@ -2284,8 +2290,8 @@ ap_add_per_dir_conf(cmd->server, new_dir_conf); if (*arg != '\0') { - return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name, + "> arguments not (yet) supported: ", arg, NULL); } cmd->path = old_path; @@ -2301,6 +2307,7 @@ int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; + const char *regex; ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool); @@ -2323,14 +2330,21 @@ cmd->override = OR_ALL|ACCESS_CONF; if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED); if (!r) { return "Regex could not be compiled"; } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED); + if (!*cmd->path) { + return " block must specify a regex"; + } + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED); if (!r) { return "Regex could not be compiled"; } @@ -2356,8 +2370,8 @@ ap_add_per_url_conf(cmd->server, new_url_conf); if (*arg != '\0') { - return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name, + "> arguments not (yet) supported: ", arg, NULL); } cmd->path = old_path; @@ -2373,6 +2387,7 @@ int old_overrides = cmd->override; char *old_path = cmd->path; core_dir_config *conf; + const char *regex; ap_regex_t *r = NULL; const command_rec *thiscmd = cmd->cmd; ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool); @@ -2400,14 +2415,18 @@ } if (thiscmd->cmd_data) { /* */ - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED | USE_ICASE); if (!r) { return "Regex could not be compiled"; } } else if (!strcmp(cmd->path, "~")) { cmd->path = ap_getword_conf(cmd->pool, &arg); - r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE); + regex = ap_getword_conf(cmd->pool, &arg); + r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path, + AP_REG_EXTENDED | USE_ICASE); if (!r) { return "Regex could not be compiled"; } @@ -2443,8 +2462,8 @@ ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf); if (*arg != '\0') { - return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, - "> arguments not (yet) supported.", NULL); + return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name, + "> arguments not (yet) supported: ", arg, NULL); } cmd->path = old_path; @@ -2530,8 +2549,8 @@ return errmsg; if (*arg != '\0') { - return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name, - "> arguments not supported.", NULL); + return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name, + "> arguments not supported: ", arg, NULL); } cmd->path = old_path; --Apple-Mail=_45D0CC1C-F3FE-48EC-AA5C-62586ED908E8--