-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unix_socket: add support for abstract unix domain socket #1197
Conversation
@Frenche, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bagder, @Lekensteyn and @yangtse to be potential reviewers. |
Note, the man pages are missing, I'll work on it asap. |
config->unix_socket_path); | ||
my_setopt_str(curl, config->abstract_unix_socket ? | ||
CURLOPT_ABSTRACT_UNIX_SOCKET : | ||
CURLOPT_UNIX_SOCKET_PATH, config->unix_socket_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix for style, use column alignment. suggest parentheses and braces to make it easier to understand
if(config->unix_socket_path) {
my_setopt_str(curl, (config->abstract_unix_socket ?
CURLOPT_ABSTRACT_UNIX_SOCKET :
CURLOPT_UNIX_SOCKET_PATH),
config->unix_socket_path);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it occurs to me that CURLoption parameter is stringized by the function-like macro so I'm pretty sure this is not going to work, run with --libcurl to confirm. Assuming that's the case do this instead
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);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll fix this.
/* sun_path must be able to store the NUL-terminated path */ | ||
path_len = strlen(path); | ||
if(path_len >= sizeof(sa_un->sun_path)) { | ||
path_len = strlen(path) +1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change all the +1
to + 1
and the -1
to - 1
. I don't think we have a policy on it but foo +1
looks weird and I don't recall it elsewhere in the codebase. Occasionally I've seen foo+1
but foo + 1
I believe is more common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Can you modify this to use url-escaped paths (and make this encoding requirement very clear in the docs)? That will correctly handle paths containing NUL bytes. (As for alternatives: |
@Lekensteyn that was my initial intention (see comments in #1061), however it got complicated in matter of design, usage and implementation. |
4e932d7
to
f9fb05d
Compare
I've addressed Jay's comments and added the missing doc, please review - thanks! |
f9fb05d
to
d03029d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only some doc nitpicks below :-)
.\" * | (__| |_| | _ <| |___ | ||
.\" * \___|\___/|_| \_\_____| | ||
.\" * | ||
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already in 2017 :-)
.\" * | ||
.\" ************************************************************************** | ||
.\" | ||
.TH CURLOPT_ABSTRACT_UNIX_SOCKET 3 "08 Jan 2016" "libcurl 7.53.0" "curl_easy_setopt options" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
@@ -272,6 +272,7 @@ static const char *const helptext[] = { | |||
" --tlspassword STRING TLS password", | |||
" --tlsauthtype STRING TLS authentication type (default: SRP)", | |||
" --unix-socket FILE Connect through this Unix domain socket", | |||
" --abstract-unix-socket PATH Connect to an abstract Unix domain socket", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with --unix-socket
, maybe change FILE to PATH (or the other way round?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't a file in case of abstract, but path would be fine for both, I'll fix it.
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)
d03029d
to
57fcd60
Compare
Thanks for the reviews, I've addressed @Lekensteyn's comments. |
It's better as FILE because that's what we use in the other options , see curl --help | grep FILE |
I may have spoken too soon maybe it's not better as FILE, if it's not a file. |
Yea, it is not a file, just a name (could be just 'foo', without slash). |
Ok, nevermind then |
Actually, a regular unix socket which is a file, can also be set to just 'foo' as a relative path, but abstract is really not a file on the file system. |
Ok, thanks for explaining that. I think it was fine the way you had it then, FILE for unix domain and PATH for abstract unix domain. |
The man page terminology argument was about both :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll try to test the new functionality after the weekend and merge then.
(Hey, if you want to get your hands wet, maybe you can create another patch that extends the test suite with support for abstract domain sockets :-))
Decided to apply it now anyway. Briefly tested with an out-of-tree autotools build. Tested things like:
|
Great, thanks all! |
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.
Reported-by: Chungtsun Li (typeless)
Signed-off-by: Isaac Boukris iboukris@gmail.com
Fixes #1061