diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-23 19:12:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-23 19:15:27 +0100 |
commit | 5f8cc96a0301c1177b11dd2e89370ef0b2ef577b (patch) | |
tree | ff5e3aebdfa5aa6ea88882595e5cda5c7b0e4986 /src/machine/machined-dbus.c | |
parent | ee502e0c28a611470a4e10b0c90bade6ff7fa389 (diff) |
machined: add new call OpenMachineLogin() that starts a getty in a container on a pty and returns the pty master fd to the client
This is a one-stop solution for "machinectl login", and should simplify
getting logins in containers.
Diffstat (limited to 'src/machine/machined-dbus.c')
-rw-r--r-- | src/machine/machined-dbus.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 370d04a9a5..5ce091bf29 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -536,6 +536,27 @@ static int method_open_machine_pty(sd_bus *bus, sd_bus_message *message, void *u return bus_machine_method_open_pty(bus, message, machine, error); } +static int method_open_machine_login(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + Machine *machine; + const char *name; + int r; + + assert(bus); + assert(message); + assert(m); + + r = sd_bus_message_read(message, "s", &name); + if (r < 0) + return sd_bus_error_set_errno(error, r); + + machine = hashmap_get(m->machines, name); + if (!machine) + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); + + return bus_machine_method_open_login(bus, message, machine, error); +} + const sd_bus_vtable manager_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_METHOD("GetMachine", "s", "o", method_get_machine, SD_BUS_VTABLE_UNPRIVILEGED), @@ -552,6 +573,7 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("GetMachineAddresses", "s", "a(iay)", method_get_machine_addresses, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetMachineOSRelease", "s", "a{ss}", method_get_machine_os_release, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("OpenMachinePTY", "s", "hs", method_open_machine_pty, 0), + SD_BUS_METHOD("OpenMachineLogin", "s", "hs", method_open_machine_login, 0), SD_BUS_SIGNAL("MachineNew", "so", 0), SD_BUS_SIGNAL("MachineRemoved", "so", 0), SD_BUS_VTABLE_END |