[systemd-commits] 2 commits - src/libsystemd-bus src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Apr 22 19:39:10 PDT 2013
src/libsystemd-bus/bus-kernel.c | 2 +
src/libsystemd-bus/bus-message.c | 43 +++++++++++++++++++++++++++++++++++++++
src/libsystemd-bus/bus-message.h | 2 +
src/systemd/sd-bus.h | 3 ++
4 files changed, 50 insertions(+)
New commits:
commit 120f919e708b49d58e4302c91d32d12917068ba3
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Apr 22 23:38:38 2013 -0300
bus: parse audit metadata from kdbus messages
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index 115297d..42b1696 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -473,6 +473,8 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
m->cmdline_length = l;
} else if (d->type == KDBUS_MSG_SRC_CGROUP)
m->cgroup = d->str;
+ else if (d->type == KDBUS_MSG_SRC_AUDIT)
+ m->audit = &d->audit;
else
log_debug("Got unknown field from kernel %llu", d->type);
}
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index f0de7a3..6b4a0f3 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -904,6 +904,30 @@ int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline) {
return 0;
}
+int sd_bus_message_get_audit_sessionid(sd_bus_message *m, uint32_t *sessionid) {
+ if (!m)
+ return -EINVAL;
+ if (!sessionid)
+ return -EINVAL;
+ if (!m->audit)
+ return -ESRCH;
+
+ *sessionid = m->audit->sessionid;
+ return 0;
+}
+
+int sd_bus_message_get_audit_loginuid(sd_bus_message *m, uid_t *uid) {
+ if (!m)
+ return -EINVAL;
+ if (!uid)
+ return -EINVAL;
+ if (!m->audit)
+ return -ESRCH;
+
+ *uid = m->audit->loginuid;
+ return 0;
+}
+
int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member) {
if (!m)
return -EINVAL;
@@ -3084,7 +3108,8 @@ int bus_message_dump(sd_bus_message *m) {
char **cmdline = NULL;
unsigned level = 1;
int r;
- uid_t owner;
+ uid_t owner, audit_loginuid;
+ uint32_t audit_sessionid;
assert(m);
@@ -3163,6 +3188,10 @@ int bus_message_dump(sd_bus_message *m) {
printf("\tsession=[%s]\n", s);
if (sd_bus_message_get_owner_uid(m, &owner) >= 0)
printf("\towner_uid=%lu\n", (unsigned long) owner);
+ if (sd_bus_message_get_audit_loginuid(m, &audit_loginuid) >= 0)
+ printf("\taudit_loginuid=%lu\n", (unsigned long) audit_loginuid);
+ if (sd_bus_message_get_audit_sessionid(m, &audit_sessionid) >= 0)
+ printf("\taudit_sessionid=%lu\n", (unsigned long) audit_sessionid);
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 9440bbe..66b4348 100644
--- a/src/libsystemd-bus/bus-message.h
+++ b/src/libsystemd-bus/bus-message.h
@@ -119,6 +119,8 @@ struct sd_bus_message {
char *session;
char *unit;
char *user_unit;
+
+ struct kdbus_audit *audit;
};
#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 92ae31b..67923e7 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -140,6 +140,8 @@ 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_get_owner_uid(sd_bus_message *m, uid_t *uid);
+int sd_bus_message_get_audit_sessionid(sd_bus_message *m, uint32_t *sessionid);
+int sd_bus_message_get_audit_loginuid(sd_bus_message *m, uid_t *loginuid);
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);
commit bc7f3beb3090716d12406e2bfdba1df0e9d4b333
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Apr 22 23:27:38 2013 -0300
bus: parse owner uid from cgroup path, too
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 8134d77..f0de7a3 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -861,6 +861,17 @@ int sd_bus_message_get_session(sd_bus_message *m, const char **ret) {
return 0;
}
+int sd_bus_message_get_owner_uid(sd_bus_message *m, uid_t *uid) {
+ if (!m)
+ return -EINVAL;
+ if (!uid)
+ return -EINVAL;
+ if (!m->cgroup)
+ return -ESRCH;
+
+ return cg_path_get_owner_uid(m->cgroup, uid);
+}
+
int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline) {
size_t n, i;
const char *p;
@@ -3073,6 +3084,7 @@ int bus_message_dump(sd_bus_message *m) {
char **cmdline = NULL;
unsigned level = 1;
int r;
+ uid_t owner;
assert(m);
@@ -3149,6 +3161,8 @@ int bus_message_dump(sd_bus_message *m) {
sd_bus_message_get_session(m, &s);
if (s)
printf("\tsession=[%s]\n", s);
+ if (sd_bus_message_get_owner_uid(m, &owner) >= 0)
+ printf("\towner_uid=%lu\n", (unsigned long) owner);
if (sd_bus_message_get_cmdline(m, &cmdline) >= 0) {
char **c;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 1352acc..92ae31b 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -139,6 +139,7 @@ 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_get_owner_uid(sd_bus_message *m, uid_t *uid);
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);
More information about the systemd-commits
mailing list