Received: (from majordom@localhost) by hyperreal.org (8.8.5/8.8.5) id BAA09469; Thu, 14 Aug 1997 01:05:03 -0700 (PDT) Received: from twinlark.arctic.org (twinlark.arctic.org [204.62.130.91]) by hyperreal.org (8.8.5/8.8.5) with SMTP id BAA09463 for ; Thu, 14 Aug 1997 01:05:00 -0700 (PDT) Received: (qmail 8550 invoked by uid 500); 14 Aug 1997 07:56:10 -0000 Date: Thu, 14 Aug 1997 00:56:09 -0700 (PDT) From: Dean Gaudet To: Apache List Subject: Re: Win32 name canonicalisation In-Reply-To: <33EDB91C.8541014F@algroup.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org 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 > #include > #include > > 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 >