This works today:
exec 3> /my/file
export LISTEN_FDS=3
export LISTEN_PID=$$
exec systemd-nspawn ... -- my_program --fd 3
This is great for exposing files or sockets in the resulting container.
If I have a container running systemd inside, I can similarly try to start a program inside it via systemd-run. However, in this case, LISTEN_FDS-style file descriptor forwarding is not supported, so in this example my program will fail with EBADF.
exec 3> /my/file
export LISTEN_FDS=3
export LISTEN_PID=$$
exec systemd-run --pipe --wait ... -- my_program --fd 3
As far as I can tell, implementing this should be possible. The least bad idea I found in 30 minutes of reading the code was to add a new handler to dbus-service.c that calls service_add_fd_store.
Would this be a sensible API? Are there other good ways to run a transient unit with arbitrary FDs inside my container?
If the API is OK, what about the implementation, is it enough to sequentially add my FDs to the FD store of the transient unit?
This works today:
This is great for exposing files or sockets in the resulting container.
If I have a container running
systemdinside, I can similarly try to start a program inside it viasystemd-run. However, in this case,LISTEN_FDS-style file descriptor forwarding is not supported, so in this example my program will fail withEBADF.As far as I can tell, implementing this should be possible. The least bad idea I found in 30 minutes of reading the code was to add a new handler to
dbus-service.cthat callsservice_add_fd_store.Would this be a sensible API? Are there other good ways to run a transient unit with arbitrary FDs inside my container?
If the API is OK, what about the implementation, is it enough to sequentially add my FDs to the FD store of the transient unit?