Append the microsecond-level connection time to the abstract socket name, making it always unique

This commit is contained in:
Lauri Kasanen 2021-05-10 19:16:28 +03:00
parent 7a695c976e
commit 9144045718

View File

@ -20,6 +20,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#include "websocket.h" #include "websocket.h"
/* /*
@ -227,9 +228,13 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
strcpy(addr.sun_path, ".KasmVNCSock"); strcpy(addr.sun_path, ".KasmVNCSock");
addr.sun_path[0] = '\0'; addr.sun_path[0] = '\0';
struct timeval tv;
gettimeofday(&tv, NULL);
struct sockaddr_un myaddr; struct sockaddr_un myaddr;
myaddr.sun_family = AF_UNIX; 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'; myaddr.sun_path[0] = '\0';
int tsock = socket(AF_UNIX, SOCK_STREAM, 0); int tsock = socket(AF_UNIX, SOCK_STREAM, 0);