diff mbox series

[01/13] curl: add support for Unix Domain Socket

Message ID 20231120154731.44988-2-stefano.babic@swupdate.org
State Accepted
Headers show
Series Native Docker Support | expand

Commit Message

Stefano Babic Nov. 20, 2023, 3:47 p.m. UTC
Set configuration for communication via Unix Domain Socket (UDS). This
can be used for many communications running locally on the target
device.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 corelib/channel_curl.c | 10 ++++++++++
 include/channel_curl.h |  1 +
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index c411aa8a..8ab0eca3 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -605,6 +605,16 @@  channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da
 		goto cleanup;
 	}
 
+	/*
+	 * If connection is via unix socket, set it
+	 */
+	if (channel_data->unix_socket &&
+		(curl_easy_setopt(channel_curl->handle, CURLOPT_UNIX_SOCKET_PATH,
+		 channel_data->unix_socket) != CURLE_OK)) {
+		result = CHANNEL_EINIT;
+		goto cleanup;
+	}
+
 	/* Check if sslkey or sslcert strings contains a pkcs11 URI
 	 * and set curl engine and types accordingly
 	 */
diff --git a/include/channel_curl.h b/include/channel_curl.h
index 643082b1..1eefbb1c 100644
--- a/include/channel_curl.h
+++ b/include/channel_curl.h
@@ -36,6 +36,7 @@  typedef enum {
 
 typedef struct {
 	char *url;
+	char *unix_socket;
 	char *cached_file;
 	char *auth;
 	char *request_body;