diff options
author | Anita Zhang <the.anitazha@gmail.com> | 2020-09-09 08:46:27 +0200 |
---|---|---|
committer | Anita Zhang <the.anitazha@gmail.com> | 2020-10-08 02:12:24 +0200 |
commit | 5c616ecfcde86105e72c11ad0916e4f3e157a382 (patch) | |
tree | ff71270f17765ad400f93c8b9eb60cf7357fdf4a /src/oom/oomd-manager-bus.c | |
parent | core: systemd-oomd pid1 integration (diff) | |
download | systemd-5c616ecfcde86105e72c11ad0916e4f3e157a382.tar.xz systemd-5c616ecfcde86105e72c11ad0916e4f3e157a382.zip |
systemd-oomd: dbus hook ups and oomctl CLI
Diffstat (limited to 'src/oom/oomd-manager-bus.c')
-rw-r--r-- | src/oom/oomd-manager-bus.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/oom/oomd-manager-bus.c b/src/oom/oomd-manager-bus.c new file mode 100644 index 0000000000..67c5fbf92f --- /dev/null +++ b/src/oom/oomd-manager-bus.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include <linux/capability.h> + +#include "bus-common-errors.h" +#include "bus-polkit.h" +#include "fd-util.h" +#include "oomd-manager-bus.h" +#include "oomd-manager.h" +#include "user-util.h" + +static int bus_method_dump_by_fd(sd_bus_message *message, void *userdata, sd_bus_error *error) { + _cleanup_free_ char *dump = NULL; + _cleanup_close_ int fd = -1; + Manager *m = userdata; + int r; + + assert(message); + assert(m); + + r = manager_get_dump_string(m, &dump); + if (r < 0) + return r; + + fd = acquire_data_fd(dump, strlen(dump), 0); + if (fd < 0) + return fd; + + return sd_bus_reply_method_return(message, "h", fd); +} + +const sd_bus_vtable manager_vtable[] = { + SD_BUS_VTABLE_START(0), + SD_BUS_METHOD("DumpByFileDescriptor", NULL, "h", bus_method_dump_by_fd, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_VTABLE_END +}; |