Bug 788641 - virt-edit doesn't preserve file permissions
virt-edit doesn't preserve file permissions
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
Depends On:
Blocks: 788642
  Show dependency treegraph
Reported: 2012-02-08 12:16 EST by Richard W.M. Jones
Modified: 2012-02-09 13:34 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 788642 (view as bug list)
Last Closed: 2012-02-09 13:34:41 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2012-02-08 12:16:36 EST
Description of problem:

virt-edit creates a new file when it is used.  Unfortunately
this means that the old file's permissions, SELinux context
etc are lost.

virt-edit should preserve all of this by copying it from the
old file to the new file.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:

This reproducer uses the phony Fedora test image from
libguestfs, but any Linux guest image would do.

$ cd libguestfs
$ cp tests/guests/fedora.img /tmp
$ ./run ./fish/guestfish -a /tmp/fedora.img -i \
      write /test "hello" : chmod 0600 /test : ll /test
$ ./run ./edit/virt-edit -a /tmp/fedora.img /test -e 's/hello/goodbye/'
$ ./run ./fish/guestfish -a /tmp/fedora.img -i \
      ll /test : cat /test : rm /test

Actual results:

The commands above print:

-rw------- 1 root root 5 Feb  8 17:14 /sysroot/test
-rw-r--r-- 1 root root 7 Feb  8 17:15 /sysroot/test

which shows that the permissions have changed.

Expected results:

Permissions, SELinux context etc should be preserved.

Additional info:
Comment 1 Richard W.M. Jones 2012-02-08 12:19:15 EST
Are there other tools which don't and should preserve permissions?
Comment 2 Richard W.M. Jones 2012-02-08 13:25:08 EST
The answer to comment 1 appears to be 'no'.

Patch posted upstream which preserves file mode, UID, GID
and SELinux context:

Comment 3 Richard W.M. Jones 2012-02-09 13:34:41 EST
This will be fixed upstream in 1.17.6.

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