On 26/10/09 12:13, Richard W.M. Jones wrote:
On Mon, Oct 26, 2009 at 11:18:26AM +0000, Matthew Booth wrote:
> Problem is, if you don't put the magic in you're pushing the problem on
> to the library user.
This is not true. It's only used for the case where you are resolving
paths given to you by Windows -- eg. coming from a Windows
configuration file or from the Windows Registry. The case we use it
is precisely this: we read the Windows %systemroot% from NTLDR and
then have to resolve that against the filesystem. If Windows allowed
its root filesystem to be on ext3 it would work the same way.
.. or the guestfish user who types 'cat
win:c:\windows\system32\blah.txt' and doesn't get the result they
intended. Essentially you need to do this in 2 cases: you read a path
from a config file, or you're accessing a file whose location you
already know. In either case, the additional call is just untidiness.
In any other case, using case_sensitive_path is almost certainly
wrong, in fact not just slow but quite likely to be insecure too. You
don't want a Linux config file that specifies /etc/something to
randomly pick /etc/SOMETHING.
It's a very good point. You can fix this, though. When iterating down
the directory structure, you'll open a file to check if it's a
directory. At the same time, to fstatfs() to check what filesystem it's
on. By doing this you can choose directory-by-directory whether or not
to be case-sensitive. This should always be safe.
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
M: +44 (0)7977 267231
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490