Bug 1142742

Summary: Improve error message if input wrong username or password for a tcp connection
Product: Red Hat Enterprise Linux 7 Reporter: CongDong <codong>
Component: virt-viewerAssignee: Fabiano Fidêncio <fidencio>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: codong, dblechte, fidencio, juzhou, marcandre.lureau, mzhan, rbalakri, tzheng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-viewer-0.6.0-8.el7 Doc Type: Bug Fix
Doc Text:
Cause: All errors coming from TCP connections have been treated as the same, showing to the user the same message, inclusive when the users tried to cancel the connection dialog. Consequence: Users cannot have a clear understanding about what have failed when an error occurred using a TCP connection (or if some fail really happened, considering the case when the user cancelled the dialog and a random error message was being shown). Fix: Let the users cancel the dialog without show any error and add a custom message, from our side, when the authentication using TCP connection fails. Result: A more accurate message is shown when an authentication error happens using TCP connection and let the users cancel the dialog without show any random message, just leaving the program.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 13:39:45 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 CongDong 2014-09-17 10:26:10 UTC
Description of problem:
When input wrong username or password for a tcp connection,
the error message is not clear

Version-Release number of selected component (if applicable):
virt-viewer-0.6.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.On host A,set tcp server environment.
1.1 Edit /etc/sysconfig/libvirtd
       LIBVIRTD_ARGS="--listen"

1.2 Edit /etc/libvirt/libvirtd.conf
       listen_tls = 0
       listen_tcp=1
       auth_tcp="sasl"

1.3 Add a user named "fred", and setting his password as "redhat"
   # saslpasswd2 -a libvirt fred
   Password: xxxxxx
   Again (for verification): xxxxxx

1.4 Restart libvirtd service and set iptables.
# service libvirtd restart

#iptables -F

2. Prepare a spice guest on host A,set it's listen address as 0.0.0.0,the xml shows as below:
# virsh dumpxml $vm
    <graphics type='spice' port='5900' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

3. On host B, try to connect the guest on host A with virt-viewer
# virt-viewer -c qemu+tcp://10.66.7.56/system $vm

4. A login dialog will come out, input a wrong username or password, and click OK
5. Repeat Step 3, and click "Cancle" button when the dialog comes out

Actual results:
Step 4, error message:
Unable to connect to libvirt with URI qemu+tcp://$hsot_a_ip/system
Step5, get same error message.

Expected results:
Step4, error message should tell user the username and password are wrong.
Step5, If click "Cancle" button, don't try to connect, just quit virt-viewer.

Additional info:

Comment 2 Fabiano Fidêncio 2014-09-23 11:36:58 UTC
We have 2 problems here and, IMHO, it should be split in 2 different bugs.

Let's start with the easiest one:
1) Cancel button should quit virt-viewer without show any error.
It's easily doable in the client side and a patch was sent to ML about it: https://www.redhat.com/archives/virt-tools-list/2014-September/msg00192.html

2) RFE: Improve libvirt errors exposed to the user when an authentication fail
This is something related to the libvirt and not to our client, AFAIU. I've done some investigation and started a thread about this in virt-tools-list: https://www.redhat.com/archives/virt-tools-list/2014-September/msg00186.html. Let's wait for answers there and see if we have an agreement about how to expose possible authentication errors.

Shall we open a different bug for 1) and change this bug title for 2)?

Comment 3 Fabiano Fidêncio 2014-09-23 14:52:23 UTC
(In reply to Fabiano Fidêncio from comment #2)
> We have 2 problems here and, IMHO, it should be split in 2 different bugs.
> 
> Let's start with the easiest one:
> 1) Cancel button should quit virt-viewer without show any error.
> It's easily doable in the client side and a patch was sent to ML about it:
> https://www.redhat.com/archives/virt-tools-list/2014-September/msg00192.html
> 
> 2) RFE: Improve libvirt errors exposed to the user when an authentication
> fail
> This is something related to the libvirt and not to our client, AFAIU. I've
> done some investigation and started a thread about this in virt-tools-list:
> https://www.redhat.com/archives/virt-tools-list/2014-September/msg00186.html.
> Let's wait for answers there and see if we have an agreement about how to
> expose possible authentication errors.

I've just sent a patch to virt-tools-list improving the error message.
This is the best we can do from our side, expose the libvirt error with our default message. If any improvement is required, it should be done in the libvirt side.
https://www.redhat.com/archives/virt-tools-list/2014-September/msg00201.html

Comment 5 CongDong 2014-10-09 03:03:14 UTC
Test with virt-viewer-0.6.0-7.el7.x86_64

Steps are same with description.

Result:
After input username and correct password, virt-viewer is exit, didn't connect the guest.

#virt-viewer -c qemu+tcp://$ip/system $vm --debug
(virt-viewer:24212): virt-viewer-DEBUG: Insert window 0 0x23dd010
(virt-viewer:24212): virt-viewer-DEBUG: Insert window 1 0x23dd0d0
(virt-viewer:24212): virt-viewer-DEBUG: Insert window 2 0x23dd190
(virt-viewer:24212): virt-viewer-DEBUG: Insert window 3 0x23dd250
(virt-viewer:24212): virt-viewer-DEBUG: fullscreen display 0: 0
(virt-viewer:24212): virt-viewer-DEBUG: fullscreen display 1: 0
(virt-viewer:24212): virt-viewer-DEBUG: fullscreen display 3: 0
(virt-viewer:24212): virt-viewer-DEBUG: fullscreen display 2: 0
(virt-viewer:24212): virt-viewer-DEBUG: connecting ...
(virt-viewer:24212): virt-viewer-DEBUG: Opening connection to libvirt with URI qemu+tcp://10.66.4.107/system
(virt-viewer:24212): virt-viewer-DEBUG: Add handle 12 1 0x2555f20
(virt-viewer:24212): virt-viewer-DEBUG: Got libvirt credential request for 2 credential(s)
(virt-viewer:24212): virt-viewer-DEBUG: Return -1
(virt-viewer:24212): virt-viewer-DEBUG: Remove handle 1 12
(virt-viewer:24212): virt-viewer-DEBUG: Disposing window 0x23dd010

(virt-viewer:24212): virt-viewer-DEBUG: Disposing window 0x23dd0d0

(virt-viewer:24212): virt-viewer-DEBUG: Disposing window 0x23dd250

(virt-viewer:24212): virt-viewer-DEBUG: Disposing window 0x23dd190

(virt-viewer:24212): virt-viewer-DEBUG: Set connect info: (null),(null),(null),-1,(null),(null),(null),0

As the result, virt-viewer cannot connect the guest over tcp connection.

Comment 6 Fabiano Fidêncio 2014-10-09 14:10:19 UTC
I found the problem.
In the upstream code virt_viewer_auth_collect_credentials() returns a gboolean (0 as FALSE or !FALSE as TRUE) while in the downstream code it returns an integer (-1 as FALSE and 0 as TRUE).
Dunno what is better, fix the behavior of my patch downstream or backport the patch that added this change plus a few more adapting the code to the change.

Comment 8 CongDong 2014-10-31 08:34:12 UTC
I can reproduce with virt-viewer-0.6.0-5.el7.x86_64.rpm

VERIFY with virt-viewer-0.6.0-10.el7.x86_64

Steps:
1.On host A,set tcp server environment.
1.1 Edit /etc/sysconfig/libvirtd
       LIBVIRTD_ARGS="--listen"

1.2 Edit /etc/libvirt/libvirtd.conf
       listen_tls = 0
       listen_tcp=1
       auth_tcp="sasl"

1.3 Add a user named "fred", and setting his password as "redhat"
   # saslpasswd2 -a libvirt fred
   Password: xxxxxx
   Again (for verification): xxxxxx

1.4 Restart libvirtd service and set iptables.
# service libvirtd restart

#iptables -F

2. Prepare a spice guest on host A,set it's listen address as 0.0.0.0,the xml shows as below:
# virsh dumpxml $vm
    <graphics type='spice' port='5900' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

3. On host B, try to connect the guest on host A with virt-viewer
# virt-viewer -c qemu+tcp://10.66.7.56/system $vm

4. A login dialog will come out, input a wrong username or password, and click OK
5. Repeat Step 3, and click "Cancle" button when the dialog comes out
6, retry with right password and username

Result:
Step 4, 
Unable to connect to libvirt with URI: qemu+tcp://10.66.4.104/system.
Authentication failed.
Step 5, dilog close without error message
step 6, can connect the guest

As the result, set VERIFIED

Comment 10 errata-xmlrpc 2015-03-05 13:39:45 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-0295.html