GUAC-548: Migrate to new error codes throughout protocol support.
This commit is contained in:
parent
3105cfbb48
commit
fdf2036cfe
@ -130,7 +130,7 @@ int __guac_handle_file(guac_client* client, guac_instruction* instruction) {
|
|||||||
dummy_stream.index = stream_index;
|
dummy_stream.index = stream_index;
|
||||||
|
|
||||||
guac_protocol_send_ack(client->socket, &dummy_stream,
|
guac_protocol_send_ack(client->socket, &dummy_stream,
|
||||||
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
"Invalid stream index", GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ int __guac_handle_pipe(guac_client* client, guac_instruction* instruction) {
|
|||||||
dummy_stream.index = stream_index;
|
dummy_stream.index = stream_index;
|
||||||
|
|
||||||
guac_protocol_send_ack(client->socket, &dummy_stream,
|
guac_protocol_send_ack(client->socket, &dummy_stream,
|
||||||
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
"Invalid stream index", GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ int __guac_handle_blob(guac_client* client, guac_instruction* instruction) {
|
|||||||
dummy_stream.index = stream_index;
|
dummy_stream.index = stream_index;
|
||||||
|
|
||||||
guac_protocol_send_ack(client->socket, &dummy_stream,
|
guac_protocol_send_ack(client->socket, &dummy_stream,
|
||||||
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
"Invalid stream index", GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ int __guac_handle_blob(guac_client* client, guac_instruction* instruction) {
|
|||||||
dummy_stream.index = stream_index;
|
dummy_stream.index = stream_index;
|
||||||
|
|
||||||
guac_protocol_send_ack(client->socket, &dummy_stream,
|
guac_protocol_send_ack(client->socket, &dummy_stream,
|
||||||
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
"Invalid stream index", GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ int __guac_handle_end(guac_client* client, guac_instruction* instruction) {
|
|||||||
|
|
||||||
guac_protocol_send_ack(client->socket, &dummy_stream,
|
guac_protocol_send_ack(client->socket, &dummy_stream,
|
||||||
"Invalid stream index",
|
"Invalid stream index",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
|
|||||||
if (freerdp_channels_pre_connect(channels, instance)) {
|
if (freerdp_channels_pre_connect(channels, instance)) {
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Error initializing RDP client channel manager",
|
"Error initializing RDP client channel manager",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ BOOL rdp_freerdp_post_connect(freerdp* instance) {
|
|||||||
if (freerdp_channels_post_connect(channels, instance)) {
|
if (freerdp_channels_post_connect(channels, instance)) {
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Error initializing RDP client channel manager",
|
"Error initializing RDP client channel manager",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
|
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Wrong argument count received.",
|
"Wrong argument count received.",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
|
|
||||||
guac_error = GUAC_STATUS_BAD_ARGUMENT;
|
guac_error = GUAC_STATUS_BAD_ARGUMENT;
|
||||||
@ -676,7 +676,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
|
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Error connecting to RDP server",
|
"Error connecting to RDP server",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
|
|
||||||
guac_error = GUAC_STATUS_BAD_STATE;
|
guac_error = GUAC_STATUS_BAD_STATE;
|
||||||
|
@ -528,7 +528,7 @@ int rdp_guac_client_blob_handler(guac_client* client, guac_stream* stream,
|
|||||||
default:
|
default:
|
||||||
guac_protocol_send_ack(client->socket, stream,
|
guac_protocol_send_ack(client->socket, stream,
|
||||||
"FAIL (BLOB NOT EXPECTED)",
|
"FAIL (BLOB NOT EXPECTED)",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
|
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
@ -552,7 +552,7 @@ int rdp_guac_client_end_handler(guac_client* client, guac_stream* stream) {
|
|||||||
default:
|
default:
|
||||||
guac_protocol_send_ack(client->socket, stream,
|
guac_protocol_send_ack(client->socket, stream,
|
||||||
"FAIL (END NOT EXPECTED)",
|
"FAIL (END NOT EXPECTED)",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
|
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -80,7 +80,7 @@ int guac_rdp_upload_file_handler(guac_client* client, guac_stream* stream,
|
|||||||
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ int guac_rdp_upload_file_handler(guac_client* client, guac_stream* stream,
|
|||||||
DISP_FILE_OVERWRITE_IF, 0);
|
DISP_FILE_OVERWRITE_IF, 0);
|
||||||
if (file_id < 0) {
|
if (file_id < 0) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (CANNOT OPEN)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (CANNOT OPEN)",
|
||||||
GUAC_PROTOCOL_STATUS_PERMISSION_DENIED);
|
GUAC_PROTOCOL_STATUS_CLIENT_FORBIDDEN);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ int guac_rdp_svc_pipe_handler(guac_client* client, guac_stream* stream,
|
|||||||
"Requested non-existent pipe: \"%s\".",
|
"Requested non-existent pipe: \"%s\".",
|
||||||
name);
|
name);
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (NO SUCH PIPE)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (NO SUCH PIPE)",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ int guac_rdp_upload_blob_handler(guac_client* client, guac_stream* stream,
|
|||||||
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ int guac_rdp_upload_blob_handler(guac_client* client, guac_stream* stream,
|
|||||||
if (bytes_written < 0) {
|
if (bytes_written < 0) {
|
||||||
guac_protocol_send_ack(client->socket, stream,
|
guac_protocol_send_ack(client->socket, stream,
|
||||||
"FAIL (BAD WRITE)",
|
"FAIL (BAD WRITE)",
|
||||||
GUAC_PROTOCOL_STATUS_PERMISSION_DENIED);
|
GUAC_PROTOCOL_STATUS_CLIENT_FORBIDDEN);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ int guac_rdp_upload_end_handler(guac_client* client, guac_stream* stream) {
|
|||||||
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ int guac_rdp_download_ack_handler(guac_client* client, guac_stream* stream,
|
|||||||
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
guac_rdp_fs* fs = ((rdp_guac_client_data*) client->data)->filesystem;
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
guac_protocol_send_ack(client->socket, stream, "FAIL (NO FS)",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
|||||||
/* Notify on error */
|
/* Notify on error */
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
guac_protocol_send_error(socket, "Error reading data.",
|
guac_protocol_send_error(socket, "Error reading data.",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ int guac_sftp_file_handler(guac_client* client, guac_stream* stream,
|
|||||||
if (!__ssh_guac_valid_filename(filename)) {
|
if (!__ssh_guac_valid_filename(filename)) {
|
||||||
guac_protocol_send_ack(client->socket, stream,
|
guac_protocol_send_ack(client->socket, stream,
|
||||||
"SFTP: Illegal filename",
|
"SFTP: Illegal filename",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ int guac_sftp_file_handler(guac_client* client, guac_stream* stream,
|
|||||||
/* If path + filename exceeds max length, abort */
|
/* If path + filename exceeds max length, abort */
|
||||||
if (i == GUAC_SFTP_MAX_PATH) {
|
if (i == GUAC_SFTP_MAX_PATH) {
|
||||||
guac_protocol_send_ack(client->socket, stream, "SFTP: Name too long",
|
guac_protocol_send_ack(client->socket, stream, "SFTP: Name too long",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ int guac_sftp_file_handler(guac_client* client, guac_stream* stream,
|
|||||||
guac_client_log_error(client, "Unable to open file \"%s\": %s",
|
guac_client_log_error(client, "Unable to open file \"%s\": %s",
|
||||||
fullpath, libssh2_sftp_last_error(client_data->sftp_session));
|
fullpath, libssh2_sftp_last_error(client_data->sftp_session));
|
||||||
guac_protocol_send_ack(client->socket, stream, "SFTP: Open failed",
|
guac_protocol_send_ack(client->socket, stream, "SFTP: Open failed",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ int guac_sftp_blob_handler(guac_client* client, guac_stream* stream,
|
|||||||
guac_client_log_error(client, "Unable to write to file: %s",
|
guac_client_log_error(client, "Unable to write to file: %s",
|
||||||
libssh2_sftp_last_error(client_data->sftp_session));
|
libssh2_sftp_last_error(client_data->sftp_session));
|
||||||
guac_protocol_send_ack(client->socket, stream, "SFTP: Write failed",
|
guac_protocol_send_ack(client->socket, stream, "SFTP: Write failed",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ int guac_sftp_end_handler(guac_client* client, guac_stream* stream) {
|
|||||||
else {
|
else {
|
||||||
guac_client_log_error(client, "Unable to close file");
|
guac_client_log_error(client, "Unable to close file");
|
||||||
guac_protocol_send_ack(client->socket, stream, "SFTP: Close failed",
|
guac_protocol_send_ack(client->socket, stream, "SFTP: Close failed",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
client_data->session = __guac_ssh_create_session(client, &socket_fd);
|
client_data->session = __guac_ssh_create_session(client, &socket_fd);
|
||||||
if (client_data->session == NULL) {
|
if (client_data->session == NULL) {
|
||||||
guac_protocol_send_error(socket, "Unable to create SSH session.",
|
guac_protocol_send_error(socket, "Unable to create SSH session.",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
libssh2_channel_open_session(client_data->session);
|
libssh2_channel_open_session(client_data->session);
|
||||||
if (client_data->term_channel == NULL) {
|
if (client_data->term_channel == NULL) {
|
||||||
guac_protocol_send_error(socket, "Unable to open channel.",
|
guac_protocol_send_error(socket, "Unable to open channel.",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
libssh2_sftp_init(client_data->sftp_ssh_session);
|
libssh2_sftp_init(client_data->sftp_ssh_session);
|
||||||
if (client_data->sftp_session == NULL) {
|
if (client_data->sftp_session == NULL) {
|
||||||
guac_protocol_send_error(socket, "Unable to start SFTP session..",
|
guac_protocol_send_error(socket, "Unable to start SFTP session..",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
client_data->term->term_width, client_data->term->term_height,
|
client_data->term->term_width, client_data->term->term_height,
|
||||||
0, 0)) {
|
0, 0)) {
|
||||||
guac_protocol_send_error(socket, "Unable to allocate PTY for channel.",
|
guac_protocol_send_error(socket, "Unable to allocate PTY for channel.",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ void* ssh_client_thread(void* data) {
|
|||||||
/* Request shell */
|
/* Request shell */
|
||||||
if (libssh2_channel_shell(client_data->term_channel)) {
|
if (libssh2_channel_shell(client_data->term_channel)) {
|
||||||
guac_protocol_send_error(socket, "Unable to associate shell with PTY.",
|
guac_protocol_send_error(socket, "Unable to associate shell with PTY.",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
if (argc != VNC_ARGS_COUNT) {
|
if (argc != VNC_ARGS_COUNT) {
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Wrong argument count received.",
|
"Wrong argument count received.",
|
||||||
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
|
GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
if (!rfb_client) {
|
if (!rfb_client) {
|
||||||
guac_protocol_send_error(client->socket,
|
guac_protocol_send_error(client->socket,
|
||||||
"Error initializing VNC client",
|
"Error initializing VNC client",
|
||||||
GUAC_PROTOCOL_STATUS_INTERNAL_ERROR);
|
GUAC_PROTOCOL_STATUS_SERVER_ERROR);
|
||||||
guac_socket_flush(client->socket);
|
guac_socket_flush(client->socket);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user