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

Eric Blake eblake at redhat.com
Thu May 20 16:45:28 UTC 2010


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100520/191eca5f/attachment-0001.sig>


More information about the libvir-list mailing list