You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by "Jonathan Hankins (JIRA)" <ji...@apache.org> on 2018/01/18 22:20:00 UTC
[jira] [Created] (GUACAMOLE-484) Guacd returns incorrect error code
to client for some disconnect circumstances resulting in incorrect attempts
to reconnect
Jonathan Hankins created GUACAMOLE-484:
------------------------------------------
Summary: Guacd returns incorrect error code to client for some disconnect circumstances resulting in incorrect attempts to reconnect
Key: GUACAMOLE-484
URL: https://issues.apache.org/jira/browse/GUACAMOLE-484
Project: Guacamole
Issue Type: Bug
Components: guacd
Affects Versions: 0.9.13-incubating
Reporter: Jonathan Hankins
{{[I originally posted about this at [http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/Need-guidance-with-suspected-auto-reconnect-bug-td2118.html] and then replied later to another thread at [http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/Error-message-when-disconnecting-a-Windows-Server-2012-td1835.html#a2129] stating that Frode Langelo's patch fixed my issue as well. Opening bug report per Nick Couchman's request and copy/pasting from these referenced threads below.]}}
{{ }}
{{ I have a single connection to an RDP server. The server is set up to only allow one connection per user, so when I leave one guacamole session connected, and start up another one (e.g., open A in chrome and B in an incognito window), the session detaches from A and attaches to B.}}
{{ }}
{{ This (erroneously) triggers the 15 second auto-reconnect countdown in A. Once it reconnects, B is disconnected and starts the 15 second countdown. It ping-pongs back and forth.}}
{{ }}
{{ Running "guacd -L debug -f" I see this:}}
{{ }}
{{ 1 ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION (0x00000005):}}
{{ 2 Another user connected to the server, forcing the disconnection of the current connection.}}
{{ 3 guacd[9344]: ERROR: Error handling RDP file descriptors}}
{{ }}
{{ Lines 1 and 2 actually come from libfreerdp, and indicate that the error code coming from RDP is 0x5. Looking at guacd: src/protocols/rdp/error.c}}
{noformat}
82 /* Another user logged on, disconnecting this user */
83 case 0x5: /* ERRINFO_DISCONNECTED_BY_OTHER_CONNECTION */
84 status = GUAC_PROTOCOL_STATUS_SESSION_CONFLICT;
85 message = "Disconnected by other connection.";
86 break;{noformat}
{{ }}
{{ So a 0x5 return from RDP should translate to GUAC_PROTOCOL_STATUS_SESSION_CONFLICT (0x209) being sent to the client.}}
{{ }}
{{ Looking at the client, in guacamole/target/guacamole-0.9.13-incubating/guacamole.js:}}
{{ }}
{{ }}
{{13877 /**
13878 * All error codes for which automatic reconnection is appropriate when a
13879 * client error occurs.
13880 */
13881 var CLIENT_AUTO_RECONNECT = \{
13882 0x0200: true,
13883 0x0202: true,
13884 0x0203: true,
13885 0x0207: true,
13886 0x0208: true,
13887 0x0301: true,
13888 0x0308: true
13889 };}}
0x0209 isn't in the list that should auto-reconnect. So I added this in guacamole.js:
console.log('status = ' + status.toString(16).toUpperCase());
In the session B console in Chrome, when the reconnect in session A, for example, disconnects session B, I see this:
status = 208
That's not 209, but it IS in the auto-reconnect list.
So I started tracking down why libfreerdp sends 0x5 to guacd, which should send 0x209 to the client, but instead is sending 0x208. Here's what I found (the clue was line 3 above in the guacd debug output:
guacd[9344]: ERROR: Error handling RDP file descriptors
In function guac_rdp_handle_connection:
{noformat}
765 /* Check the libfreerdp fds */
766 if (!freerdp_check_fds(rdp_inst)) {
767 guac_client_abort(client,
768 GUAC_PROTOCOL_STATUS_UPSTREAM_UNAVAILABLE,
769 "Error handling RDP file descriptors");
770 pthread_mutex_unlock(&(rdp_client->rdp_lock));
771 return 1;
772 }
{noformat}
and lower down:
{noformat}
804 /* Handle RDP disconnect */
805 if (freerdp_shall_disconnect(rdp_inst)) {
806 guac_rdp_client_abort(client);
807 pthread_mutex_unlock(&(rdp_client->rdp_lock));
808 return 1;
809 }
810{noformat}
the first bit is returning GUAC_PROTOCOL_STATUS_UPSTREAM_UNAVAILABLE, which is 0x208, to the client and returning. This means guac_rdp_client_abort, which maps the RDP error codes to GUAC_PROTOCOL_STATUS*, is never reached. I poked it a bit and realized I was in over my head. I'd need to understand more about freerdp_check_fds and freerdp_shall_disconnect before I could decide how to rework it.
I am not sure what all error conditions from RDP will trigger the first bit and return before guac_rdp_client_abort is called, but I am guessing that more than 0x5 is getting short-circuited and arriving at the client as a 0x208.
Excerpt from mailing list with Frode's patch:
{noformat}
I am seeing the same behavior as Kevin; Windows 2008 does not give
this error, while both 2012 and 2016 do. I found the easiest way to
reproduce this is to connect to the box but not do anything in the
Windows logon screen. The RDP server will disconnect the session and
the referenced error is produced. The freerdp version I am using is
1.1.0~git20140921.
Kevin; try adding this to src/protocols/rdp/rdp.c for remedy:
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index 0b15d055..d35c663c 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -764,9 +764,16 @@ static int
guac_rdp_handle_connection(guac_client* client) {
/* Check the libfreerdp fds */
if (!freerdp_check_fds(rdp_inst)) {
- guac_client_abort(client,
- GUAC_PROTOCOL_STATUS_UPSTREAM_UNAVAILABLE,
- "Error handling RDP file descriptors");
+ /* Handle RDP disconnect */
+ if (freerdp_shall_disconnect(rdp_inst)) {
+ guac_rdp_client_abort(client);
+ }
+ /* Handle FD error */
+ else {
+ guac_client_abort(client,
+ GUAC_PROTOCOL_STATUS_UPSTREAM_UNAVAILABLE,
+ "Error handling RDP file descriptors");
+ }
pthread_mutex_unlock(&(rdp_client->rdp_lock));
return 1;
}
Kind regards,
Frode
{noformat}
-Jonathan Hankins
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)