X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fmachine%2Fmachined-dbus.c;h=505bc17e6accc4596573744e36d9c31cdcd6a742;hp=b55266249bf322d2f3a70bcf1d57a3359d9398d7;hb=4e724d9c5ab76c3f8327945317463ef706011082;hpb=2614202b517790d1d11319dce830a9bdcca37f00 diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index b55266249..505bc17e6 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -86,17 +86,25 @@ static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void _cleanup_free_ char *p = NULL; Manager *m = userdata; Machine *machine = NULL; - uint32_t pid; + pid_t pid; int r; assert(bus); assert(message); assert(m); + assert_cc(sizeof(pid_t) == sizeof(uint32_t)); + r = sd_bus_message_read(message, "u", &pid); if (r < 0) return sd_bus_reply_method_errno(bus, message, r, NULL); + if (pid == 0) { + r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), &pid); + if (r < 0) + return sd_bus_reply_method_errno(bus, message, r, NULL); + } + r = manager_get_machine_by_pid(m, pid, &machine); if (r < 0) return sd_bus_reply_method_errno(bus, message, r, NULL);