From: Daniel Lenski Date: Thu, 3 Feb 2022 22:12:17 +0000 (-0800) Subject: In dumb_socketpair(), delete Unix-domain socket path once no longer needed X-Git-Tag: v8.20~10 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dd926507221de1c544f96f40de2d6b9001c9a2ef;p=users%2Fdwmw2%2Fopenconnect.git In dumb_socketpair(), delete Unix-domain socket path once no longer needed Small follow-up improvement to https://gitlab.com/openconnect/openconnect/-/merge_requests/320, which made dumb_socketpair() able to use Unix-domain sockets, on those Windows versions that support them albeit only with named paths. This was suggested as a way to prevent the Windows dumb_socketpair() implementation from leaving behind size-0 files, even if normally only in temporary directories. See original suggestion at https://github.com/microsoft/WSL/issues/4240#issuecomment-1027607891. Signed-off-by: Daniel Lenski --- diff --git a/compat.c b/compat.c index 4c0863e3..ecaf87d3 100644 --- a/compat.c +++ b/compat.c @@ -511,6 +511,8 @@ int dumb_socketpair(OPENCONNECT_CMD_SOCKET socks[2], int make_overlapped) goto fallback; if (connect(socks[0], &a.addr, addrlen) == SOCKET_ERROR) goto fallback; + if (domain == AF_UNIX) + DeleteFile(a.unaddr.sun_path); // Socket file no longer needed socks[1] = accept(listener, NULL, NULL); if (socks[1] == INVALID_SOCKET)