]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Change to common source file not applicable to open-vm-tools.
authorKruti Pendharkar <kp025370@broadcom.com>
Wed, 11 Jun 2025 00:48:53 +0000 (17:48 -0700)
committerKruti Pendharkar <kp025370@broadcom.com>
Wed, 11 Jun 2025 00:48:53 +0000 (17:48 -0700)
open-vm-tools/vgauth/serviceImpl/service.c

index 481af4b21ccd00728128dc21212f2327ed6f29fa..bb605a6cd6c94fa90532eee1cf892be5b1ce35f6 100644 (file)
@@ -29,7 +29,7 @@
 #include "VGAuthUtil.h"
 #ifdef _WIN32
 #include "winUtil.h"
-#include <gmodule.h>
+#include <glib.h>
 #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,