Bug 1517123

Summary: virt-who doesn't validate file contents and file name leading to duplicate config
Product: Red Hat Satellite Reporter: Harshad More <hmore>
Component: Virt-who Configure PluginAssignee: Marek Hulan <mhulan>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact: satellite-doc-list
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, hmore, mhulan, tstrachota, zhunting
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: foreman_virt_who_configure-0.1.9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:37 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:
Attachments:
Description Flags
form screenshot none

Description Harshad More 2017-11-24 09:32:27 UTC
Description of problem:

Using Virt-who Configurations plugin to create new configuration leads to duplicate config if created config same as old one on satellite 6.3 server.

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

satellite 6.3.0 25.0
virt-who-0.19-6.el7_4.noarch
foreman-1.15.6.9-1.el7sat.noarch

How reproducible:

Always

Steps to Reproduce:
1. Infrastructure --> Virt-who Configurations --> Create Config
2. Fill all the details and submit
3. Again follow steps 1 and 2

Actual results:

Creates two configuration files with same name

Expected results:

Should give error while creating new config file which has same contents as old one.

Additional info:

# ll
total 16
-rw-r--r--. 1 root root 1213 Jul 22 02:16 template.conf
-rw-r--r--. 1 root root  485 Nov 24 12:16 virt-who-config-1.conf
-rw-r--r--. 1 root root  602 Nov 24 12:26 virt-who-config-2.conf
-rw-r--r--. 1 root root  485 Nov 24 14:18 virt-who-config-3.conf
# pwd
/etc/virt-who.d

# diff virt-who-config-1.conf virt-who-config-3.conf
3c3
< [virt-who-config-1]
---
> [virt-who-config-3]
12,13c12,13
< rhsm_username=virt_who_reporter_1
< rhsm_encrypted_password=8aa98b69ebfddac99e9239d3f93604d8b1e502cb24b051c89a141e29e31f0582
---
> rhsm_username=virt_who_reporter_3
> rhsm_encrypted_password=a7713acc7262a086c9fa57ba5b914189ebe1ff712c611f3fa83a29ba3d2a5c85

--------------------
# cat virt-who-config-1.conf
### This configuration file is managed via the virt-who configure plugin
### manual edits will be deleted.
[virt-who-config-1]
type=esx
hypervisor_id=hostname
owner=RedHat
env=Library
server=vmware-1.xxx.redhat.com
username=satadmin
encrypted_password=ea5c98bfec1784e4860a102026eb71ac
rhsm_hostname=vm250-75.xxx.com
rhsm_username=virt_who_reporter_1
rhsm_encrypted_password=8aa98b69ebfddac99e9239d3f93604d8b1e502cb24b051c89a141e29e31f0582
rhsm_prefix=/rhsm

Comment 2 Marek Hulan 2017-11-24 13:27:17 UTC
Why is this an issue? It might be necessary to create 2 configs for the same hypervisor, e.g. with only different whitelist/blacklist. Or is that only a name that you'd like to be unique?

Comment 3 Harshad More 2017-11-27 09:12:31 UTC
(In reply to Marek Hulan from comment #2)
> Why is this an issue? It might be necessary to create 2 configs for the same
> hypervisor, e.g. with only different whitelist/blacklist. Or is that only a
> name that you'd like to be unique?

------------------------------------------------------------

Yes, name should be unique to the config.

Additionally, for one configuration we can have either whitelist or backlist and not both. So need to be taken care or some message should be pop-up

Comment 4 Marek Hulan 2017-11-27 10:40:11 UTC
Created redmine issue http://projects.theforeman.org/issues/21773 from this bug

Comment 5 Marek Hulan 2017-11-27 10:43:03 UTC
I do not understand the second commit. You need to chose filtering mode. Either unlimited, whitelist or blacklist, I don't see a way you could have two at the same time. Anyway that should be a separate BZ, so if you see some issue there, please create a new report.

Comment 8 Marek Hulan 2017-11-27 11:04:57 UTC
The patch adds a uniqueness check but note it's per organization only. So two organizations can have the configuration with the same name. Therefore as a user in any context you could still see two records in a table with the same name. That is however correct.

Comment 9 Satellite Program 2017-12-08 15:13:36 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21773 has been resolved.

Comment 10 Peter Ondrejka 2018-01-03 17:06:35 UTC
Created attachment 1376531 [details]
form screenshot

Verified on Sat 6.3 snap 30, virt-who config dialog now validates name for uniqueness

Comment 11 Satellite Program 2018-02-21 16:54:37 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://access.redhat.com/errata/RHSA-2018:0336