Red Hat Bugzilla – Bug 1174551
"lstatnslist" and "lstatlist" don't give an error if the API is used wrongly
Last modified: 2016-11-03 13:48:44 EDT
Description of problem: As described in the man page: "lstatnslist/lstatlist path names", where all files are in the directory "path". "names" is the list of files from this directory. But In RHEL7.1, results have nothing to do with "path" in the cases where "name" is absolute paths. Version-Release number of selected component (if applicable): libguestfs-tools-c-1.28.1-1.17.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.add an image, mount the root filesystem #guestfish -a rhel-guest-image-7.0-20140926.0.x86_64.qcow2 ><fs> run ><fs> mount /dev/sda1 2.list the files in "/home" ><fs> ll /home total 4 drwxr-xr-x. 2 root root 6 Mar 13 2014 . dr-xr-xr-x. 17 root root 4096 Dec 15 08:48 .. 3.use "lstatlist" to "lstat" on multiple files ><fs> lstatnslist /home "/bin /root" [0] = { st_dev: 2064 st_ino: 197 st_mode: 41471 st_nlink: 1 st_uid: 0 st_gid: 0 st_rdev: 0 st_size: 7 st_blksize: 4096 st_blocks: 8 st_atime_sec: 1418556601 st_atime_nsec: 0 st_mtime_sec: 1417173747 st_mtime_nsec: 0 st_ctime_sec: 1417173747 st_ctime_nsec: 0 st_spare1: 0 st_spare2: 0 st_spare3: 0 st_spare4: 0 st_spare5: 0 st_spare6: 0 } [1] = { st_dev: 2064 st_ino: 603 st_mode: 16868 st_nlink: 2 st_uid: 0 st_gid: 0 st_rdev: 0 st_size: 4096 st_blksize: 4096 st_blocks: 8 st_atime_sec: 1418610114 st_atime_nsec: 0 st_mtime_sec: 1418611447 st_mtime_nsec: 0 st_ctime_sec: 1418611447 st_ctime_nsec: 0 st_spare1: 0 st_spare2: 0 st_spare3: 0 st_spare4: 0 st_spare5: 0 st_spare6: 0 } Actual results: as described above Expected results: "/bin" and "/root" are not files in "/home". So the results should be like this: [0] = { st_dev: 0 st_ino: -1 st_mode: 0 st_nlink: 0 st_uid: 0 st_gid: 0 st_rdev: 0 st_size: 0 st_blksize: 0 st_blocks: 0 st_atime_sec: 0 st_atime_nsec: 0 st_mtime_sec: 0 st_mtime_nsec: 0 st_ctime_sec: 0 st_ctime_nsec: 0 st_spare1: 0 st_spare2: 0 st_spare3: 0 st_spare4: 0 st_spare5: 0 st_spare6: 0 } [1] = { st_dev: 0 st_ino: -1 st_mode: 0 st_nlink: 0 st_uid: 0 st_gid: 0 st_rdev: 0 st_size: 0 st_blksize: 0 st_blocks: 0 st_atime_sec: 0 st_atime_nsec: 0 st_mtime_sec: 0 st_mtime_nsec: 0 st_ctime_sec: 0 st_ctime_nsec: 0 st_spare1: 0 st_spare2: 0 st_spare3: 0 st_spare4: 0 st_spare5: 0 st_spare6: 0 } Additional info:
I guess the answer is "don't do that" :-) However yes we can add a check to make sure if you use the API wrongly it will give you an error instead. Moving to 7.2 because the API does currently work if used correctly.
This has been fixed upstream with commits https://github.com/libguestfs/libguestfs/commit/7c10cda26650bd0076817b07134c893c28e0adf9 https://github.com/libguestfs/libguestfs/commit/b5a6f899cdf383e07871952dd7378b0787c43687 which are in libguestfs >= 1.31.20. It will be picked by the rebase (bug #1218766).
Verified with the packages: libguestfs-1.32.5-6.el7.x86_64 Verify steps: 1. Prepare a RHEL guest image: RHEL-Server-7.2-64-hvm.raw 2. # guestfish -a RHEL-Server-7.2-64-hvm.raw -i ><fs> ll /home/ total 4 drwxr-xr-x. 2 root root 6 May 25 2015 . dr-xr-xr-x. 17 root root 4096 Oct 31 2015 .. ><fs> lstatnslist /home "/bin /root" libguestfs: error: lstatnslist: names: '/bin' is not a file name It gives an obvious error as above. So verified.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2576.html