[systemd-commits] 2 commits - src/libsystemd src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Jan 22 07:44:51 PST 2014
src/libsystemd/libsystemd.sym | 1 +
src/libsystemd/sd-bus/bus-control.c | 15 ++++++++++++++-
src/libsystemd/sd-bus/bus-creds.c | 13 +++++++++++++
src/libsystemd/sd-bus/bus-creds.h | 2 ++
src/libsystemd/sd-bus/bus-dump.c | 4 +++-
src/libsystemd/sd-bus/bus-kernel.c | 18 +++++++++++++++---
src/systemd/sd-bus.h | 4 +++-
7 files changed, 51 insertions(+), 6 deletions(-)
New commits:
commit 41add995cf7d61e299cb859a7f63117e2b4de312
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 22 16:44:32 2014 +0100
bus: pass timestamp info only to caller if he asked for it
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 95efbbe..f547ebf 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -500,9 +500,13 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
break;
case KDBUS_ITEM_TIMESTAMP:
- m->realtime = d->timestamp.realtime_ns / NSEC_PER_USEC;
- m->monotonic = d->timestamp.monotonic_ns / NSEC_PER_USEC;
- m->seqnum = d->timestamp.seqnum;
+
+ if (bus->attach_flags & KDBUS_ATTACH_TIMESTAMP) {
+ m->realtime = d->timestamp.realtime_ns / NSEC_PER_USEC;
+ m->monotonic = d->timestamp.monotonic_ns / NSEC_PER_USEC;
+ m->seqnum = d->timestamp.seqnum;
+ }
+
break;
case KDBUS_ITEM_PID_COMM:
commit cccb0b2cdbd25e90ae92d2d5b107125cb1ca3433
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 22 16:28:58 2014 +0100
bus: include connection name in credentials structure
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index 0942a6e..0337e4e 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -187,6 +187,7 @@ global:
sd_bus_creds_get_audit_login_uid;
sd_bus_creds_get_unique_name;
sd_bus_creds_get_well_known_names;
+ sd_bus_creds_get_connection_name;
/* Error structures */
sd_bus_error_free;
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index e7e9ba0..5548239 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -379,9 +379,10 @@ static int bus_get_owner_kdbus(
cmd = alloca0(size);
strcpy(cmd->name, name);
}
- cmd->flags = KDBUS_ATTACH_NAMES;
cmd->size = size;
+ kdbus_translate_attach_flags(mask, (uint64_t*) &cmd->flags);
+
r = ioctl(bus->input_fd, KDBUS_CMD_CONN_INFO, cmd);
if (r < 0)
return -errno;
@@ -553,6 +554,18 @@ static int bus_get_owner_kdbus(
c->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES;
}
break;
+
+ case KDBUS_ITEM_CONN_NAME:
+ if ((mask & SD_BUS_CREDS_CONNECTION_NAME)) {
+ c->conn_name = strdup(item->str);
+ if (!c->conn_name) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ c->mask |= SD_BUS_CREDS_CONNECTION_NAME;
+ }
+ break;
}
}
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 52e55fc..85509e8 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -92,6 +92,7 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
free(c->label);
free(c->unique_name);
free(c->cgroup_root);
+ free(c->conn_name);
free(c);
}
} else {
@@ -462,6 +463,18 @@ _public_ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***well_kno
return 0;
}
+_public_ int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **ret) {
+ assert_return(c, -EINVAL);
+ assert_return(ret, -EINVAL);
+
+ if (!(c->mask & SD_BUS_CREDS_CONNECTION_NAME))
+ return -ENODATA;
+
+ assert(c->conn_name);
+ *ret = c->conn_name;
+ return 0;
+}
+
static int has_cap(sd_bus_creds *c, unsigned offset, int capability) {
size_t sz;
diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h
index d8b4aca..df33d34 100644
--- a/src/libsystemd/sd-bus/bus-creds.h
+++ b/src/libsystemd/sd-bus/bus-creds.h
@@ -64,6 +64,8 @@ struct sd_bus_creds {
char **well_known_names;
char *cgroup_root;
+
+ char *conn_name;
};
sd_bus_creds* bus_creds_new(void);
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index d2c0684..f1d00a9 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -342,8 +342,10 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f) {
fprintf(f, " TIDComm=%s", c->tid_comm);
if (c->mask & SD_BUS_CREDS_SELINUX_CONTEXT)
fprintf(f, " Label=%s", c->label);
+ if (c->mask & SD_BUS_CREDS_CONNECTION_NAME)
+ fprintf(f, " ConnectionName=%s", c->conn_name);
- if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT))
+ if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT|SD_BUS_CREDS_CONNECTION_NAME))
fputs("\n", f);
if (sd_bus_creds_get_cmdline(c, &cmdline) >= 0) {
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 833ea55..95efbbe 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -568,6 +568,11 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
goto fail;
break;
+ case KDBUS_ITEM_CONN_NAME:
+ m->creds.conn_name = d->str;
+ m->creds.mask |= SD_BUS_CREDS_CONNECTION_NAME & bus->creds_mask;
+ break;
+
case KDBUS_ITEM_FDS:
case KDBUS_ITEM_SECLABEL:
break;
@@ -1240,6 +1245,9 @@ int kdbus_translate_attach_flags(uint64_t mask, uint64_t *kdbus_mask) {
if (mask & SD_BUS_CREDS_WELL_KNOWN_NAMES)
m |= KDBUS_ATTACH_NAMES;
+ if (mask & SD_BUS_CREDS_CONNECTION_NAME)
+ m |= KDBUS_ATTACH_CONN_NAME;
+
*kdbus_mask = m;
return 0;
}
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index baffd53..9992888 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -72,7 +72,8 @@ enum {
SD_BUS_CREDS_AUDIT_LOGIN_UID = 1ULL << 21,
SD_BUS_CREDS_UNIQUE_NAME = 1ULL << 22,
SD_BUS_CREDS_WELL_KNOWN_NAMES = 1ULL << 23,
- _SD_BUS_CREDS_ALL = (1ULL << 24) -1,
+ SD_BUS_CREDS_CONNECTION_NAME = 1ULL << 24,
+ _SD_BUS_CREDS_ALL = (1ULL << 25) -1,
};
enum {
@@ -309,6 +310,7 @@ int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessionid);
int sd_bus_creds_get_audit_login_uid(sd_bus_creds *c, uid_t *loginuid);
int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **name);
int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***names);
+int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **name);
/* Error structures */
More information about the systemd-commits
mailing list