httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: Win32 name canonicalisation
Date Thu, 14 Aug 1997 07:56:09 GMT
I haven't read this thread at all yet.  But I did ask about this exact
problem while I was at the Usenix NT conference this week.  I got answers
from a fellow @microsoft, and fellows from Softway (who make OpenNT).  The
suggestions were:

- use a heuristic to detect shortname components -- the existance of a ~
    when a component contains the ~ do the short -> long
    conversion, otherwise assume it's canonical

- find the registry setting that disables shortnames on ntfs partitions,
    dictate that webservers have to change this and run on ntfs

- decree that shortnames are not valid components period.  Do a long->short
    (this is the cheap one right?) conversion on all components and
    if they differ then deny access.

I personally like the last one.

Dean

On Sun, 10 Aug 1997, Ben Laurie wrote:

> Here's a not particularly efficient implementation of name
> canonicalisation for Win32. Now all we need to do is figure out where to
> slot it :-)
> 
> It isn't Apache-ised, just written as a simple test console program.
> 
> Cheers,
> 
> Ben.
> 
> #include <windows.h>
> #include <stdio.h>
> #include <assert.h>
> 
> void sub_canonical_filename(char *szCanon,const char *szFile)
> {
>     char buf[_MAX_PATH];
>     int n;
>     char *szFilePart;
> 
>     n=GetFullPathName(szFile,sizeof buf,buf,&szFilePart);
>     assert(n);
>     assert(n < sizeof buf);
> 
>     WIN32_FIND_DATA d;
> 
>     HANDLE h=FindFirstFile(buf,&d);
>     assert(h != INVALID_HANDLE_VALUE);
>     FindClose(h);
> 
>     if(szFilePart != buf+3) // "x:\" == 4
>     {
> 	char b2[_MAX_PATH];
> 	assert(szFilePart > buf+3);
> 
> 	szFilePart[-1]='\0';
> 	sub_canonical_filename(b2,buf);
> 
> 	strcpy(szCanon,b2);
> 	strcat(szCanon,"/");
> 	strcat(szCanon,d.cFileName);
>     }
>     else
>     {
> 	strcpy(szCanon,buf);
> 	szCanon[2]='/';
> 	szCanon[3]='\0';
> 	strcat(szCanon,d.cFileName);
>     }
> }
> 
> char *canonical_filename(const char *szFile)
> {
>     char buf[_MAX_PATH];
> 
>     sub_canonical_filename(buf,szFile);
>     strlwr(buf);
>     return strdup(buf);
> }
> 
> void main(int argc,char **argv)
> {
>     char *szFile=argv[1];
> 
>     printf("%s\n",canonical_filename(szFile));
> }
> 
> -- 
> Ben Laurie                Phone: +44 (181) 994 6435  Email:
> ben@algroup.co.uk
> Freelance Consultant and  Fax:   +44 (181) 994 6472
> Technical Director        URL: http://www.algroup.co.uk/Apache-SSL
> A.L. Digital Ltd,         Apache Group member (http://www.apache.org)
> London, England.          Apache-SSL author
> 


Mime
View raw message