Bug 633174

Summary: some guestfish sub commands can not handle special files properly
Product: Red Hat Enterprise Linux 6 Reporter: Jinxin Zheng <jzheng>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: dallan, leiwang, mbooth, mshao, pcao, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.7.17-4.el6 Doc Type: Bug Fix
Doc Text:
Some guestfish commands would hang when applied to non-regular files. This had some security implications in that a guest could replace regular configuration files with, for example, character devices, and cause virt-inspector and other programs to hang. guestfish commands have been modified and can now handle non-regular files. Additionally, virt-inspector has been rewritten as virt-inspector2, which is both more powerful, and more careful about untrusted files from the guest.
Story Points: ---
Clone Of: 582484 Environment:
Last Closed: 2011-05-19 11:44:28 UTC Type: ---
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: 582484, 613593    
Bug Blocks:    

Description Jinxin Zheng 2010-09-13 05:28:05 UTC
Still exists in libguestfs-1.2.7-1.24.el6, so clone to RHEL6 to ensure it get fixed in RHEL 6.1.

+++ This bug was initially created as a clone of Bug #582484 +++

Description of problem:
1. guestfish "file" command can not handle character special files properly, it just hang when called againest a char special file.
2. guestfish "touch" command can not handle fifo special files properly, it also hang.
These two commands can work for other special devices like block special file.

Version-Release number of selected component (if applicable):
libguestfs-1.0.85-1.fc12.3.x86_64
And also the lastest git version

How reproducible:
100%

Steps to Reproduce:
1. Run guestfish, add an img containing some char/block/fifo special files
2. Run and mount the partition
3. "file /path_to_char-dev-file" , it will hang the guestfish shell.
4. Repeat step 1,2, then run "touch /path_to_fifo-dev-file", it will hang.
5. ll,stat commands works fine for these special files

Actual results:
guestfish hang

Expected results:
command should return proper value

Additional info:
check logs in the attachment:
guestfish-file-error01.log
guestfish-touch-error02.log

--- Additional comment from pcao on 2010-04-15 02:39:34 EDT ---

Created attachment 406688 [details]
log for file command

--- Additional comment from pcao on 2010-04-15 02:40:03 EDT ---

Created attachment 406689 [details]
log for touch command

--- Additional comment from rjones on 2010-04-15 04:24:22 EDT ---

I'll have a look at this when I get back from holiday.

--- Additional comment from rjones on 2010-06-04 10:37:55 EDT ---

Patches posted upstream to fix the issues with
the touch and file commands.

https://www.redhat.com/archives/libguestfs/2010-June/msg00050.html

--- Additional comment from rjones on 2010-06-08 09:32:57 EDT ---

This commit:

http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=4df593496e116dfb635731c058b7627e81fc179c

breaks OS detection, since /dev/VG/LV is a symbolic link to
../dm-NN.

Reopening this bug.

--- Additional comment from rjones on 2010-06-08 11:08:02 EDT ---

Second patch posted:

https://www.redhat.com/archives/libguestfs/2010-June/msg00068.html

--- Additional comment from rjones on 2010-06-08 13:01:39 EDT ---

Patch ACKed upstream:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=ba39ced8804765705f4c61a92db0fddb8d672c7d

Comment 1 Richard W.M. Jones 2010-11-24 09:10:40 UTC
Will be fixed by the rebase (bug 613593).

Comment 2 Richard W.M. Jones 2011-01-04 14:17:42 UTC
Fixed by the rebase.

Comment 4 Lei Wang 2011-01-21 07:09:13 UTC
Test steps:
1. Run guestfish, add image, run and mount.
2. Use "mkfifo 0644 /tmp/fifo-file" to create a FIFO file.
3. Verify the file created correctly via "ll /tmp/fifo-file".
4. Run "touch /tmp/fifo-file".
5. Rerun step 1.
6. Use "mknod-c 0644 1 6 /tmp/char-file" to create a character file.
7. Verify the file created correctly via "ll /tmp/char-file".
8. Run "file /tmp/char-file".

Could reproduce the bug with: libguestfs-1.2.7-1.24.el6
At step 4, the "touch" command hangs there.
At step 8, the "file" comamnd reports "writable, no read permission" though "ll" shows there's read permission.

Verity this bug with: libguestfs-1.7.17-10.el6
At step 4, the "touch" command failed with error message as below:
libguestfs: error: touch: /tmp/fifo-file: touch can only be used on a regular files.
At step 8, the "file" command returned right file type as below:
character device

According to the results above, move to VERIFIED.

Comment 7 Laura Bailey 2011-04-19 02:48:02 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Some guestfish commands would hang when applied to non-regular files. This had some security implications in that a guest could replace regular configuration files with, for example, character devices, and cause virt-inspector and other programs to hang. guestfish commands have been modified and can now handle non-regular files.

Additionally, the virt-inspector has been rewritten as virt-inspector2, which is both more powerful, and more careful about untrusted files from the guest.

Comment 8 Richard W.M. Jones 2011-04-19 07:40:46 UTC
Small change made to technical note.

Comment 9 Richard W.M. Jones 2011-04-19 07:40:46 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,3 +1,3 @@
 Some guestfish commands would hang when applied to non-regular files. This had some security implications in that a guest could replace regular configuration files with, for example, character devices, and cause virt-inspector and other programs to hang. guestfish commands have been modified and can now handle non-regular files.
 
-Additionally, the virt-inspector has been rewritten as virt-inspector2, which is both more powerful, and more careful about untrusted files from the guest.+Additionally, virt-inspector has been rewritten as virt-inspector2, which is both more powerful, and more careful about untrusted files from the guest.

Comment 11 errata-xmlrpc 2011-05-19 11:44:28 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html

Comment 12 errata-xmlrpc 2011-05-19 13:10:30 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html