Skip to content
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

Add support for abstract Unix sockets #14

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Add support for abstract Unix sockets #14

merged 1 commit into from
Aug 8, 2023

Conversation

aszlig
Copy link
Contributor

@aszlig aszlig commented May 28, 2020

Abstract Unix domain sockets are a Linux extension, which allows to bind a socket to a name not bound to a particular file system path.

While I personally don't have a need for this, since I actually want to use file system paths in order to separate permissions, it does however make sense to support it for the sake of completeness.

@aszlig aszlig linked an issue May 28, 2020 that may be closed by this pull request
@aszlig aszlig added this to the 2.2.0 milestone May 28, 2020
@aszlig aszlig force-pushed the abstract-sockets branch 7 times, most recently from 964023b to 14d62fe Compare August 8, 2023 01:58
@aszlig aszlig marked this pull request as ready for review August 8, 2023 01:59
Adding abstract namespace sockets has been requested a long time ago[1]
and while I also had a partial implementation laying around, it was also
so ugly that I didn't want to merge it.

The reason why it was ugly was that first of all, I added another
"abstract" field to struct Rule and second, I used a boolean is_abstract
all over the place to distinguish between socket_path and abstract.

While in the end this resulted in a functional implementation, it also
made the code messier and hard to extend.

In the years passing since the aforementioned issue, I had several
occasions where abstract sockets would have been useful, so today I
decided to rewrite the ugly implementation mentioned above.

The new implementation now simply abstracts away the socket_path field
into a SocketPath type, which then either is marked Type::ABSTRACT or
Type::FILESYSTEM.

This has the advantage that we only need to know the details about
SocketPath when we parse the rules and when we create the SockAddr,
everything in between is just changing types from std::string to
SocketPath.

[1]: #8

Signed-off-by: aszlig <[email protected]>
Closes: #8
@aszlig aszlig merged commit a1b0a51 into master Aug 8, 2023
2 checks passed
@aszlig aszlig deleted the abstract-sockets branch August 8, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support abstract sockets on linux
1 participant