Bug 1151897

Summary: virt-ls --checksum: checksum for soft link is wrong, the soft link have no checksum value output
Product: Red Hat Enterprise Linux 7 Reporter: Lingfei Kong <lkong>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.1CC: leiwang, mbooth, ptoscano, wshi, yuliu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1151898 (view as bug list) Environment:
Last Closed: 2014-10-20 09:32:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1151898    

Description Lingfei Kong 2014-10-13 02:28:06 UTC
Description of problem:
checksum for soft link is wrong, the soft link have no checksum value output. 
Both md5sum and sha*sum can give checksum value for soft link. So the best way is also provide checksum value for soft link.

Version-Release number of selected component (if applicable):
libguestfs-1.27.62-1.1.el7


How reproducible:
100%


Steps to Reproduce:
#virt-ls -a rhel.img /etc -lR --checksum


Actual results:
.....
- 0644        447 dbc1e6da7574717bd3f7a02f98252c4c /etc/selinux/config
...
l 0777         17 /etc/sysconfig/selinux -> ../selinux/config
....


Expected results:
.....
- 0644        447 dbc1e6da7574717bd3f7a02f98252c4c /etc/selinux/config
...
l 0777         17 dbc1e6da7574717bd3f7a02f98252c4c /etc/sysconfig/selinux  -> ../selinux/config
....


Additional info:

Comment 1 Pino Toscano 2014-10-17 09:56:27 UTC
Checksum is currently done only for regular files, and symlinks are not regular files.

I do not think we should dereference them, since
a) if the symlink target exists in the guest, its checksum would be calculated more than once (once for the file itself, plus once for every symlink pointing to it)
b) if the symlink target does not exists, then there would be a mismatch in the output (one field less) between such kind of symlink and those pointing to existing files

Another case is that you might list just a subdirectory of a guest, with a symlink in it pointing to a file outside that subdirectory; say:
  $ virt-ls ... /etc
  [...]
  l 0777         10 /etc/vmlinuz  -> ../vmlinuz
then I think it still might be correct to not look at anything outout the subdirectory requested.

Comment 2 Lingfei Kong 2014-10-18 03:06:56 UTC
(In reply to Pino Toscano from comment #1)
> Checksum is currently done only for regular files, and symlinks are not
> regular files.
> 
> I do not think we should dereference them, since
> a) if the symlink target exists in the guest, its checksum would be
> calculated more than once (once for the file itself, plus once for every
> symlink pointing to it)
> b) if the symlink target does not exists, then there would be a mismatch in
> the output (one field less) between such kind of symlink and those pointing
> to existing files
> 
> Another case is that you might list just a subdirectory of a guest, with a
> symlink in it pointing to a file outside that subdirectory; say:
>   $ virt-ls ... /etc
>   [...]
>   l 0777         10 /etc/vmlinuz  -> ../vmlinuz
> then I think it still might be correct to not look at anything outout the
> subdirectory requested.

Thanks for your explanation. I agree with you to close it as NOTABUG.

Comment 3 Richard W.M. Jones 2014-10-20 09:32:41 UTC
Closing per comment 2.