Bug 1141157

Summary: virt-sysprep option '--user-accounts' don't work well
Product: Red Hat Enterprise Linux 7 Reporter: Lingfei Kong <lkong>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: medium    
Version: 7.1CC: leiwang, mbooth, ptoscano, wshi, yuliu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.27.44-1.1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 13:44:39 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:

Description Lingfei Kong 2014-09-12 10:58:55 UTC
Description of problem:
virt-sysprep option '--user-accounts' don't work well

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 --user-accounts lkong -a rhel6.6.img
[   0.0] Examining the guest ...
[   5.0] Performing "abrt-data" ...
[   5.0] Performing "bash-history" ...
[   5.0] Performing "blkid-tab" ...
[   5.0] Performing "crash-data" ...
[   5.0] Performing "cron-spool" ...
[   5.0] Performing "dhcp-client-state" ...
[   5.0] Performing "dhcp-server-state" ...
[   5.0] Performing "dovecot-data" ...
[   5.0] Performing "logfiles" ...
[   5.0] Performing "machine-id" ...
[   5.0] Performing "mail-spool" ...
[   5.0] Performing "net-hostname" ...
[   5.0] Performing "net-hwaddr" ...
[   5.0] Performing "pacct-log" ...
[   5.0] Performing "package-manager-cache" ...
[   5.0] Performing "pam-data" ...
[   5.0] Performing "puppet-data-log" ...
[   5.0] Performing "rh-subscription-manager" ...
[   5.0] Performing "rhn-systemid" ...
[   5.0] Performing "rpm-db" ...
[   5.0] Performing "samba-db-log" ...
[   5.0] Performing "script" ...
[   5.0] Performing "smolt-uuid" ...
[   5.0] Performing "ssh-hostkeys" ...
[   5.0] Performing "ssh-userdir" ...
[   5.0] Performing "sssd-db-log" ...
[   5.0] Performing "tmp-files" ...
[   5.0] Performing "udev-persistent-net" ...
[   5.0] Performing "utmp" ...
[   5.0] Performing "yum-uuid" ...
[   5.0] Performing "customize" ...
[   5.0] Setting a random seed
[   6.0] Performing "lvm-uuids" ...

4. Login the guest and check

Actual results:
At step 4, lkong account was not removed from the guest


Expected results:
At step 4, lkong account was removed from the guest


Additional info:

Comment 2 Pino Toscano 2014-09-12 13:04:55 UTC
(In reply to Lingfei Kong from comment #0)
> 3. #virt-sysprep --user-accounts lkong -a rhel6.6.img
> [   0.0] Examining the guest ...
> [   5.0] Performing "abrt-data" ...
> [   5.0] Performing "bash-history" ...
> [   5.0] Performing "blkid-tab" ...
> [   5.0] Performing "crash-data" ...
> [   5.0] Performing "cron-spool" ...
> [   5.0] Performing "dhcp-client-state" ...
> [   5.0] Performing "dhcp-server-state" ...
> [   5.0] Performing "dovecot-data" ...
> [   5.0] Performing "logfiles" ...
> [   5.0] Performing "machine-id" ...
> [   5.0] Performing "mail-spool" ...
> [   5.0] Performing "net-hostname" ...
> [   5.0] Performing "net-hwaddr" ...
> [   5.0] Performing "pacct-log" ...
> [   5.0] Performing "package-manager-cache" ...
> [   5.0] Performing "pam-data" ...
> [   5.0] Performing "puppet-data-log" ...
> [   5.0] Performing "rh-subscription-manager" ...
> [   5.0] Performing "rhn-systemid" ...
> [   5.0] Performing "rpm-db" ...
> [   5.0] Performing "samba-db-log" ...
> [   5.0] Performing "script" ...
> [   5.0] Performing "smolt-uuid" ...
> [   5.0] Performing "ssh-hostkeys" ...
> [   5.0] Performing "ssh-userdir" ...
> [   5.0] Performing "sssd-db-log" ...
> [   5.0] Performing "tmp-files" ...
> [   5.0] Performing "udev-persistent-net" ...
> [   5.0] Performing "utmp" ...
> [   5.0] Performing "yum-uuid" ...
> [   5.0] Performing "customize" ...
> [   5.0] Setting a random seed
> [   6.0] Performing "lvm-uuids" ...

--user-accounts is just the optional parameter for the user-account operation, which you are not actually enabling there; see the output of `virt-sysprep --list-operations` (user-account has no '*', so it is not enabled by default).

In the documentation there is:
        --user-accounts USERS (see "user-account" below)
which yes, gives the idea that --user-accounts is related to the user-account operation, but not actually saying more than that.

Rich, what do you think about turning the documentation text
  (see "OP" below)
into
  (needs the "OP" operation; see below)
?

Comment 3 Richard W.M. Jones 2014-09-12 15:43:55 UTC
I have a slightly different take on this problem.  See:

https://www.redhat.com/archives/libguestfs/2014-September/thread.html#00063

Comment 5 yuliu 2014-11-11 07:15:47 UTC
Version: libguestfs-1.28.1-1.9.el7.x86_64

Steps:
1. Login guest and create an user account test1
2. #virt-sysprep --enable user-account -a guest-image.qcow2
3. Login guest again by the account test1.

test1 was deleted already.

Verified.

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