diff options
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machine.c | 7 | ||||
-rw-r--r-- | src/machine/machined-dbus.c | 5 | ||||
-rw-r--r-- | src/machine/machined.h | 4 | ||||
-rw-r--r-- | src/machine/test-machine-tables.c | 1 |
4 files changed, 10 insertions, 7 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index 196bc4b8f4..6b1fae2769 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -29,6 +29,7 @@ #include "bus-error.h" #include "bus-util.h" #include "escape.h" +#include "extract-word.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" @@ -37,12 +38,12 @@ #include "machine.h" #include "mkdir.h" #include "parse-util.h" +#include "process-util.h" #include "special.h" #include "string-table.h" #include "terminal-util.h" #include "unit-name.h" #include "util.h" -#include "extract-word.h" Machine* machine_new(Manager *manager, MachineClass class, const char *name) { Machine *m; @@ -105,7 +106,7 @@ void machine_free(Machine *m) { m->manager->host_machine = NULL; if (m->leader > 0) - (void) hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); + (void) hashmap_remove_value(m->manager->machine_leaders, PID_TO_PTR(m->leader), m); sd_bus_message_unref(m->create_message); @@ -401,7 +402,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { if (m->started) return 0; - r = hashmap_put(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m); + r = hashmap_put(m->manager->machine_leaders, PID_TO_PTR(m->leader), m); if (r < 0) return r; diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 7827f063c1..961767c4a9 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -199,6 +199,9 @@ static int method_get_machine_by_pid(sd_bus_message *message, void *userdata, sd if (r < 0) return r; + if (pid < 0) + return -EINVAL; + if (pid == 0) { _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; @@ -1505,7 +1508,7 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) { assert(pid >= 1); assert(machine); - mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid)); + mm = hashmap_get(m->machine_leaders, PID_TO_PTR(pid)); if (!mm) { _cleanup_free_ char *unit = NULL; diff --git a/src/machine/machined.h b/src/machine/machined.h index dac7a29ed1..bc5d4abb80 100644 --- a/src/machine/machined.h +++ b/src/machine/machined.h @@ -31,9 +31,9 @@ typedef struct Manager Manager; -#include "machine.h" -#include "machine-dbus.h" #include "image-dbus.h" +#include "machine-dbus.h" +#include "machine.h" struct Manager { sd_event *event; diff --git a/src/machine/test-machine-tables.c b/src/machine/test-machine-tables.c index 4aae426050..f851a4d37d 100644 --- a/src/machine/test-machine-tables.c +++ b/src/machine/test-machine-tables.c @@ -18,7 +18,6 @@ ***/ #include "machine.h" - #include "test-tables.h" int main(int argc, char **argv) { |