Bug 788641 - virt-edit doesn't preserve file permissions
Summary: virt-edit doesn't preserve file permissions
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 788642
TreeView+ depends on / blocked
 
Reported: 2012-02-08 17:16 UTC by Richard W.M. Jones
Modified: 2012-02-09 18:34 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 788642 (view as bug list)
Environment:
Last Closed: 2012-02-09 18:34:41 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2012-02-08 17:16:36 UTC
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):

1.17.5

How reproducible:

100%

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
goodbye

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 17:19:15 UTC
Are there other tools which don't and should preserve permissions?

Comment 2 Richard W.M. Jones 2012-02-08 18:25:08 UTC
The answer to comment 1 appears to be 'no'.

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

https://www.redhat.com/archives/libguestfs/2012-February/msg00033.html

Comment 3 Richard W.M. Jones 2012-02-09 18:34:41 UTC
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.