From d91778dcdf1cc11268222cad783eedbe06bbc2d0 Mon Sep 17 00:00:00 2001 From: Kruti Pendharkar Date: Tue, 10 Jun 2025 17:48:53 -0700 Subject: [PATCH] Change to common source file not applicable to open-vm-tools. --- open-vm-tools/vgauth/serviceImpl/service.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/open-vm-tools/vgauth/serviceImpl/service.c b/open-vm-tools/vgauth/serviceImpl/service.c index 481af4b21..bb605a6cd 100644 --- a/open-vm-tools/vgauth/serviceImpl/service.c +++ b/open-vm-tools/vgauth/serviceImpl/service.c @@ -29,7 +29,7 @@ #include "VGAuthUtil.h" #ifdef _WIN32 #include "winUtil.h" -#include +#include #endif static ServiceStartListeningForIOFunc startListeningIOFunc = NULL; @@ -286,14 +286,21 @@ ServiceUserNameToPipeName(const char *userName) { gchar *escapedName = ServiceEncodeUserName(userName); #ifdef _WIN32 + gchar *uuidStr = g_uuid_string_random(); /* * Add a unique suffix to avoid a name collision with an existing named pipe * created by someone else (intentionally or by accident). + * This is not needed for Linux; name collisions on sockets are already + * avoided there since (1) file system paths to VGAuthService sockets are in + * a directory that is writable only by root and (2) VGAuthService unlinks a + * socket path before binding it to a newly created socket. */ - gchar *pipeName = g_strdup_printf("%s-%s-%u", + gchar *pipeName = g_strdup_printf("%s-%s-%s", SERVICE_PUBLIC_PIPE_NAME, escapedName, - g_random_int()); + uuidStr); + + g_free(uuidStr); #else gchar *pipeName = g_strdup_printf("%s-%s", SERVICE_PUBLIC_PIPE_NAME, -- 2.47.3