summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-bus/bus-message.c76
-rw-r--r--src/libsystemd-bus/bus-message.h4
-rw-r--r--src/systemd/sd-bus.h3
3 files changed, 83 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index b78d34bf7a..8134d77f36 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -26,6 +26,7 @@
#include "utf8.h"
#include "strv.h"
#include "time-util.h"
+#include "cgroup-util.h"
#include "sd-bus.h"
#include "bus-message.h"
@@ -76,6 +77,10 @@ static void message_free(sd_bus_message *m) {
free(m->root_container.signature);
free(m->peeked_signature);
+
+ free(m->unit);
+ free(m->user_unit);
+ free(m->session);
free(m);
}
@@ -796,6 +801,66 @@ int sd_bus_message_get_cgroup(sd_bus_message *m, const char **ret) {
return 0;
}
+int sd_bus_message_get_unit(sd_bus_message *m, const char **ret) {
+ int r;
+
+ if (!m)
+ return -EINVAL;
+ if (!ret)
+ return -EINVAL;
+ if (!m->cgroup)
+ return -ESRCH;
+
+ if (!m->unit) {
+ r = cg_path_get_unit(m->cgroup, &m->unit);
+ if (r < 0)
+ return r;
+ }
+
+ *ret = m->unit;
+ return 0;
+}
+
+int sd_bus_message_get_user_unit(sd_bus_message *m, const char **ret) {
+ int r;
+
+ if (!m)
+ return -EINVAL;
+ if (!ret)
+ return -EINVAL;
+ if (!m->cgroup)
+ return -ESRCH;
+
+ if (!m->user_unit) {
+ r = cg_path_get_user_unit(m->cgroup, &m->user_unit);
+ if (r < 0)
+ return r;
+ }
+
+ *ret = m->user_unit;
+ return 0;
+}
+
+int sd_bus_message_get_session(sd_bus_message *m, const char **ret) {
+ int r;
+
+ if (!m)
+ return -EINVAL;
+ if (!ret)
+ return -EINVAL;
+ if (!m->cgroup)
+ return -ESRCH;
+
+ if (!m->session) {
+ r = cg_path_get_session(m->cgroup, &m->session);
+ if (r < 0)
+ return r;
+ }
+
+ *ret = m->session;
+ return 0;
+}
+
int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline) {
size_t n, i;
const char *p;
@@ -3004,6 +3069,7 @@ int sd_bus_message_set_destination(sd_bus_message *m, const char *destination) {
}
int bus_message_dump(sd_bus_message *m) {
+ const char *u = NULL, *uu = NULL, *s = NULL;
char **cmdline = NULL;
unsigned level = 1;
int r;
@@ -3074,6 +3140,16 @@ int bus_message_dump(sd_bus_message *m) {
if (m->cgroup)
printf("\tcgroup=[%s]\n", m->cgroup);
+ sd_bus_message_get_unit(m, &u);
+ if (u)
+ printf("\tunit=[%s]\n", u);
+ sd_bus_message_get_user_unit(m, &uu);
+ if (uu)
+ printf("\tuser_unit=[%s]\n", uu);
+ sd_bus_message_get_session(m, &s);
+ if (s)
+ printf("\tsession=[%s]\n", s);
+
if (sd_bus_message_get_cmdline(m, &cmdline) >= 0) {
char **c;
diff --git a/src/libsystemd-bus/bus-message.h b/src/libsystemd-bus/bus-message.h
index 2cd1ef257d..9440bbebb4 100644
--- a/src/libsystemd-bus/bus-message.h
+++ b/src/libsystemd-bus/bus-message.h
@@ -115,6 +115,10 @@ struct sd_bus_message {
const char *cmdline;
size_t cmdline_length;
char **cmdline_array;
+
+ char *session;
+ char *unit;
+ char *user_unit;
};
#define BUS_MESSAGE_NEED_BSWAP(m) ((m)->header->endian != SD_BUS_NATIVE_ENDIAN)
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 5d082f26b3..1352acc908 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -136,6 +136,9 @@ int sd_bus_message_get_tid_comm(sd_bus_message *m, const char **r);
int sd_bus_message_get_exe(sd_bus_message *m, const char **r);
int sd_bus_message_get_cgroup(sd_bus_message *m, const char **r);
int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline);
+int sd_bus_message_get_unit(sd_bus_message *m, const char **unit);
+int sd_bus_message_get_user_unit(sd_bus_message *m, const char **unit);
+int sd_bus_message_get_session(sd_bus_message *m, const char **session);
int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);