summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-30 13:52:40 +0100
committerLennart Poettering <lennart@poettering.net>2013-10-30 15:35:49 +0100
commit0f8bd8debb0ff7f5bff7738841931f6c41e40bc1 (patch)
tree50ab6e129131fd301e1665b15e8896ea80ff2e74 /src/libsystemd-bus/sd-bus.c
parent2004d23a0fcaa6e74631057a2ff75594a038d86e (diff)
bus: move ssh support into public API of libsystem-bus
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r--src/libsystemd-bus/sd-bus.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 55d964ed8f..383b035b7e 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1033,6 +1033,42 @@ fail:
return r;
}
+int sd_bus_open_system_remote(const char *host, sd_bus **ret) {
+ _cleanup_free_ char *e = NULL;
+ char *p = NULL;
+ sd_bus *bus;
+ int r;
+
+ assert_return(host, -EINVAL);
+ assert_return(ret, -EINVAL);
+
+ e = bus_address_escape(host);
+ if (!e)
+ return -ENOMEM;
+
+ p = strjoin("unixexec:path=ssh,argv1=-xT,argv2=", e, ",argv3=systemd-stdio-bridge", NULL);
+ if (!p)
+ return -ENOMEM;
+
+ r = sd_bus_new(&bus);
+ if (r < 0) {
+ free(p);
+ return r;
+ }
+
+ bus->address = p;
+ bus->bus_client = true;
+
+ r = sd_bus_start(bus);
+ if (r < 0) {
+ bus_free(bus);
+ return r;
+ }
+
+ *ret = bus;
+ return 0;
+}
+
void sd_bus_close(sd_bus *bus) {
if (!bus)
return;