GUACAMOLE-221: Make lock, condition, and flags specific to credentials.
This commit is contained in:
parent
7369bed22c
commit
76ef6332cc
@ -123,29 +123,26 @@ static int guac_rdp_argv_end_handler(guac_user* user,
|
||||
/* Update RDP username. */
|
||||
case GUAC_RDP_ARGV_SETTING_USERNAME:
|
||||
free(settings->username);
|
||||
settings->username = malloc(strlen(argv->buffer) * sizeof(char));
|
||||
strcpy(settings->username, argv->buffer);
|
||||
rdp_client->rdp_cond_flags ^= GUAC_RDP_COND_FLAG_USERNAME;
|
||||
settings->username = strndup(argv->buffer, argv->length);
|
||||
rdp_client->rdp_credential_flags &= ~GUAC_RDP_CRED_FLAG_USERNAME;
|
||||
break;
|
||||
|
||||
case GUAC_RDP_ARGV_SETTING_PASSWORD:
|
||||
free(settings->password);
|
||||
settings->password = malloc(strlen(argv->buffer) * sizeof(char));
|
||||
strcpy(settings->password, argv->buffer);
|
||||
rdp_client->rdp_cond_flags ^= GUAC_RDP_COND_FLAG_PASSWORD;
|
||||
settings->password = strndup(argv->buffer, argv->length);
|
||||
rdp_client->rdp_credential_flags &= ~GUAC_RDP_CRED_FLAG_PASSWORD;
|
||||
break;
|
||||
|
||||
case GUAC_RDP_ARGV_SETTING_DOMAIN:
|
||||
free(settings->domain);
|
||||
settings->domain = malloc(strlen(argv->buffer) * sizeof(char));
|
||||
strcpy(settings->domain, argv->buffer);
|
||||
rdp_client->rdp_cond_flags ^= GUAC_RDP_COND_FLAG_DOMAIN;
|
||||
settings->domain = strndup(argv->buffer, argv->length);
|
||||
rdp_client->rdp_credential_flags &= ~GUAC_RDP_CRED_FLAG_DOMAIN;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (!rdp_client->rdp_cond_flags)
|
||||
pthread_cond_signal(&(rdp_client->rdp_cond));
|
||||
if (!rdp_client->rdp_credential_flags)
|
||||
pthread_cond_signal(&(rdp_client->rdp_credential_cond));
|
||||
|
||||
free(argv);
|
||||
return 0;
|
||||
|
@ -225,7 +225,7 @@ int guac_rdp_client_free_handler(guac_client* client) {
|
||||
guac_rdp_audio_buffer_free(rdp_client->audio_input);
|
||||
|
||||
/* Destroy the pthread conditional handler */
|
||||
pthread_cond_destroy(&(rdp_client->rdp_cond));
|
||||
pthread_cond_destroy(&(rdp_client->rdp_credential_cond));
|
||||
|
||||
pthread_rwlock_destroy(&(rdp_client->lock));
|
||||
|
||||
|
@ -235,19 +235,19 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username,
|
||||
|
||||
if (settings->username == NULL || strcmp(settings->username, "") == 0) {
|
||||
params[i] = "username";
|
||||
rdp_client->rdp_cond_flags |= GUAC_RDP_COND_FLAG_USERNAME;
|
||||
rdp_client->rdp_credential_flags |= GUAC_RDP_CRED_FLAG_USERNAME;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (settings->password == NULL || strcmp(settings->password, "") == 0) {
|
||||
params[i] = "password";
|
||||
rdp_client->rdp_cond_flags |= GUAC_RDP_COND_FLAG_PASSWORD;
|
||||
rdp_client->rdp_credential_flags |= GUAC_RDP_CRED_FLAG_PASSWORD;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (settings->domain == NULL || strcmp(settings->domain, "") == 0) {
|
||||
params[i] = "domain";
|
||||
rdp_client->rdp_cond_flags |= GUAC_RDP_COND_FLAG_DOMAIN;
|
||||
rdp_client->rdp_credential_flags |= GUAC_RDP_CRED_FLAG_DOMAIN;
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -256,14 +256,14 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username,
|
||||
|
||||
if (i > 0) {
|
||||
/* Lock the client thread. */
|
||||
pthread_mutex_lock(&(rdp_client->rdp_lock));
|
||||
pthread_mutex_lock(&(rdp_client->rdp_credential_lock));
|
||||
|
||||
/* Send require params and flush socket. */
|
||||
guac_protocol_send_required(client->socket, (const char**) params);
|
||||
guac_socket_flush(client->socket);
|
||||
|
||||
/* Wait for condition. */
|
||||
pthread_cond_wait(&(rdp_client->rdp_cond), &(rdp_client->rdp_lock));
|
||||
pthread_cond_wait(&(rdp_client->rdp_credential_cond), &(rdp_client->rdp_credential_lock));
|
||||
|
||||
/* Get new values from settings. */
|
||||
*username = settings->username;
|
||||
@ -271,7 +271,7 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username,
|
||||
*domain = settings->domain;
|
||||
|
||||
/* Unlock the thread. */
|
||||
pthread_mutex_unlock(&(rdp_client->rdp_lock));
|
||||
pthread_mutex_unlock(&(rdp_client->rdp_credential_lock));
|
||||
}
|
||||
|
||||
/* Always return TRUE allowing connection to retry. */
|
||||
|
@ -52,17 +52,17 @@
|
||||
/**
|
||||
* A flag for tracking if we are waiting conditionally on a username.
|
||||
*/
|
||||
#define GUAC_RDP_COND_FLAG_USERNAME 1
|
||||
#define GUAC_RDP_CRED_FLAG_USERNAME 1
|
||||
|
||||
/**
|
||||
* A flag for tracking if we are waiting conditionally on a password.
|
||||
*/
|
||||
#define GUAC_RDP_COND_FLAG_PASSWORD 2
|
||||
#define GUAC_RDP_CRED_FLAG_PASSWORD 2
|
||||
|
||||
/**
|
||||
* A flag for tracking if we are waiting conditionally on a domain.
|
||||
*/
|
||||
#define GUAC_RDP_COND_FLAG_DOMAIN 3
|
||||
#define GUAC_RDP_CRED_FLAG_DOMAIN 4
|
||||
|
||||
/**
|
||||
* RDP-specific client data.
|
||||
|
@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include "argv.h"
|
||||
#include "channels/audio-input/audio-input.h"
|
||||
#include "channels/cliprdr.h"
|
||||
#include "channels/pipe-svc.h"
|
||||
|
Loading…
Reference in New Issue
Block a user