Bug 980372

Summary: "hivex-commit" should fail with a relative path
Product: Red Hat Enterprise Linux 6 Reporter: bfan
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5CC: leiwang, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.20.9-7.el6 Doc Type: Bug Fix
Doc Text:
Cause: Using hivex-commit command in guestfish. Consequence: Using hivex-commit with a relative path parameter would succeed, but it should give an error. (It writes the hive to an inaccessible place, so it's useless for end users) Fix: hivex-commit fixed Result: Using hivex-commit with a relative path parameter will now fail with an error. You must use an absolute path; or a NULL path (means: overwrite the original).
Story Points: ---
Clone Of: 905322
: 981683 (view as bug list) Environment:
Last Closed: 2013-11-21 04:45:38 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: 981683    
Bug Blocks:    

Description bfan 2013-07-02 07:47:24 UTC
+++ This bug was initially created as a clone of Bug #905322 +++

Description of problem:
Command "hivex-commit" need a absolute path as its parameter, it's different with "hivex-open" which just need a relative path.

"/WINDOWS/system32/config/software" is exist, and that folder is writable. it's like hivex-commit didn't correctly follow the link, its path is not start from "/sysroot/"  


Version-Release number of selected component (if applicable):
><fs> version
major: 1
minor: 20
release: 1
extra: rhel=7,release=6.el7,libvirt


How reproducible:
100%


Steps to Reproduce:
1. launch libguestfs with a windows guest
[root#] guestfish -a Win2003-32-hvm.raw
><fs> run
><fs> mount /dev/sda1 /

2. open a registry hive file with write model
><fs> hivex-open /WINDOWS/system32/config/software write:true

3. commit changes to the hive file with relative path, it's failed
><fs> hivex-commit /WINDOWS/system32/config/software
libguestfs: error: hivex_commit: failed: No such file or directory

4. commit changes to the hive file with absolute path, it's passed
><fs> hivex-commit /sysroot/WINDOWS/system32/config/software


Actual results:
hivex-commit with relatived path failed


Expected results:
hivex-commit with relatived path can pass


Additional info:

--- Additional comment from RHEL Product and Program Management on 2013-01-29 02:27:34 EST ---

Since this bug report was entered in bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

--- Additional comment from Richard W.M. Jones on 2013-01-29 05:38:13 EST ---

Fixed upstream in:
https://github.com/libguestfs/libguestfs/commit/be4a3d77c42148731a977b68aab8b454372518d7

Comment 1 bfan 2013-07-02 09:13:56 UTC
Sorry, may something wrong during my test.
Actually it works, not a bug, please close it.

Comment 2 Richard W.M. Jones 2013-07-05 13:14:29 UTC
In fact there is a bug here.

Test script.  You'll need 'minimal' from
https://github.com/libguestfs/hivex/blob/master/images/minimal
and note that you have to uncomment only *one* of the three hivex-commit
lines in the script.

guestfish -x -N fs -m /dev/sda1 <<EOF
upload /mnt/scratch/minimal /minimal
hivex-open /minimal write:true
#hivex-commit ""
#hivex-commit "/minimal"
hivex-commit "minimal"
EOF

The first case (NULL) should always succeed and it does.

The second case (absolute path "/minimal") should succeed
and it does.

The third case (relative path "minimal") should fail because
relative paths shouldn't be allowed.  It doesn't fail, so that is
a bug.

Comment 5 bfan 2013-09-17 07:50:58 UTC
Verified with libguestfs-1.20.11-1.el6.x86_64

Test according to #C2
(1) successed
guestfish -x -N fs -m /dev/sda1 <<EOF
upload /mnt/scratch/minimal /minimal
hivex-open /minimal write:true
hivex-commit ""
#hivex-commit "/minimal"
#hivex-commit "minimal"
EOF

(2) successed
guestfish -x -N fs -m /dev/sda1 <<EOF
upload /mnt/scratch/minimal /minimal
hivex-open /minimal write:true
#hivex-commit ""
hivex-commit "/minimal"
#hivex-commit "minimal"
EOF

(3) libguestfs: error: hivex_commit: do_hivex_commit: path must start with a / character
guestfish -x -N fs -m /dev/sda1 <<EOF
upload /mnt/scratch/minimal /minimal
hivex-open /minimal write:true
#hivex-commit ""
#hivex-commit "/minimal"
hivex-commit "minimal"
EOF

So change the status to verified

Comment 7 errata-xmlrpc 2013-11-21 04:45:38 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.

http://rhn.redhat.com/errata/RHSA-2013-1536.html