From 89902847a8a2890796cd29484a145e378684ba63 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Fri, 24 Aug 2018 12:20:38 +0800
Subject: [PATCH] unix skt: default on

---
 CMakeLists.txt           | 2 +-
 lib/core/libwebsockets.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b5288b3..5c140c88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ option(LWS_WITH_HTTP2 "Compile with server support for HTTP/2" OFF)
 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" ON)
 option(LWS_WITH_PLUGINS "Support plugins for protocols and extensions" OFF)
 option(LWS_WITH_HTTP_PROXY "Support for rewriting HTTP proxying (requires libhubbub)" OFF)
 option(LWS_WITH_ZIP_FOPS "Support serving pre-zipped files" OFF)
diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c
index eeb9e168..351db79a 100644
--- a/lib/core/libwebsockets.c
+++ b/lib/core/libwebsockets.c
@@ -2593,9 +2593,11 @@ lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port,
 	}
 
 #if defined(LWS_WITH_UNIX_SOCK)
-	if (LWS_UNIX_SOCK_ENABLED(vhost) && vhost->context->uid) {
-		chown(serv_unix.sun_path, vhost->context->uid, vhost->context->gid);
-	}
+	if (LWS_UNIX_SOCK_ENABLED(vhost) && vhost->context->uid)
+		if (chown(serv_unix.sun_path, vhost->context->uid,
+			    vhost->context->gid))
+			lwsl_notice("%s: chown for unix skt %s failed\n",
+				    __func__, serv_unix.sun_path);
 #endif
 
 #ifndef LWS_PLAT_OPTEE
-- 
GitLab