mirror of
https://github.com/curl/curl.git
synced 2026-06-10 08:14:15 +03:00
unix_socket: add support for abstract unix domain socket
In addition to unix domain sockets, Linux also supports an abstract namespace which is independent of the filesystem. In order to support it, add new CURLOPT_ABSTRACT_UNIX_SOCKET option which uses the same storage as CURLOPT_UNIX_SOCKET_PATH internally, along with a flag to specify abstract socket. On non-supporting platforms, the abstract address will be interpreted as an empty string and fail gracefully. Also add new --abstract-unix-socket tool parameter. Signed-off-by: Isaac Boukris <iboukris@gmail.com> Reported-by: Chungtsun Li (typeless) Reviewed-by: Daniel Stenberg Reviewed-by: Peter Wu Closes #1197 Fixes #1061
This commit is contained in:
parent
a7c73ae309
commit
1d786faee1
17 changed files with 139 additions and 19 deletions
|
|
@ -230,6 +230,7 @@ struct OperationConfig {
|
|||
bool nonpn; /* enable/disable TLS NPN extension */
|
||||
bool noalpn; /* enable/disable TLS ALPN extension */
|
||||
char *unix_socket_path; /* path to Unix domain socket */
|
||||
bool abstract_unix_socket; /* path to an abstract Unix domain socket */
|
||||
bool falsestart;
|
||||
bool path_as_is;
|
||||
double expect100timeout;
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ static const struct LongShort aliases[]= {
|
|||
{"$R", "expect100-timeout", TRUE},
|
||||
{"$S", "tftp-no-options", FALSE},
|
||||
{"$U", "connect-to", TRUE},
|
||||
{"$W", "abstract-unix-socket", TRUE},
|
||||
{"0", "http1.0", FALSE},
|
||||
{"01", "http1.1", FALSE},
|
||||
{"02", "http2", FALSE},
|
||||
|
|
@ -1024,6 +1025,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
#endif
|
||||
break;
|
||||
case 'M': /* --unix-socket */
|
||||
config->abstract_unix_socket = FALSE;
|
||||
GetStr(&config->unix_socket_path, nextarg);
|
||||
break;
|
||||
case 'N': /* --path-as-is */
|
||||
|
|
@ -1054,6 +1056,10 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
if(err)
|
||||
return err;
|
||||
break;
|
||||
case 'W': /* --abstract-unix-socket */
|
||||
config->abstract_unix_socket = TRUE;
|
||||
GetStr(&config->unix_socket_path, nextarg);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '#': /* --progress-bar */
|
||||
|
|
|
|||
|
|
@ -271,7 +271,8 @@ static const char *const helptext[] = {
|
|||
" --tlsuser USER TLS username",
|
||||
" --tlspassword STRING TLS password",
|
||||
" --tlsauthtype STRING TLS authentication type (default: SRP)",
|
||||
" --unix-socket FILE Connect through this Unix domain socket",
|
||||
" --unix-socket PATH Connect through this Unix domain socket",
|
||||
" --abstract-unix-socket PATH Connect to an abstract Unix domain socket",
|
||||
" -A, --user-agent STRING Send User-Agent STRING to server (H)",
|
||||
" -v, --verbose Make the operation more talkative",
|
||||
" -V, --version Show version number and quit",
|
||||
|
|
|
|||
|
|
@ -1393,11 +1393,17 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
my_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L);
|
||||
}
|
||||
|
||||
/* new in 7.40.0 */
|
||||
if(config->unix_socket_path)
|
||||
my_setopt_str(curl, CURLOPT_UNIX_SOCKET_PATH,
|
||||
config->unix_socket_path);
|
||||
|
||||
/* new in 7.40.0, abstract support added in 7.53.0 */
|
||||
if(config->unix_socket_path) {
|
||||
if(config->abstract_unix_socket) {
|
||||
my_setopt_str(curl, CURLOPT_ABSTRACT_UNIX_SOCKET,
|
||||
config->unix_socket_path);
|
||||
}
|
||||
else {
|
||||
my_setopt_str(curl, CURLOPT_UNIX_SOCKET_PATH,
|
||||
config->unix_socket_path);
|
||||
}
|
||||
}
|
||||
/* new in 7.45.0 */
|
||||
if(config->proto_default)
|
||||
my_setopt_str(curl, CURLOPT_DEFAULT_PROTOCOL, config->proto_default);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue