diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-02-17 19:22:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-02-17 19:22:36 +0100 |
commit | 0370612e0522191f929e3feb7d4937fff3d421e2 (patch) | |
tree | d991bb0f0039c499229da7b48f8e232b8fceec7b /src/machine/machined-dbus.c | |
parent | c7abe32be167ded048a5bb8a912faf2e745b20cb (diff) |
machined: make "machinectl copy-to" and "machinectl copy-from" server side operations
This way, any bus client can make use of these calls.
Diffstat (limited to 'src/machine/machined-dbus.c')
-rw-r--r-- | src/machine/machined-dbus.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 2b06d994a8..155146b938 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -580,6 +580,27 @@ static int method_bind_mount_machine(sd_bus *bus, sd_bus_message *message, void return bus_machine_method_bind_mount(bus, message, machine, error); } +static int method_copy_machine(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 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_copy(bus, message, machine, error); +} + static int method_remove_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image* i = NULL; const char *name; @@ -683,17 +704,19 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("CreateMachineWithNetwork", "sayssusaia(sv)", "o", method_create_machine_with_network, 0), SD_BUS_METHOD("RegisterMachine", "sayssus", "o", method_register_machine, 0), SD_BUS_METHOD("RegisterMachineWithNetwork", "sayssusai", "o", method_register_machine_with_network, 0), - SD_BUS_METHOD("KillMachine", "ssi", NULL, method_kill_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), SD_BUS_METHOD("TerminateMachine", "s", NULL, method_terminate_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), + SD_BUS_METHOD("KillMachine", "ssi", NULL, method_kill_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), 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, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("BindMountMachine", "sssbb", NULL, method_bind_mount_machine, 0), + SD_BUS_METHOD("CopyFromMachine", "sss", NULL, method_copy_machine, 0), + SD_BUS_METHOD("CopyToMachine", "sss", NULL, method_copy_machine, 0), SD_BUS_METHOD("RemoveImage", "s", NULL, method_remove_image, 0), SD_BUS_METHOD("RenameImage", "ss", NULL, method_rename_image, 0), SD_BUS_METHOD("CloneImage", "ssb", NULL, method_clone_image, 0), SD_BUS_METHOD("MarkImageReadOnly", "sb", NULL, method_mark_image_read_only, 0), - SD_BUS_METHOD("BindMountMachine", "sssbb", NULL, method_bind_mount_machine, 0), SD_BUS_SIGNAL("MachineNew", "so", 0), SD_BUS_SIGNAL("MachineRemoved", "so", 0), SD_BUS_VTABLE_END |