[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] storage: Sanitize pool target paths

On 05/20/2010 10:34 AM, Eric Blake wrote:
>> If we're going todo this shouldn't we resolve symlinks, and
>> canonicalize any '..' or '.' components in the path. IIRC
>> gnulib had something for this ?
> Gnulib has canonicalize-lgpl, but that only succeeds on existing file
> names.  If you want to canonicalize a name without regards to existence,
> there is canonicalize(), but it is GPL, so we can't use it. :(

Clarification - there is the 'canonicalize' module, which is GPL, and
provides the canonicalize_filename_mode() interface which allows you to
choose how to deal with non-existent files.

Then there is the 'canonicalize-lgpl' module, which is LGPLv2+, and
provides both the realpath() and canonicalize_file_name() functions, but
both of those require the file to exist.  Also, realpath() is broken by
design unless you pass a NULL argument, at which point you might as well
be using canonicalize_file_name() wrapper for one less argument.

But both of those modules remove all symlinks - gnulib does not yet have
any intermediate module that removes just redundant / and . while
keeping symlinks intact.  And since that operation is just textual,
maybe it _does_ make sense to turn it into a gnulib module.

Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]