int guac_telnet_client_free_handler(guac_client* client) { guac_telnet_client* telnet_client = (guac_telnet_client*) client->data; /* Close telnet connection */ if (telnet_client->socket_fd != -1) close(telnet_client->socket_fd); /* Clean up recording, if in progress */ if (telnet_client->recording != NULL) guac_common_recording_free(telnet_client->recording); /* Kill terminal */ guac_terminal_free(telnet_client->term); /* Wait for and free telnet session, if connected */ if (telnet_client->telnet != NULL) { pthread_join(telnet_client->client_thread, NULL); telnet_free(telnet_client->telnet); } /* Free settings */ if (telnet_client->settings != NULL) guac_telnet_settings_free(telnet_client->settings); free(telnet_client); return 0; }
int ssh_guac_client_free_handler(guac_client* client) { ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data; /* Close SSH channel */ if (guac_client_data->term_channel != NULL) { libssh2_channel_send_eof(guac_client_data->term_channel); libssh2_channel_close(guac_client_data->term_channel); } /* Free terminal */ guac_terminal_free(guac_client_data->term); pthread_join(guac_client_data->client_thread, NULL); /* Free channels */ libssh2_channel_free(guac_client_data->term_channel); /* Clean up SFTP */ if (guac_client_data->sftp_session) libssh2_sftp_shutdown(guac_client_data->sftp_session); if (guac_client_data->sftp_ssh_session) { libssh2_session_disconnect(guac_client_data->sftp_ssh_session, "Bye"); libssh2_session_free(guac_client_data->sftp_ssh_session); } /* Free session */ if (guac_client_data->session != NULL) libssh2_session_free(guac_client_data->session); /* Free auth key */ if (guac_client_data->key != NULL) ssh_key_free(guac_client_data->key); /* Free clipboard */ guac_common_clipboard_free(guac_client_data->clipboard); /* Free cursors */ guac_ssh_cursor_free(client, guac_client_data->ibar_cursor); guac_ssh_cursor_free(client, guac_client_data->blank_cursor); /* Free generic data struct */ free(client->data); return 0; }
int guac_ssh_client_free_handler(guac_client* client) { guac_ssh_client* ssh_client = (guac_ssh_client*) client->data; /* Close SSH channel */ if (ssh_client->term_channel != NULL) { libssh2_channel_send_eof(ssh_client->term_channel); libssh2_channel_close(ssh_client->term_channel); } /* Free terminal (which may still be using term_channel) */ if (ssh_client->term != NULL) { guac_terminal_free(ssh_client->term); pthread_join(ssh_client->client_thread, NULL); } /* Free terminal channel now that the terminal is finished */ if (ssh_client->term_channel != NULL) libssh2_channel_free(ssh_client->term_channel); /* Clean up the SFTP filesystem object and session */ if (ssh_client->sftp_filesystem) { guac_common_ssh_destroy_sftp_filesystem(ssh_client->sftp_filesystem); guac_common_ssh_destroy_session(ssh_client->sftp_session); } /* Free interactive SSH session */ if (ssh_client->session != NULL) guac_common_ssh_destroy_session(ssh_client->session); /* Free SSH client credentials */ if (ssh_client->user != NULL) guac_common_ssh_destroy_user(ssh_client->user); /* Free parsed settings */ if (ssh_client->settings != NULL) guac_ssh_settings_free(ssh_client->settings); /* Free client structure */ free(ssh_client); guac_common_ssh_uninit(); return 0; }