Bug 693064

Summary: Symbolic links on ntfs-3g are not followed correctly by some commands
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: stenavin, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2011-04-02 09:58:17 UTC
Description of problem:

[This really a bug or shortcoming in ntfs-3g, and is caused by the
stupid way that symlinks are implemented in NTFS itself.  For some
background on this see
http://libguestfs.org/guestfs.3.html#symlinks_on_ntfs_3g_filesystems ]

Paths that contain elements that are symbolic links are not
followed correctly by some commands.  It depends on whether
the command happens to be implemented using a chroot or not.

For a full example see "Steps to reproduce" below.

If /foo is a symbolic link to (say) C:\baz then ntfs-3g rewrites
/foo as a symbolic link to /sysroot//baz (actually incorporating
the mount point in the path itself).  This works fine as long
as we don't chroot:

 /sysroot/foo/bar -> /sysroot//baz/bar

but if a command does a chroot then it fails:

 /foo/bar -> /sysroot//baz/bar  ** fail: /sysroot not found **

Version-Release number of selected component (if applicable):

libguestfs 1.9.16

How reproducible:

100% on NTFS filesystems, for paths that contain symbolic links.

Steps to Reproduce:

You need a Windows 7 guest to follow these steps, because
on Windows 7, "/Documents and Settings/" is no longer a real
directory, but a symbolic link to /Users/

1. Open the Windows 7 guest image using guestfish:

# guestfish --ro -i -d Win7Guest
><fs> ll "/Documents and Settings"
lrwxrwxrwx 2 root root 60 Jul 14  2009 /sysroot/Documents and Settings -> /sysroot//Users

2. Run 'file' on "/Documents and Settings/Default/NTUSER.DAT".  Note
I'm using win:... rewriting in guestfish (see:
http://libguestfs.org/guestfish.1.html#windows_paths )

><fs> file "win:/Documents and Settings/Default/NTUSER.DAT"
MS Windows registry file, NT/2000 or above

3. Try to download the same file:

><fs> download "win:/Documents and Settings/Default/NTUSER.DAT" /tmp/NTUSER.DAT
libguestfs: error: download: /Documents and Settings/Default/NTUSER.DAT: No such file or directory
  
Actual results:

Error message.

Expected results:

All commands should work consistently on NTFS-3g filesystems,
including on paths that contain symbolic links.