From 6d7156bc70d568d125b659176b8a7dddcfe4a9f9 Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Fri, 1 Apr 2022 19:30:31 -0400 Subject: [PATCH] GUACAMOLE-1293: Update struct member that stores human-readable name. --- src/libguac/client.c | 16 ++++++++-------- src/libguac/guacamole/user.h | 2 +- src/libguac/user-handlers.c | 14 ++++++++------ src/libguac/user-handlers.h | 4 ++-- src/libguac/user-handshake.c | 6 +++--- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/libguac/client.c b/src/libguac/client.c index 3f307579..612a0bb1 100644 --- a/src/libguac/client.c +++ b/src/libguac/client.c @@ -763,12 +763,12 @@ static void* guac_client_owner_notify_join_callback(guac_user* user, void* data) int retval = 0; char* owner = "owner"; - if (user->info.name != NULL) - owner = strdup(user->info.name); + if (user->info.username != NULL) + owner = strdup(user->info.username); char* joinName = "anonymous"; - if (joiner->info.name != NULL) - joinName = strdup(joiner->info.name); + if (joiner->info.username != NULL) + joinName = strdup(joiner->info.username); guac_user_log(user, GUAC_LOG_DEBUG, "Notifying %s of %s joining.", owner, joinName); @@ -826,12 +826,12 @@ static void* guac_client_owner_notify_leave_callback(guac_user* user, void* data const guac_user* quitter = (const guac_user *) data; char* owner = "owner"; - if (user->info.name != NULL) - owner = strdup(user->info.name); + if (user->info.username != NULL) + owner = strdup(user->info.username); char* quitterName = "anonymous"; - if (quitter->info.name != NULL) - quitterName = strdup(quitter->info.name); + if (quitter->info.username != NULL) + quitterName = strdup(quitter->info.username); guac_user_log(user, GUAC_LOG_DEBUG, "Notifying %s of %s leaving.", owner, quitterName); diff --git a/src/libguac/guacamole/user.h b/src/libguac/guacamole/user.h index 06db8fd6..dc27bb6d 100644 --- a/src/libguac/guacamole/user.h +++ b/src/libguac/guacamole/user.h @@ -93,7 +93,7 @@ struct guac_user_info { * The human-readable name of the Guacamole user. If the client does not * provide a name then this will be NULL. */ - const char* name; + const char* username; /** * The timezone of the remote system. If the client does not provide diff --git a/src/libguac/user-handlers.c b/src/libguac/user-handlers.c index 0c084457..66488c6a 100644 --- a/src/libguac/user-handlers.c +++ b/src/libguac/user-handlers.c @@ -64,7 +64,7 @@ __guac_instruction_handler_mapping __guac_handshake_handler_map[] = { {"video", __guac_handshake_video_handler}, {"image", __guac_handshake_image_handler}, {"timezone", __guac_handshake_timezone_handler}, - {"name", __guac_handshake_name_handler}, + {"username", __guac_handshake_username_handler}, {NULL, NULL} }; @@ -677,16 +677,18 @@ int __guac_handshake_image_handler(guac_user* user, int argc, char** argv) { } -int __guac_handshake_name_handler(guac_user* user, int argc, char** argv) { +int __guac_handshake_username_handler(guac_user* user, int argc, char** argv) { - /* Free any past value */ - free((char *) user->info.name); + /* Free any past value for the user's name */ + free((char *) user->info.username); + /* If a value is provided for the username, copy it into guac_user. */ if (argc > 0 && strcmp(argv[0], "")) - user->info.name = (const char*) strdup(argv[0]); + user->info.username = (const char*) strdup(argv[0]); + /* No or empty value was provided, so make sure this is NULLed out. */ else - user->info.name = NULL; + user->info.username = NULL; return 0; diff --git a/src/libguac/user-handlers.h b/src/libguac/user-handlers.h index 7f82302b..785e5b6b 100644 --- a/src/libguac/user-handlers.h +++ b/src/libguac/user-handlers.h @@ -219,11 +219,11 @@ __guac_instruction_handler __guac_handshake_video_handler; __guac_instruction_handler __guac_handshake_image_handler; /** - * Internal handler function that is called when the name instruction is + * Internal handler function that is called when the username instruction is * received during the handshake process, specifying the name of the Guacamole * user establishing the connection. */ -__guac_instruction_handler __guac_handshake_name_handler; +__guac_instruction_handler __guac_handshake_username_handler; /** * Internal handler function that is called when the timezone instruction is diff --git a/src/libguac/user-handshake.c b/src/libguac/user-handshake.c index 0863325f..e2910f0e 100644 --- a/src/libguac/user-handshake.c +++ b/src/libguac/user-handshake.c @@ -296,7 +296,7 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) { user->info.audio_mimetypes = NULL; user->info.image_mimetypes = NULL; user->info.video_mimetypes = NULL; - user->info.name = NULL; + user->info.username = NULL; user->info.timezone = NULL; /* Count number of arguments. */ @@ -371,8 +371,8 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) { guac_free_mimetypes((char **) user->info.image_mimetypes); guac_free_mimetypes((char **) user->info.video_mimetypes); - /* Free name and timezone info. */ - free((char *) user->info.name); + /* Free username and timezone info. */ + free((char *) user->info.username); free((char *) user->info.timezone); guac_parser_free(parser);