diff --git a/guacamole/libguac/src/client.c b/guacamole/libguac/src/client.c index ee4ee0158..d6fd6658b 100644 --- a/guacamole/libguac/src/client.c +++ b/guacamole/libguac/src/client.c @@ -102,50 +102,60 @@ guac_client* guac_get_client(int client_fd) { } /* Connect instruction read */ - if (result > 0 && strcmp(instruction.opcode, "connect") == 0) { + if (result > 0) { - /* Get protocol from message */ - char* protocol = instruction.argv[0]; + if (strcmp(instruction.opcode, "connect") == 0) { - strcat(protocol_lib, protocol); - strcat(protocol_lib, ".so"); + /* Get protocol from message */ + char* protocol = instruction.argv[0]; - /* Create new client */ - client = __guac_alloc_client(io); + strcat(protocol_lib, protocol); + strcat(protocol_lib, ".so"); - /* Load client plugin */ - client->client_plugin_handle = dlopen(protocol_lib, RTLD_LAZY); - if (!(client->client_plugin_handle)) { - fprintf(stderr, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror()); - exit(EXIT_FAILURE); - } + /* Create new client */ + client = __guac_alloc_client(io); - dlerror(); /* Clear errors */ + /* Load client plugin */ + client->client_plugin_handle = dlopen(protocol_lib, RTLD_LAZY); + if (!(client->client_plugin_handle)) { + syslog(LOG_ERR, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror()); + guac_send_error(io, "Could not load server-side client plugin."); + guac_free_instruction_data(&instruction); + return NULL; + } - /* Get init function */ - alias.obj = dlsym(client->client_plugin_handle, "guac_client_init"); + dlerror(); /* Clear errors */ - if ((error = dlerror()) != NULL) { - fprintf(stderr, "Could not get guac_client_init in plugin: %s\n", error); - exit(EXIT_FAILURE); - } + /* Get init function */ + alias.obj = dlsym(client->client_plugin_handle, "guac_client_init"); - /* Initialize client arguments */ - argc = instruction.argc; - argv = instruction.argv; + if ((error = dlerror()) != NULL) { + syslog(LOG_ERR, "Could not get guac_client_init in plugin: %s\n", error); + guac_send_error(io, "Invalid server-side client plugin."); + guac_free_instruction_data(&instruction); + return NULL; + } - break; + /* Initialize client arguments */ + argc = instruction.argc; + argv = instruction.argv; + + if (alias.client_init(client, argc, argv) != 0) { + guac_free_instruction_data(&instruction); + guac_send_error(io, "Error initializing server-side client."); + return NULL; + } + + guac_free_instruction_data(&instruction); + return client; + + } /* end if connect */ + + guac_free_instruction_data(&instruction); } } - if (alias.client_init(client, argc, argv) != 0) - return NULL; - - guac_free_instruction_data(&instruction); - - return client; - } diff --git a/guacamole/proxy/src/daemon.c b/guacamole/proxy/src/daemon.c index 8a4a980fe..b8e545a11 100644 --- a/guacamole/proxy/src/daemon.c +++ b/guacamole/proxy/src/daemon.c @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) { int connected_socket_fd; /* Arguments */ - int listen_port = -1; + int listen_port = 4822; /* Default port */ int opt; /* Parse arguments */ @@ -95,17 +95,11 @@ int main(int argc, char* argv[]) { } } else { - fprintf(stderr, "USAGE: %s -l LISTENPORT\n", argv[0]); + fprintf(stderr, "USAGE: %s [-l LISTENPORT]\n", argv[0]); exit(EXIT_FAILURE); } } - /* Validate arguments */ - if (listen_port < 0) { - fprintf(stderr, "The port to listen on must be specified.\n"); - exit(EXIT_FAILURE); - } - /* Get binding address */ memset(&server_addr, 0, sizeof(server_addr)); /* Zero struct */ server_addr.sin_family = AF_INET;