You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2004/07/23 23:12:36 UTC

Please define "canonicalize" in httpd.h

from httpd.h:

struct request_rec {
  ...
     /* XXX: What does this mean? Please define "canonicalize" -aaron */
     /** The true filename, we canonicalize r->filename if these don't 
match */
     char *canonical_filename;

I'm asking the same question. It looks like it's only different from 
'filename' #ifdef CASE_BLIND_FILESYSTEM (see server/request.c). But I'm 
not quite sure what it does. Any explanations?

Thanks

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Please define "canonicalize" in httpd.h

Posted by Stas Bekman <st...@stason.org>.
William A. Rowe, Jr. wrote:
> At 02:35 PM 8/1/2004, Stas Bekman wrote:
> 
>>John Rowe wrote:
>>
>>>>Please define "canonicalize" 
>>>
>>>In the context of case-insensitive file systems, it's often the case
>>>that a file is given the canonical name that it was created with
>>>("MyFile") with all other capitalisations ("myfile", "myfilE") being
>>>alternative names for the same filename. 
>>
>>Thanks John. I understand all that. My request was to fix the following XXX in httpd.h:
>>
>>struct request_rec {
>>...
>>   /* XXX: What does this mean? Please define "canonicalize" -aaron */
>>   /** The true filename, we canonicalize r->filename if these don't match */
>>   char *canonical_filename;
>>
>>and explain there when one should use canonical_filename, instead of filename. The comment:
>>
>>/** The true filename, we canonicalize r->filename if these don't match */
>>
>>suggests that r->filename is getting canonized as well.
> 
> 
> Yes - you don't generally play with r->canonical_filename (in fact, it should
> become private) unless you are the module who is responsible for it.  Only
> things like the core file handler, which happens to dig through the segments,
> eliminate /foo/../ sorts of elements, and checks the filesystem case as it
> goes will bother to set this.
> 
> When we hit the dir_walk on win32, the system compares filename to the
> canonical_filename.  If they match - dir_walk won't bother to re-canonicalize
> the (matching) segments of the name.  This, at least, is the theory.
> 
> This should possibly be better 'hidden' - in the sense that it is probably
> just confusing cruft to most module authors.

Excellent. Thanks Bill!

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Please define "canonicalize" in httpd.h

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 02:35 PM 8/1/2004, Stas Bekman wrote:
>John Rowe wrote:
>>>Please define "canonicalize" 
>>
>>In the context of case-insensitive file systems, it's often the case
>>that a file is given the canonical name that it was created with
>>("MyFile") with all other capitalisations ("myfile", "myfilE") being
>>alternative names for the same filename. 
>
>Thanks John. I understand all that. My request was to fix the following XXX in httpd.h:
>
>struct request_rec {
> ...
>    /* XXX: What does this mean? Please define "canonicalize" -aaron */
>    /** The true filename, we canonicalize r->filename if these don't match */
>    char *canonical_filename;
>
>and explain there when one should use canonical_filename, instead of filename. The comment:
>
>/** The true filename, we canonicalize r->filename if these don't match */
>
>suggests that r->filename is getting canonized as well.

Yes - you don't generally play with r->canonical_filename (in fact, it should
become private) unless you are the module who is responsible for it.  Only
things like the core file handler, which happens to dig through the segments,
eliminate /foo/../ sorts of elements, and checks the filesystem case as it
goes will bother to set this.

When we hit the dir_walk on win32, the system compares filename to the
canonical_filename.  If they match - dir_walk won't bother to re-canonicalize
the (matching) segments of the name.  This, at least, is the theory.

This should possibly be better 'hidden' - in the sense that it is probably
just confusing cruft to most module authors.

Bill



Re: Please define "canonicalize" in httpd.h

Posted by Stas Bekman <st...@stason.org>.
John Rowe wrote:
>>Please define "canonicalize" 
> 
> 
> If the same thing can be referred to by a number of different names and
> the convention is that one is the "one true", or canonical, name and the
> others are mere aliases then canonicalisation (or canonicalization for a
> non-Brit) is the process of translating a name into the canonical name
> of that object. Of course this assumes that no two objects can have the
> same name.
> 
> In the context of case-insensitive file systems, it's often the case
> that a file is given the canonical name that it was created with
> ("MyFile") with all other capitalisations ("myfile", "myfilE") being
> alternative names for the same filename. 
> 
> Of course, the situation is complicated not only by symlinks but also
> that in unix the same file can have many filenames. The normal
> canonicalisation for a file, as opposed to filename, is (device, inode
> number) but that's not always very useful: for security reasons you
> can't actually open a file from its device and inode number.

Thanks John. I understand all that. My request was to fix the following 
XXX in httpd.h:

struct request_rec {
  ...
     /* XXX: What does this mean? Please define "canonicalize" -aaron */
     /** The true filename, we canonicalize r->filename if these don't 
match */
     char *canonical_filename;

and explain there when one should use canonical_filename, instead of 
filename. The comment:

/** The true filename, we canonicalize r->filename if these don't match */

suggests that r->filename is getting canonized as well.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Please define "canonicalize" in httpd.h

Posted by John Rowe <ro...@excc.ex.ac.uk>.
> Please define "canonicalize" 

If the same thing can be referred to by a number of different names and
the convention is that one is the "one true", or canonical, name and the
others are mere aliases then canonicalisation (or canonicalization for a
non-Brit) is the process of translating a name into the canonical name
of that object. Of course this assumes that no two objects can have the
same name.

In the context of case-insensitive file systems, it's often the case
that a file is given the canonical name that it was created with
("MyFile") with all other capitalisations ("myfile", "myfilE") being
alternative names for the same filename. 

Of course, the situation is complicated not only by symlinks but also
that in unix the same file can have many filenames. The normal
canonicalisation for a file, as opposed to filename, is (device, inode
number) but that's not always very useful: for security reasons you
can't actually open a file from its device and inode number.

John