Skip to content

varlink: add ability to talk to remote Varlink service binary via ssh #32560

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

Merged
merged 7 commits into from
Jun 27, 2024

Conversation

poettering
Copy link
Member

@poettering poettering commented Apr 29, 2024

So far our varlink client could connect to remote AF_UNIX sockets via SSH. This adds a 2nd SSH-based transport: invoke a binary remotely via ssh, and talk to it via stdin/stdout.

This is v257 material, don't bother with this for v256

@poettering poettering added this to the v257 milestone Apr 29, 2024
@github-actions github-actions bot added documentation util-lib please-review PR is ready for (re-)review by a maintainer labels Apr 29, 2024

This comment was marked as outdated.

@poettering poettering force-pushed the varlink-double-fd branch from c1624ae to e727cca Compare May 22, 2024 19:44
@poettering poettering force-pushed the varlink-double-fd branch 6 times, most recently from 9efde3e to 2eff9c9 Compare June 18, 2024 09:34
@poettering poettering force-pushed the varlink-double-fd branch 3 times, most recently from 42c36a6 to e8b3749 Compare June 25, 2024 08:51
Copy link
Contributor

@DaanDeMeyer DaanDeMeyer left a comment

Choose a reason for hiding this comment

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

This could really do with some kind of integration test.

A man page example would also help a lot in understanding how to use this.

Also, the title feels wrong in a way. This allows you to invoke a command on a remote host and communicate with it using varlink. On its own it doesn't really allow you to talk to a running service on a remote host using varlink.

Shouldn't this also add systemd-varlink-bridge like we have systemd-stdio-bridge for D-Bus which connects to a varlink service running on a remote host?

@poettering
Copy link
Member Author

poettering commented Jun 27, 2024

Shouldn't this also add systemd-varlink-bridge like we have systemd-stdio-bridge for D-Bus which connects to a varlink service running on a remote host?

There's no need, we already support that. See varlinkctl(1) man page. You can already access remote services that are bound to some AF_UNIX socket. This requires the new support for connecting to a remote AF_UNIX socket via "ssh -W". Only available since OpenSSH 9.4, which is really recent though.

systemd-stdio-bridge is a concept from a time where "ssh -W" didn't exist. I mean, we can't kill it for now, as older ssh versions are still popular. And maybe it even makes sense to keep after that, since it actually patches the negotation protocol of D-Bus to disable fd passing, since that doesn't work via ssh. (This concept like this doesn't exist in varlink anyway, hence no need for anything like this in a varlink world).

To summarize, with this PR we support two different things:

  1. varlinkctl ssh-unix:hostxyz:/run/some/socket
  2. varlinkctl ssh-exec:hostabc:/usr/bin/some/binary

And neither requires any particular tool on the other side to invoke, we just need the target socket or binary to talk to.

When invoking another process via a pair of pipes it makes sense to
allow reading from one fd, and writing from another. Teach our varlink
code to do so optionally.

(sd-bus supports something similar, fill the gap).

This is preparation for a later commit that uses this to talk to remote
SSH invocations via pipes.
…ents

This makes use of the functionality added in the previous commit to
implement the client-side functionality for talking to servers via a
pair of fds.
… servers

This adds the server-side for varlink connections over two distinct fds.
This adds varlink_server_add_connection_stdio() as wrapper around
varlink_server_add_connection_pair(), that steals stdin/stdout fds and
turns them into a varlink connection. To be safe it replaces
stdin/stdout with /dev/null fds.
@poettering poettering changed the title varlink: add ability to talk to remote ssh Varlink service varlink: add ability to talk to remote Varlink service binary via ssh Jun 27, 2024
@github-actions github-actions bot added the tests label Jun 27, 2024
@poettering
Copy link
Member Author

rebased, addressed the issues, added examples to the varlinkctl man page and a CI test. ptal.

@DaanDeMeyer DaanDeMeyer added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed please-review PR is ready for (re-)review by a maintainer labels Jun 27, 2024
@poettering poettering merged commit 24f0d61 into systemd:main Jun 27, 2024
39 of 48 checks passed
@github-actions github-actions bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants