diff --git a/src/protocols/telnet/client.c b/src/protocols/telnet/client.c index 4a9d9f3a..c0c782f9 100644 --- a/src/protocols/telnet/client.c +++ b/src/protocols/telnet/client.c @@ -75,7 +75,7 @@ enum __TELNET_ARGS_IDX { /** * The regular expression to use when searching for the username/login prompt. - * Optional + * Optional. */ IDX_USERNAME_REGEX, @@ -106,7 +106,8 @@ enum __TELNET_ARGS_IDX { /** * Compile a regular expression and checks it return value. Returns NULL if compilation fails */ -static regex_t* __guac_telnet_compile_regext(guac_client* client, char* pattern) { +static regex_t* __guac_telnet_compile_regex(guac_client* client, char* pattern) { + int compile_result; regex_t* regex = malloc(sizeof(regex_t)); @@ -115,7 +116,7 @@ static regex_t* __guac_telnet_compile_regext(guac_client* client, char* pattern) /* Notify of failure to parse/compile */ if (compile_result != 0) { - guac_client_log_info(client, "Regular expression '%s' could not be compiled.", pattern); + guac_client_log_error(client, "Regular expression '%s' could not be compiled.", pattern); free(regex); return NULL; } @@ -156,20 +157,23 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Compile regular expression */ if (argv[IDX_USERNAME_REGEX][0] != 0) - client_data->username_regex = __guac_telnet_compile_regext(client, argv[IDX_USERNAME_REGEX]); + client_data->username_regex = __guac_telnet_compile_regex(client, argv[IDX_USERNAME_REGEX]); else - client_data->username_regex = __guac_telnet_compile_regext(client, GUAC_TELNET_DEFAULT_USERNAME_REGEX); + client_data->username_regex = __guac_telnet_compile_regex(client, GUAC_TELNET_DEFAULT_USERNAME_REGEX); + } else client_data->username_regex = NULL; /* Set password regex, if needed */ if (client_data->password[0] != 0) { + /* Compile regular expression */ if (argv[IDX_PASSWORD_REGEX][0] != 0) - client_data->password_regex = __guac_telnet_compile_regext(client, argv[IDX_PASSWORD_REGEX]); + client_data->password_regex = __guac_telnet_compile_regex(client, argv[IDX_PASSWORD_REGEX]); else - client_data->password_regex = __guac_telnet_compile_regext(client, GUAC_TELNET_DEFAULT_PASSWORD_REGEX); + client_data->password_regex = __guac_telnet_compile_regex(client, GUAC_TELNET_DEFAULT_PASSWORD_REGEX); + } else client_data->password_regex = NULL; diff --git a/src/protocols/telnet/client.h b/src/protocols/telnet/client.h index d2364904..e72a1a63 100644 --- a/src/protocols/telnet/client.h +++ b/src/protocols/telnet/client.h @@ -32,8 +32,8 @@ #include -#define GUAC_TELNET_DEFAULT_USERNAME_REGEX "login:" -#define GUAC_TELNET_DEFAULT_PASSWORD_REGEX "password:" +#define GUAC_TELNET_DEFAULT_USERNAME_REGEX "[Ll]ogin:" +#define GUAC_TELNET_DEFAULT_PASSWORD_REGEX "[Pp]assword:" /** * Telnet-specific client data. diff --git a/src/protocols/telnet/telnet_client.c b/src/protocols/telnet/telnet_client.c index f07ae6b7..6794d750 100644 --- a/src/protocols/telnet/telnet_client.c +++ b/src/protocols/telnet/telnet_client.c @@ -216,6 +216,7 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event, /* Environment request */ case TELNET_EV_ENVIRON: + /* Only send USER if entire environment was requested */ if (event->environ.size == 0) guac_telnet_send_user(telnet, client_data->username);