GUACAMOLE-1133: Merge addition of GCrypt initialization to VNC startup process.

This commit is contained in:
Mike Jumper 2021-01-22 21:33:10 -08:00 committed by GitHub
commit 6d526cb60f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 5 deletions

View File

@ -140,12 +140,22 @@ static void guac_common_ssh_openssl_free_locks(int count) {
int guac_common_ssh_init(guac_client* client) {
#ifdef LIBSSH2_USES_GCRYPT
if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
/* Init threadsafety in libgcrypt */
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
/* Initialize GCrypt */
if (!gcry_check_version(GCRYPT_VERSION)) {
guac_client_log(client, GUAC_LOG_ERROR, "libgcrypt version mismatch.");
return 1;
}
/* Mark initialization as completed. */
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
}
#endif
#ifdef OPENSSL_REQUIRES_THREADING_CALLBACKS

View File

@ -48,12 +48,22 @@
#include <guacamole/timestamp.h>
#include <guacamole/wol.h>
#include <rfb/rfbclient.h>
#include <rfb/rfbconfig.h>
#include <rfb/rfbproto.h>
#ifdef LIBVNCSERVER_WITH_CLIENT_GCRYPT
#include <errno.h>
#include <gcrypt.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef LIBVNCSERVER_WITH_CLIENT_GCRYPT
GCRY_THREAD_OPTION_PTHREAD_IMPL;
#endif
char* GUAC_VNC_CLIENT_KEY = "GUAC_VNC";
#ifdef ENABLE_VNC_TLS_LOCKING
@ -135,6 +145,27 @@ rfbClient* guac_vnc_get_client(guac_client* client) {
rfb_client->UnlockWriteToTLS = guac_vnc_unlock_write_to_tls;
#endif
#ifdef LIBVNCSERVER_WITH_CLIENT_GCRYPT
/* Check if GCrypt is initialized, do it if not. */
if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
guac_client_log(client, GUAC_LOG_DEBUG, "GCrypt initialization started.");
/* Initialize thread control. */
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
/* Basic GCrypt library initialization. */
gcry_check_version(NULL);
/* Mark initialization as completed. */
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
guac_client_log(client, GUAC_LOG_DEBUG, "GCrypt initialization completed.");
}
#endif
/* Do not handle clipboard and local cursor if read-only */
if (vnc_settings->read_only == 0) {