curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

feature request: support specifying Unix socket with systemd directive OpenFile=

From: Erik Sjölund via curl-users <curl-users_at_lists.haxx.se>
Date: Tue, 20 Jun 2023 12:06:48 +0200

Hello,
curl already has the command-line option

--unix-socket path

where the UNIX socket is specified as a path in the file system.
It would be nice if curl would also support using an inherited file
descriptor that originates from systemd.

The systemd directive OpenFile= was introduced in systemd 253
(released February 2023).

Man page:
https://www.freedesktop.org/software/systemd/man/systemd.service.html#OpenFile=

Rationale: Due to restrictive file permissions on a Unix socket, curl
might not be able to connect to the Unix socket of a web server. By
letting systemd connect to the Unix socket and then letting curl
inherit the file descriptor, curl would be able to retrieve web pages
from the Unix socket.

Demo:
I wrote a minimal demo where I modified docs/examples/externalsocket.c
to make use of a Unix socket specified with OpenFile=

https://github.com/eriksjolund/podman-OpenFile
https://github.com/eriksjolund/curl/blob/externalsocket_openfile/docs/examples/externalsocket.c

Regarding the user interface, a new command-line argument could be added

For example:
--unix-socket-fdname myfdname

A side note: OpenFile= could also be used for opening normal files.
In addition to the already existing command-line argument
--proxy-cacert
a new command-line argument
--proxy-cacert-fdname myfdname
could be added.

Kind regards,
Erik Sjölund
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-06-20