You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Randy Terbush <ra...@zyzzyva.com> on 1997/09/04 03:21:54 UTC
Re: Auth failure in Win32
What about support for UNC pathnames?
\\server\sharename
> On Mon, 1 Sep 1997, Ben Laurie wrote:
>
> > I don't see why we should try to make it work. Just accept that
> > pathnames on Win32 look like <drive>:/<path>. It's the way it is. You
> > don't expect Apache to warn you that <DirectoryMatch ^x$> is a stupid
> > thing to do, so why expect it to warn about <DirectoryMatch ^/$>?
> >
> > I admit I'm reversing my previous position :-)
>
> Yes, well... okay. But pathnames on Win32 don't always look like
> <drive>:/<path>, where <drive> and <path> are lowercase strings. In fact,
> the Windows tools nearly always use uppercase drive letters. I agree that
> it's fine to use lowercase representations internally, but I don't think
> we should just say "oh, all <Directory> entries have to be lowercase, and
> with lowercase drive letters," and expect people to do so. Especially
> since no other Windows program does, and even the DirectoryRoot and Alias
> and such functions do not (Apache will expand it out after translating
> the URL).
>
> So I think a patch like this one is appropriate:
>
> Index: main/http_core.c
> ===================================================================
> RCS file: /export/home/cvs/apachen/src/main/http_core.c,v
> retrieving revision 1.118
> diff -u -r1.118 http_core.c
> --- http_core.c 1997/09/02 16:12:08 1.118
> +++ http_core.c 1997/09/03 23:46:25
> @@ -753,6 +753,16 @@
> return NULL;
> }
>
> +/* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that
> + * people don't get bitten by wrong-cased regex matches
> + */
> +
> +#ifdef WIN32
> +#define USE_ICASE REG_ICASE
> +#else
> +#define USE_ICASE 0
> +#endif
> +
> static const char end_dir_magic[] = "</Directory> outside of any <Directory> section";
>
> const char *end_dirsection (cmd_parms *cmd, void *dummy) {
> @@ -782,11 +792,15 @@
> cmd->override = OR_ALL|ACCESS_CONF;
>
> if (cmd->info) { /* <DirectoryMatch> */
> - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
> + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
> }
> else if (!strcmp(cmd->path, "~")) {
> cmd->path = getword_conf (cmd->pool, &arg);
> - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
> + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
> + }
> + else {
> + /* Ensure that the pathname is canonical */
> + cmd->path = os_canonical_filename(cmd->pool, cmd->path);
> }
>
> errmsg = srm_command_loop (cmd, new_dir_conf);
> @@ -881,16 +895,21 @@
> if (cmd->info) { /* <FilesMatch> */
> if (old_path && cmd->path[0] != '/' && cmd->path[0] != '^')
> cmd->path = pstrcat(cmd->pool, "^", old_path, cmd->path, NULL);
> - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
> + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
> }
> else if (!strcmp(cmd->path, "~")) {
> cmd->path = getword_conf (cmd->pool, &arg);
> if (old_path && cmd->path[0] != '/' && cmd->path[0] != '^')
> cmd->path = pstrcat(cmd->pool, "^", old_path, cmd->path, NULL);
> - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
> + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
> + }
> + else {
> + if (old_path && cmd->path[0] != '/')
> + cmd->path = pstrcat(cmd->pool, old_path, cmd->path, NULL);
> +
> + /* Ensure that the pathname is canonical */
> + cmd->path = os_canonical_filename(cmd->pool, cmd->path);
> }
> - else if (old_path && cmd->path[0] != '/')
> - cmd->path = pstrcat(cmd->pool, old_path, cmd->path, NULL);
>
> errmsg = srm_command_loop (cmd, new_file_conf);
> if (errmsg != end_file_magic) return errmsg;
>
>
> -- Alexei Kosut <ak...@organic.com>