RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1141626 - virt-sysprep option '--password' don't work well, it will cause login problem and if execute with other options it will take no effect
Summary: virt-sysprep option '--password' don't work well, it will cause login problem...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.1
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-15 04:25 UTC by Lingfei Kong
Modified: 2015-03-05 13:44 UTC (History)
6 users (show)

Fixed In Version: libguestfs-1.28.1-1.5.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 13:44:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0303 0 normal SHIPPED_LIVE libguestfs bug fix and enhancement update 2015-03-05 17:34:44 UTC

Description Lingfei Kong 2014-09-15 04:25:15 UTC
Description of problem:
virt-sysprep option '--password' don't work well, it will cause login problem and if execute with other options it will take no effect. For example:
#virt-sysprep --password lkong:password:lkong -a rhel6.6.img
If i try to login the guest with root account, i will failed to login with 'login incorrect' error message. But if i disabled selinux first, then i can login with root account successfully and password for lkong account is change as requested.

#virt-sysprep --operation net-hwaddr --password lkong:password:lkong -a rhel6.6.img
[   0.0] Examining the guest ...
[   5.0] Performing "net-hwaddr" ...

According to the output, virt-sysprep did not run '--password' option, or there should have 'Setting passwords' line output.

Version-Release number of selected component (if applicable):
libguestfs-1.27.43-1.1.el7


How reproducible:
100%


Steps to Reproduce:
1. Create a raw format guest image: rhel6.6.img
2. Start the guest and create a new user lkong in the guest
# useradd lkong
3. #virt-sysprep --operation net-hwaddr --password lkong:password:lkong -a rhel6.6.img
[   0.0] Examining the guest ...
[   6.0] Performing "net-hwaddr" ...
4. #virt-sysprep --password lkong:password:lkong -a rhel6.6.img
5. Start the guest and try to login with root account


Actual results:
At step 3, password of lkong account not changed as requested.
At step 5, login with root account failed weith "login incorrect" error message


Expected results:
At step 3, password of lkong account changed as requested.
At step 5, can login to the guest with root account and lkong's password is changed as requested.


Additional info:

Comment 2 Richard W.M. Jones 2014-09-15 07:55:50 UTC
Can you try it with the --selinux-relabel option?

There are some problems with SELinux relabelling, both in libguestfs 1.26
and with RHEL itself.

Comment 3 Lingfei Kong 2014-09-15 08:18:07 UTC
(In reply to Richard W.M. Jones from comment #2)
> Can you try it with the --selinux-relabel option?
> 
> There are some problems with SELinux relabelling, both in libguestfs 1.26
> and with RHEL itself.

1. Create a new user test in rhel6.6.img
2. #virt-sysprep --selinux-relabel --password lkong:password:lkong -a rhel6.6.img
3. Try to login the guest. 

I can login the guest successfully with '--selinux-relabel' and the password is changed as requested.

Comment 4 Pino Toscano 2014-09-30 09:25:21 UTC
Hi Lingfei,

there are two different issues in this bug report.

(In reply to Lingfei Kong from comment #0)
> #virt-sysprep --password lkong:password:lkong -a rhel6.6.img
> If i try to login the guest with root account, i will failed to login with
> 'login incorrect' error message. But if i disabled selinux first, then i can
> login with root account successfully and password for lkong account is
> change as requested.

Accoding to the version reported (libguestfs-1.27.43-1.1.el7), this might be another case of the switch to Augeas to edit /etc/shadow (i.e. the same issue reported as #1146275 and #1147065). This has been fixed upstream yesterday, in libguestfs 1.27.56.

Can you please try this with libguestfs-1.27.56-1.1.el7? --selinux-relabel should not be needed.

(In reply to Lingfei Kong from comment #0)
> #virt-sysprep --operation net-hwaddr --password lkong:password:lkong -a
> rhel6.6.img
> [   0.0] Examining the guest ...
> [   5.0] Performing "net-hwaddr" ...

This invocation basically enables only the "net-hwaddr" operation, and thus the "customize" operation (which does the password changing) is not run. This is similar to #1141157, so a similar fix should be done in the "customize" operation.

Comment 5 Richard W.M. Jones 2014-10-20 09:35:29 UTC
Setting needinfo of Lingfei to retest with latest virt-sysprep
and without --selinux-label option.  It should work.

Comment 6 Lingfei Kong 2014-10-22 11:52:22 UTC
(In reply to Pino Toscano from comment #4)
> Can you please try this with libguestfs-1.27.56-1.1.el7? --selinux-relabel
> should not be needed.
> 
I try it with libguestfs-1.28.1-1.2.el7, virt-sysprep --password do not change the specify user's password in guest with or without --selinux-relabel option:
#virt-sysprep --password lkong:password:redhat -a rhel7_kvm.img
#virt-sysprep --selinux-relabel --password lkong:password:redhat -a rhel7_kvm.img

Also i try it with libguestfs-1.27.43-1.1.el7 as Comment 3, it can not work this time.
I try --root-password option it do not work well too. 

> (In reply to Lingfei Kong from comment #0)
> > #virt-sysprep --operation net-hwaddr --password lkong:password:lkong -a
> > rhel6.6.img
> > [   0.0] Examining the guest ...
> > [   5.0] Performing "net-hwaddr" ...
> 
> This invocation basically enables only the "net-hwaddr" operation, and thus
> the "customize" operation (which does the password changing) is not run.
> This is similar to #1141157, so a similar fix should be done in the
> "customize" operation.

In bug 1141157, there have no fix related to this problem, in 1141157, virt-sysprep only replace --user-accounts option with --{remove, keep}-user-accounts. When "customize" operation along with '--operation/--operations' options is it right to ignore "customize" operation? Should i file a bug for this issue?

Comment 7 Richard W.M. Jones 2014-10-24 14:40:35 UTC
I wanted to have a reliable reproducer of this.  Below is what I've
worked out.  It works on either Fedora 21 or RHEL 7, except that on
RHEL 7 you can to use /usr/libexec/qemu-kvm.

-------------
$ virt-builder fedora-20 
$ qemu-kvm -hda fedora-20.img -m 512

# verify that you can log in as root using the randomly generated
# root password that is printed by virt-builder
# then shut the guest down properly (/sbin/poweroff)

$ virt-sysprep --root-password password:123456 -a fedora-20.img
$ qemu-kvm -hda fedora-20.img -m 512

# verify that you can log in using root/123456

$ rm fedora-20.img
-------------

This fails on RHEL 7.1.  The reason is because the Augeas /etc/shadow
lens isn't working / hasn't been backported.  It sees the /etc/shadow
file as if it was completely empty and just doesn't work at all from
there.  Assigning to Pino since he knows what's going on here.

Comment 9 Richard W.M. Jones 2014-10-24 21:57:16 UTC
Now WFM with libguestfs-1.28.1-1.5.el7 using the reproducer
instructions given in comment 7.

Comment 10 Lingfei Kong 2014-11-11 08:27:10 UTC
Verify with libguestfs-1.28.1-1.9.el7

Steps to verify:
1. Prepare a guest image: rhel.img

2. # virt-sysprep --root-password password:123456 -a rhel.img

3. # qemu-kvm  -m 1024M -smp 3 -drive file=$PWD/rhel.img -vnc :1

4. Access the guest via vncviewer, can login root account with '123456' password.

Comment 12 errata-xmlrpc 2015-03-05 13:44:42 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.

https://rhn.redhat.com/errata/RHBA-2015-0303.html


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