Bug 1174551 - "lstatnslist" and "lstatlist" don't give an error if the API is used wrongly
Summary: "lstatnslist" and "lstatlist" don't give an error if the API is used wrongly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.1
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1218766
Blocks: 1288337 1301891
TreeView+ depends on / blocked
 
Reported: 2014-12-16 02:48 UTC by Chao Zhang
Modified: 2016-11-03 17:48 UTC (History)
6 users (show)

Fixed In Version: libguestfs-1.32.0-2.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 17:48:44 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 12:06:51 UTC

Description Chao Zhang 2014-12-16 02:48:44 UTC
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:

Comment 1 Richard W.M. Jones 2014-12-16 09:53:22 UTC
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.

Comment 4 Pino Toscano 2015-10-21 11:03:47 UTC
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).

Comment 7 Xianghua Chen 2016-06-28 07:27:38 UTC
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.

Comment 9 errata-xmlrpc 2016-11-03 17:48:44 UTC
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


Note You need to log in before you can comment on or make changes to this bug.