[Libguestfs] [PATCH] daemon: scrub-file: resolve the path before calling scrub (RHBZ#1099490).

Richard W.M. Jones rjones at redhat.com
Tue May 20 14:56:16 UTC 2014


On Tue, May 20, 2014 at 03:33:31PM +0200, Pino Toscano wrote:
> Resolve the given path within the chroot, so scrub can be invoked
> outside the chroot on an already-resolved path.
> Given that realpath is used, its availability is checked manually,
> since scrub-file already depends on the "scrub" feature. Slightly ugly,
> but on the other hand realpath is generally available nowadays, so the
> check should not be failing.
> 
> Add few tests in scrub-file for this and other similar issues.

The realpath test was added (commit a86eb0e0d2c67e2) at a time when we
thought it would be a good idea to have the daemon run on Windows.
Since no one thinks that's a good idea any longer, I think you could
prepend this commit with one which removes tests for realpath /
HAVE_REALPATH and hard-codes optgroup_realpath_available() == 1.

On to this patch ...

Is it possible to make this change more generic so in future it could
be applied to other functions?

- Would it make sense to have a 'sysroot_realpath' library function to
  replace 'sysroot_path' in certain functions?

- Would it even make sense to modify 'sysroot_path' so it just calls
  realpath?

(I suspect not the second one because there are likely to be calls
like 'lstat' that want to see the symlink, not the final path.)

The concept behind the patch is good, I'd just like to see if we can
apply this in more places in future.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list