Cannot login after modification shadow file with guestmount
Hi. I have a VM with CentOs6.2 on KVM. I mount an image of the VM when it's not working with guestmount: root@diehard:~# guestmount -a named-centos.img -i tmp vi /etc/shadow insert comment line into the file (esc yy p 0 i # esc :wq!), save changes, unmount the image, turn on the VM, and I cannot login. I cannot login even if I recover the shadow file. root@diehard:~# guestmount --version guestmount 1.16.15 -- Яицков Даниил Сергеевич Daneel S. Yaitskov skype: daneel_s_yaitskov google talks: rtfm.rtfm.rtfm@gmail.com email: dy@hivext.net
On Fri, Apr 20, 2012 at 05:48:06PM +0400, Daneel Yaitskov wrote:
I have a VM with CentOs6.2 on KVM. I mount an image of the VM when it's not working with guestmount:
root@diehard:~# guestmount -a named-centos.img -i tmp
vi /etc/shadow
Hopefully you edited the guest's tmp/etc/shadow, not your host's /etc/shadow ...
insert comment line into the file (esc yy p 0 i # esc :wq!), save changes, unmount the image, turn on the VM, and I cannot login.
I cannot login even if I recover the shadow file.
Not much information to go on here, but my guess is that /etc/shadow has the wrong permissions or SELinux context after you edited it. We recently fixed this bug in virt-edit: https://bugzilla.redhat.com/show_bug.cgi?id=788641 but that doesn't help you if you're using guestmount. These are what they should be on a RHEL 6 system: $ ll -Z /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /etc/shadow If that doesn't help, have a look for the error (/var/log/messages, /var/log/secure, or /var/log/audit/audit.log): $ guestfish --ro -a named-centos.img -i
<fs> less /var/log/messages [etc]
Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
I actually tried this to see what would happen. First I created an overlay so as not to modify the original guest: $ rm -f overlay.qcow2 $ qemu-img create -f qcow2 -o backing_file=F16x64.img overlay.qcow2 Here is the original file permissions and SELinux context: $ guestfish --ro -a overlay.qcow2 -i llz /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /sysroot/etc/shadow After editing with guestmount + vi there was no change so it appears to work correctly: $ guestfish --ro -a overlay.qcow2 -i llz /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /sysroot/etc/shadow I also tried guestmount + emacs. emacs refused to save the file, complaining: Doing lsetfilecon: operation not supported, /tmp/mnt/etc/shadow This even failed when I used 'guestmount --selinux' option, so I have filed a bug: https://bugzilla.redhat.com/show_bug.cgi?id=814933 For completeness I tried virt-edit: $ virt-edit -a overlay.qcow2 /etc/shadow $ guestfish --ro -a overlay.qcow2 -i llz /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /sysroot/etc/shadow and guestfish 'edit': $ guestfish -a overlay.qcow2 -i emacs /etc/shadow $ guestfish --ro -a overlay.qcow2 -i llz /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /sysroot/etc/shadow and as you can see both work correctly. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
participants (2)
-
Daneel Yaitskov -
Richard W.M. Jones