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 the newline-fd readiness protocol #484

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

capezotte
Copy link

This is a partial equivalent to sd-notify that's already implemented in a few non-systemd supervisors — namely, s6, which originally proposed this protocol, and dinit. With creative fd wrangling, a shell script is able to recognize it.

Daemons write a line to a file descriptor of their choice, then close that file descriptor, when they're ready to serve. This is a generic mechanism that some daemons already implement.

Even if there's no interest in merging this (as non-systemd Linux is such a rare sight that the systemd notification protocol is under port-linux.[ch] in this repository), I'd at least like to know if this is a sound implementation of it.

@djmdjm
Copy link
Contributor

djmdjm commented Apr 30, 2024

How widely used are these init systems? This feature might be a bit too niche...

One problem you're likely to run into is the unconditional closefrom() in sshd.c:main() that will significantly constrain the possible fd numbers you are able to pass in. I'd suggest altering your patch to check whether the supplied fd number is going to get clobbered and erroring out if it is.

I'd also suggest moving the actual messaging to platform_post_listen(), which probably means you'll need some way of plumbing the fd number though to that file.

@capezotte
Copy link
Author

Would stdout be a suitable outlet for the newline? It appears unused when sshd is a daemon.

(Actually, if any option writes something to an fd other than stderr after listening, it'd be hacky but suitable for these supervisors, and something like this patch wouldn't be needed).


How widely used are these init systems? This feature might be a bit too niche...

Admittedly, it's niche even for "non-systemd Linux" standards — most are using OpenRC or sysv, which work with sshd's default behavior of forking == ready. s6 is finding some use as a container init, but that's a context where sshd doesn't make much sense.

Even if this does not get merged, thanks for the feedback!

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