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

feat: add support for systemd listener activation sockets #205

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

networkException
Copy link
Contributor

To support starting a network service on demand and to support a "least privilege-approach" with regards to the permission a network service process needs to have, systemd supports opening a network socket on behalf of the service and passing it as an open file descriptor.

The service gets notified about open file descriptors for this purpose as well as metadata such as named listeners via environment variables.

This pull request adds support for prefixing the listen address passed with --address with "sd-listen-fd:" to access these file descriptors, taking either a listener name passed using the LISTEN_FDNAMES environment variable or LISTEN_FD_$n for unnamed file descriptiors where n is the id of the descriptor starting at 3 (LISTEN_FD_3).

See sd_listen_fds(3)

To support starting a network service on demand and to
support a "least privilege-approach" with regards to the
permission a network service process needs to have, systemd
supports opening a network socket on behalf of the service
and passing it as an open file descriptor.

The service gets notified about open file descriptors for
this purpose as well as metadata such as named listeners
via environment variables.

This patch adds support for prefixing the listen address
passed with --address with "sd-listen-fd:" to access these
file descriptors, taking either a listener name passed using
the `LISTEN_FDNAMES` environment variable or `LISTEN_FD_$n`
for unnamed file descriptiors where `n` is the id of the
descriptor starting at 3 (LISTEN_FD_3).

See sd_listen_fds(3)
Copy link
Owner

@hacdias hacdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks for this addition!

@hacdias hacdias merged commit 79bc17a into hacdias:main Dec 11, 2024
3 checks passed
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.

2 participants