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 fallback for unsupported abstract sockets #278

Merged
merged 10 commits into from
Sep 20, 2022

Commits on Sep 19, 2022

  1. docs(sockctl): document generate_socket_name()

    Add docs describing that generate_socket_name() returns a
    pseudo-random _abstract_ socket name, without the leading ␀-char.
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    1ce4e17 View commit details
    Browse the repository at this point in the history
  2. docs(sockctl): improve create_domain_client docs

    Add details on what _abstract_ Unix domain sockets are, and that
    they're used when the input path is NULL.
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    338c641 View commit details
    Browse the repository at this point in the history
  3. refactor(socketctl): make domain params const

    These input variables are not changed, so we should make them const.
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    b00f855 View commit details
    Browse the repository at this point in the history
  4. refactor(sockctl): clean up create_domain_*()

    Combines variable definition and initialization, since we aren't using
    an old C89 compiler.
    
    Additionally, I've replaced all of the sockaddr_un initialisations
    with portable C default initializers, as memset() is explicitly
    not recommended as it isn't portable,
    see [manpage for netinet_in.h under APPLICATION USAGE][1]
    
    [1]: https://manpages.ubuntu.com/manpages/jammy/en/man7/netinet_in.h.7posix.html
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    e196ead View commit details
    Browse the repository at this point in the history
  5. refactor(sockctl): autobind abstract unix sockets

    Instead of creating our own abstract address, using 8 random hex chars,
    we can use Linux's autobind feature to create a new **unused** abstract
    address consisting of 5 random hex chars.
    
    This is 3 less hex chars, however Linux's autobind feature ensures
    that the a new abstract address is always picked, unlike our custom
    generator, which may rarely create an abstract address that is already
    being used.
    
    See https://manpages.ubuntu.com/manpages/jammy/en/man7/unix.7.html for
    documentation on the "autobind feature".
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    390c321 View commit details
    Browse the repository at this point in the history
  6. feat(sockctl): add close_domain_socket function

    Creates a helper function that can be used to:
    - close a unix domain socket, and
    - unlink() the unix domain socket (if _pathname_ unix domain socket)
    
    I've modified the `close()` function after every
    create_domain_client(NULL) to instead call `close_domain_socket()`.
    aloisklink committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    b8d674b View commit details
    Browse the repository at this point in the history

Commits on Sep 20, 2022

  1. Configuration menu
    Copy the full SHA
    f34c098 View commit details
    Browse the repository at this point in the history
  2. feat(sockctl): support temp pathname unix sockets

    Currently, creating a temporary unix domain socket using
    `create_domain_client(NULL)` creates an abstract Unix domain
    socket, which only works on Linux.
    
    In order to support FreeBSD (and other Unix not-Linux platforms),
    `create_domain_client(NULL)` can now fallback to creating
    a new _pathname_ unix domain socket using `mkdtemp()`.
    aloisklink committed Sep 20, 2022
    Configuration menu
    Copy the full SHA
    ba72733 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9ccb5ad View commit details
    Browse the repository at this point in the history
  4. fix(sockctl): log when deleting tmp folders

    There's a very tiny chance that we'll misidentify a folder
    as a mkdtemp folder created by `create_tmp_domain_socket_path()`.
    
    For this case, I've added a log statement. It's only a log_debug(),
    since we expect that if this ever does misidentify a folder, rmdir()
    will throw an ENOTEMPTY (dir not empty) error, which will print
    an error log message.
    aloisklink committed Sep 20, 2022
    Configuration menu
    Copy the full SHA
    ae16f1c View commit details
    Browse the repository at this point in the history