From 9144045718b7519088aaaf605001fa3d34f92b34 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Mon, 10 May 2021 19:16:28 +0300 Subject: [PATCH] Append the microsecond-level connection time to the abstract socket name, making it always unique --- common/network/websockify.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/network/websockify.c b/common/network/websockify.c index aaabb9a..08491c9 100644 --- a/common/network/websockify.c +++ b/common/network/websockify.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "websocket.h" /* @@ -227,9 +228,13 @@ void proxy_handler(ws_ctx_t *ws_ctx) { strcpy(addr.sun_path, ".KasmVNCSock"); addr.sun_path[0] = '\0'; + struct timeval tv; + gettimeofday(&tv, NULL); + struct sockaddr_un myaddr; myaddr.sun_family = AF_UNIX; - sprintf(myaddr.sun_path, ".%s@%s", ws_ctx->user, ws_ctx->ip); + sprintf(myaddr.sun_path, ".%s@%s_%lu.%lu", ws_ctx->user, ws_ctx->ip, + tv.tv_sec, tv.tv_usec); myaddr.sun_path[0] = '\0'; int tsock = socket(AF_UNIX, SOCK_STREAM, 0);