[jira] [Resolved] (GUACAMOLE-384) Terminal writes during disconnect may segfault

2018-01-23 Thread Michael Jumper (JIRA)

 [ 
https://issues.apache.org/jira/browse/GUACAMOLE-384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Jumper resolved GUACAMOLE-384.
--
   Resolution: Fixed
Fix Version/s: 0.9.15

> Terminal writes during disconnect may segfault
> --
>
> Key: GUACAMOLE-384
> URL: https://issues.apache.org/jira/browse/GUACAMOLE-384
> Project: Guacamole
>  Issue Type: Bug
>  Components: Terminal
>Affects Versions: 0.9.12-incubating
> Environment: GNU/Linux x86_64
>Reporter: Phillip Arcuri
>Priority: Minor
> Fix For: 0.9.15
>
>
> In a stress test we kick off an SSH session every second.  The session does a 
> minimal amount of work and exits after a few seconds.  A ps -ef shows we have 
> 2 to 6 instances running at one time.  About 1 in 10 of the instances cores 
> with corrupted buffer data at line buffer.c:108.:
> (gdb) p *buffer
> $2 = {default_character = {value = -1269703408, attributes = {bold = 170, 
> reverse = 42, cursor = false, underscore = false, foreground = 0,
>   background = 0}, width = -1269422328}, rows = 0x2aaab456fa30, top = 
> 686, length = 0, available = 686}
> As an aside I also see roughly 1 in 100 instances become a zombie process 
> hung in pthread_join.  Doubt that is related, but thought I'd mention it.
> This is a blocker for our deployment of a guacamole-enabled feature-set.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[1/2] guacamole-server git commit: GUACAMOLE-384: fixing segfault during ssh disconnect

2018-01-23 Thread mjumper
Repository: guacamole-server
Updated Branches:
  refs/heads/master 8c844e6ea -> db85163e2


GUACAMOLE-384: fixing segfault during ssh disconnect

Root Cause:
See the core dump and Valgrind report posted on Jira. guacd was reading a ssh 
terminal which had been freed. When a ssh connection is terminated, 
guac_ssh_client_free_handler() will be called from guacd_exec_proc() -> 
guac_client_free() with pointer client->free_handler. In 
guac_ssh_client_free_handler(), when ssh_client->term is freed, 
ssh_client->client_thread may still be using the ssh_client->term. It causes 
the crash reported in this bug.

The stack trace exposing the problem can be found by running guacd under 
Valgrind with a ssh test script. The test script repeats doing ssh login and 
logout for 5000 times.

Solution:
In guac_ssh_client_free_handler(), before calling 
guac_terminal_free(ssh_client->term), close the stdin pipe of the terminal to 
stop reading the pipe with guac_terminal_read_stdin() in ssh_input_thread(). So 
that ssh_input_thread() can be terminated in this case. Call pthread_join() to 
wait for ssh_client_thread() terminating before freeing the terminal.

Add a new function guac_terminal_stop() to close the pipe and set the fds to 
invalid (-1). Call it in guac_ssh_client_free_handler() and 
guac_terminal_free().

Checking the client running state in ssh_input_thread() and ssh_client_thread() 
to make sure they can be terminated when the client is stopped in 
guacd_exec_proc() by another thread.

Test:
- Confirmed ssh connection works normally.
- Observed the child process of guacd exits when ssh connection is terminated.
- Reran the ssh test script. Observed no crash.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/d33bd8de
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/d33bd8de
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/d33bd8de

Branch: refs/heads/master
Commit: d33bd8deff9c7964a3a9c997c5c882d09dfed87b
Parents: 3c7a09f
Author: sanhex 
Authored: Wed Oct 18 12:08:32 2017 -0700
Committer: sanhex 
Committed: Sun Oct 29 18:11:15 2017 -0700

--
 src/protocols/ssh/client.c   |  6 +-
 src/protocols/ssh/ssh.c  | 12 
 src/terminal/terminal.c  | 16 ++--
 src/terminal/terminal/terminal.h |  9 +
 4 files changed, 40 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/d33bd8de/src/protocols/ssh/client.c
--
diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c
index c0a26b9..12eb1b7 100644
--- a/src/protocols/ssh/client.c
+++ b/src/protocols/ssh/client.c
@@ -70,8 +70,12 @@ int guac_ssh_client_free_handler(guac_client* client) {
 
 /* Free terminal (which may still be using term_channel) */
 if (ssh_client->term != NULL) {
-guac_terminal_free(ssh_client->term);
+/* Stop the terminal to unblock any pending reads/writes */
+guac_terminal_stop(ssh_client->term);
+
+/* Wait ssh_client_thread to finish before freeing the terminal */
 pthread_join(ssh_client->client_thread, NULL);
+guac_terminal_free(ssh_client->term);
 }
 
 /* Free terminal channel now that the terminal is finished */

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/d33bd8de/src/protocols/ssh/ssh.c
--
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index 54d13e5..6575d9f 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -162,8 +162,14 @@ void* ssh_input_thread(void* data) {
 pthread_mutex_lock(&(ssh_client->term_channel_lock));
 libssh2_channel_write(ssh_client->term_channel, buffer, bytes_read);
 pthread_mutex_unlock(&(ssh_client->term_channel_lock));
+
+/* Make sure ssh_input_thread can be terminated anyway */
+if (client->state == GUAC_CLIENT_STOPPING)
+break;
 }
 
+/* Stop the client so that ssh_client_thread can be terminated */
+guac_client_stop(client);
 return NULL;
 
 }
@@ -340,6 +346,12 @@ void* ssh_client_thread(void* data) {
 break;
 }
 
+/* Client is stopping, break the loop */
+if (client->state == GUAC_CLIENT_STOPPING) {
+pthread_mutex_unlock(&(ssh_client->term_channel_lock));
+break;
+}
+
 /* Send keepalive at configured interval */
 if (settings->server_alive_interval > 0) {
 timeout = 0;

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/d33bd8de/src/terminal/terminal.c

[2/2] guacamole-server git commit: GUACAMOLE-384: Merge fix for potential segfault if SSH connection is closed while output is still being written to the terminal.

2018-01-23 Thread mjumper
GUACAMOLE-384: Merge fix for potential segfault if SSH connection is closed 
while output is still being written to the terminal.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/db85163e
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/db85163e
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/db85163e

Branch: refs/heads/master
Commit: db85163e20a253dae1daffd0dd6b7ab6beb1ed6d
Parents: 8c844e6 d33bd8d
Author: Michael Jumper 
Authored: Tue Jan 23 14:44:47 2018 -0800
Committer: Michael Jumper 
Committed: Tue Jan 23 14:44:47 2018 -0800

--
 src/protocols/ssh/client.c   |  6 +-
 src/protocols/ssh/ssh.c  | 12 
 src/terminal/terminal.c  | 16 ++--
 src/terminal/terminal/terminal.h |  9 +
 4 files changed, 40 insertions(+), 3 deletions(-)
--




[jira] [Created] (GUACAMOLE-488) Add Belgian-French keymap for RDP

2018-01-23 Thread James He (JIRA)
James He created GUACAMOLE-488:
--

 Summary: Add Belgian-French keymap for RDP
 Key: GUACAMOLE-488
 URL: https://issues.apache.org/jira/browse/GUACAMOLE-488
 Project: Guacamole
  Issue Type: New Feature
  Components: RDP
Affects Versions: 0.9.14
Reporter: James He


Guacamole's RDP support currently lacks the Belgian-French AZERTY keyboard 
layout variant. It should be added. The corresponding layout constant in 
FreeRDP is KBD_BELGIAN_FRENCH.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GUACAMOLE-487) RDP server closed connection: Forcibly disconnected.

2018-01-23 Thread Michael Jumper (JIRA)

[ 
https://issues.apache.org/jira/browse/GUACAMOLE-487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16336202#comment-16336202
 ] 

Michael Jumper commented on GUACAMOLE-487:
--

{quote}
Thanks for your answer, well i made several tests on my differents plateforms 
0.9.13 on Ubuntu 14.04 Tomcat 7 and 0.9.14 on Ubuntu 16.04 with tomcat8 or 
tomcat7 and always get the problem as mentionned on this thread...
{quote}

The fact that Guacamole is correctly interpreting the reason for the disconnect 
is not a bug nor a problem. If your remote desktop server is unexpectedly 
closing the connection, you will need to investigate the remote desktop server. 
Guacamole is not the cause of the disconnect here, nor Ubuntu, nor Tomcat, etc.

> RDP server closed connection: Forcibly disconnected.
> 
>
> Key: GUACAMOLE-487
> URL: https://issues.apache.org/jira/browse/GUACAMOLE-487
> Project: Guacamole
>  Issue Type: Bug
>  Components: guacamole
>Affects Versions: 0.9.14
> Environment: Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-62-generic x86_64) 
> on VMware 5.5
>Reporter: emma
>Priority: Minor
> Attachments: RDP_Disconnected_issue1.png, 
> RDP_Disconnected_issue2.png, RDP_Disconnected_issue3.png
>
>
> Hi,
> I'm just installing and testing 0.9.14 version on Ubuntu 16.04.3 LTS 
> (GNU/Linux 4.4.0-62-generic x86_64) with Tomcat8 and during my first tests i 
> got an error while disconnecting from  RDP session from Windows 2003R2 or 
> Windows 2012R2 (same issues).
> Once im logged onto the rdp session, then from windows GUI, start / logoff i 
> got an error message (Cf. first screenshot)
> !RDP_Disconnected_issue1.png!
> Then if i click RECONNECT, and at the Windows logging screen click CANCEL the 
> disconnection seems to operate properly (Cf. screenshot)
> !RDP_Disconnected_issue2.png!
> !RDP_Disconnected_issue3.png!
> So far im using Guacamole 0.9.12 running on Ubuntu 16.04.2 LTS (GNU/Linux 
> 4.4.0-62-generic x86_64) and also upgrade 0.9.9 on 0.9.13 and never had this 
> problem.
> What should i check  to get Guacamole 0.9.14 running without this error 
> message ?
> All these servers were installed and setup with the same SOP.
> Thank you !



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)