1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

windows: recent win10 support Unix Domain

Allow selection of Unix Domain Sockets on windows since it is supported
for the last couple of years on windows 10

https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

... if only they could add a full set of posix pieces to go with it
(and abstract namespace UDS which doesn't work apparently) so that
the parts dealing with uid / gid don't have to be disabled.
This commit is contained in:
Andy Green 2020-05-24 13:57:21 +01:00
parent c9c152baba
commit 911898ad70
7 changed files with 11 additions and 14 deletions

View file

@ -164,9 +164,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif()
# microsoft... that's why you can't have nice things
if (WIN32 OR LWS_PLAT_FREERTOS)
if (LWS_PLAT_FREERTOS)
set(LWS_UNIX_SOCK 0)
endif()

View file

@ -85,7 +85,7 @@ option(LWS_WITH_HTTP2 "Compile with server support for HTTP/2" ON)
option(LWS_WITH_LWSWS "Libwebsockets Webserver" OFF)
option(LWS_WITH_CGI "Include CGI (spawn process with network-connected stdin/out/err) APIs" OFF)
option(LWS_IPV6 "Compile with support for ipv6" OFF)
option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket" OFF)
option(LWS_UNIX_SOCK "Compile with support for UNIX domain socket if OS supports it" ON)
option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions" OFF)
option(LWS_WITH_HTTP_PROXY "Support for active HTTP proxying" OFF)
option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF)

View file

@ -225,7 +225,7 @@ lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port,
iface);
return LWS_ITOSA_NOT_EXIST;
}
n = sizeof(uint16_t) + strlen(iface);
n = (int)(sizeof(uint16_t) + strlen(iface));
strcpy(serv_unix.sun_path, iface);
if (serv_unix.sun_path[0] == '@')
serv_unix.sun_path[0] = '\0';
@ -315,7 +315,7 @@ lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port,
return LWS_ITOSA_NOT_EXIST;
}
#if defined(LWS_WITH_UNIX_SOCK)
#if defined(LWS_WITH_UNIX_SOCK) && !defined(WIN32)
if (!port && LWS_UNIX_SOCK_ENABLED(vhost)) {
uid_t uid = vhost->context->uid;
gid_t gid = vhost->context->gid;

View file

@ -706,7 +706,7 @@ lws_plat_init(struct lws_context *context,
LWS_EXTERN int
lws_plat_drop_app_privileges(struct lws_context *context, int actually_drop);
#if defined(LWS_WITH_UNIX_SOCK)
#if defined(LWS_WITH_UNIX_SOCK) && !defined(WIN32)
int
lws_plat_user_colon_group_to_ids(const char *u_colon_g, uid_t *puid, gid_t *pgid);
#endif

View file

@ -64,6 +64,10 @@
#include <mstcpip.h>
#include <io.h>
#if defined(LWS_WITH_UNIX_SOCK)
#include <afunix.h>
#endif
#if !defined(LWS_HAVE_ATOLL)
#if defined(LWS_HAVE__ATOI64)
#define atoll _atoi64

View file

@ -681,9 +681,9 @@ ads_known:
if (wsi->unix_skt) {
psa = (const struct sockaddr *)&sau;
if (sau.sun_path[0])
n = sizeof(uint16_t) + strlen(sau.sun_path);
n = (int)(sizeof(uint16_t) + strlen(sau.sun_path));
else
n = sizeof(uint16_t) + strlen(&sau.sun_path[1]) + 1;
n = (int)(sizeof(uint16_t) + strlen(&sau.sun_path[1]) + 1);
} else
#endif

View file

@ -101,11 +101,6 @@ endif()
set(LWS_OPENSSL_CLIENT_CERTS ../share CACHE PATH "Server SSL certificate directory")
if (WIN32)
set(LWS_OPENSSL_CLIENT_CERTS . CACHE PATH "Client SSL certificate directory" PARENT_SCOPE)
if (LWS_UNIX_SOCK)
set(LWS_UNIX_SOCK OFF PARENT_SCOPE)
message(WARNING "Windows does not support UNIX domain sockets")
endif()
else()
set(LWS_OPENSSL_CLIENT_CERTS /etc/pki/tls/certs/ CACHE PATH "Client SSL certificate directory")
endif()