summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Nemo <camerontnorman@gmail.com>2018-10-23 18:02:25 -0700
committerSven Eden <sven.eden@prydeworx.com>2018-11-08 08:02:57 +0100
commit18924a1e18b3c6159bf49a364e8bc339bb5175ae (patch)
treef9a478ddc6800f5731ae0ef749a77dc8a135ed39
parent3ab9309e18658e22c1322eef168871d26cd49fb3 (diff)
sd-bus: enable support for user bus instances
Bug: #87 Closes: #87 Signed-off-by: Cameron Nemo <camerontnorman@gmail.com> Signed-off-by: Sven Eden <sven.eden@prydeworx.com>
-rw-r--r--src/busctl/busctl.c4
-rw-r--r--src/libelogind/sd-bus/bus-dump.c4
-rw-r--r--src/libelogind/sd-bus/bus-internal.h4
-rw-r--r--src/libelogind/sd-bus/bus-kernel.c2
-rw-r--r--src/libelogind/sd-bus/sd-bus.c18
-rw-r--r--src/shared/bus-util.c4
6 files changed, 4 insertions, 32 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index e2ae474..efb68c8 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -92,17 +92,13 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
switch (arg_transport) {
case BUS_TRANSPORT_LOCAL:
-#if 0 /// elogind does not support user buses
if (arg_user) {
bus->is_user = true;
r = bus_set_address_user(bus);
} else {
bus->is_system = true;
-#endif // 0
r = bus_set_address_system(bus);
-#if 0 /// elogind does not support user buses
}
-#endif // 0
break;
case BUS_TRANSPORT_REMOTE:
diff --git a/src/libelogind/sd-bus/bus-dump.c b/src/libelogind/sd-bus/bus-dump.c
index 635403b..bd018db 100644
--- a/src/libelogind/sd-bus/bus-dump.c
+++ b/src/libelogind/sd-bus/bus-dump.c
@@ -453,7 +453,11 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
if (z != -ENODATA)
fprintf(f, "%sSession=%s%s%s", prefix, color, strna(s), suffix);
+#if 0 /// elogind does not support systemd units, and q is only used with them until now
if (terse && ((c->mask & SD_BUS_CREDS_CGROUP) || r != -ENODATA || q != -ENODATA || v != -ENODATA || w != -ENODATA || z != -ENODATA))
+#else
+ if (terse && ((c->mask & SD_BUS_CREDS_CGROUP) || r != -ENODATA || v != -ENODATA || w != -ENODATA || z != -ENODATA))
+#endif // 0
fputs("\n", f);
r = sd_bus_creds_get_audit_login_uid(c, &audit_loginuid);
diff --git a/src/libelogind/sd-bus/bus-internal.h b/src/libelogind/sd-bus/bus-internal.h
index 904d610..df33ca2 100644
--- a/src/libelogind/sd-bus/bus-internal.h
+++ b/src/libelogind/sd-bus/bus-internal.h
@@ -396,14 +396,10 @@ void bus_close_io_fds(sd_bus *b);
_cleanup_(sd_bus_unrefp) _unused_ sd_bus *_dont_destroy_##bus = sd_bus_ref(bus)
int bus_set_address_system(sd_bus *bus);
-#if 0 /// UNNEEDED by elogind
int bus_set_address_user(sd_bus *bus);
-#endif // 0
int bus_set_address_system_remote(sd_bus *b, const char *host);
int bus_set_address_system_machine(sd_bus *b, const char *machine);
-#if 0 /// UNNEEDED by elogind
-#endif // 0
int bus_get_root_path(sd_bus *bus);
int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
diff --git a/src/libelogind/sd-bus/bus-kernel.c b/src/libelogind/sd-bus/bus-kernel.c
index e0f521b..1f61bd3 100644
--- a/src/libelogind/sd-bus/bus-kernel.c
+++ b/src/libelogind/sd-bus/bus-kernel.c
@@ -50,5 +50,3 @@ void bus_flush_memfd(sd_bus *b) {
for (i = 0; i < b->n_memfd_cache; i++)
close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped);
}
-#if 0 /// UNNEEDED by elogind
-#endif // 0
diff --git a/src/libelogind/sd-bus/sd-bus.c b/src/libelogind/sd-bus/sd-bus.c
index 2a49040..0b325e4 100644
--- a/src/libelogind/sd-bus/sd-bus.c
+++ b/src/libelogind/sd-bus/sd-bus.c
@@ -1203,19 +1203,15 @@ _public_ int sd_bus_open_with_description(sd_bus **ret, const char *description)
if (e) {
if (streq(e, "system"))
return sd_bus_open_system_with_description(ret, description);
-#if 0 /// elogind does not support systemd user instances
else if (STR_IN_SET(e, "session", "user"))
-#endif // 0
return sd_bus_open_user_with_description(ret, description);
}
e = secure_getenv("DBUS_STARTER_ADDRESS");
if (!e) {
-#if 0 /// elogind does not support systemd user instances
if (cg_pid_get_owner_uid(0, NULL) >= 0)
return sd_bus_open_user_with_description(ret, description);
else
-#endif // 0
return sd_bus_open_system_with_description(ret, description);
}
@@ -1299,7 +1295,6 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
return sd_bus_open_system_with_description(ret, NULL);
}
-#if 0 /// elogind can not open/use a user bus
int bus_set_address_user(sd_bus *b) {
const char *e;
_cleanup_free_ char *ee = NULL, *s = NULL;
@@ -1325,10 +1320,8 @@ int bus_set_address_user(sd_bus *b) {
return 0;
}
-#endif // 0
_public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *description) {
-#if 0 /// elogind does not support user buses
_cleanup_(bus_freep) sd_bus *b = NULL;
int r;
@@ -1362,9 +1355,6 @@ _public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *descrip
*ret = TAKE_PTR(b);
return 0;
-#else
- return sd_bus_open_system_with_description(ret, description);
-#endif // 0
}
_public_ int sd_bus_open_user(sd_bus **ret) {
@@ -3276,8 +3266,6 @@ finish:
return r;
}
-#if 0 /// UNNEEDED by elogind
-#endif // 0
_public_ int sd_bus_add_match(
sd_bus *bus,
sd_bus_slot **slot,
@@ -3651,11 +3639,7 @@ _public_ int sd_bus_default_system(sd_bus **ret) {
}
_public_ int sd_bus_default_user(sd_bus **ret) {
-#if 0 /// elogind does not support user buses
return bus_default(sd_bus_open_user, &default_user_bus, ret);
-#else
- return sd_bus_default_system(ret);
-#endif // 0
}
_public_ int sd_bus_default(sd_bus **ret) {
@@ -4030,9 +4014,7 @@ static void flush_close(sd_bus *bus) {
_public_ void sd_bus_default_flush_close(void) {
flush_close(default_starter_bus);
-#if 0 /// elogind does not support user buses
flush_close(default_user_bus);
-#endif // 0
flush_close(default_system_bus);
}
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 7c37648..e3fc1bd 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1299,7 +1299,6 @@ int bus_connect_transport(BusTransport transport, const char *host, bool user, s
switch (transport) {
case BUS_TRANSPORT_LOCAL:
-#if 0 /// elogind does not support a user bus
if (user)
r = sd_bus_default_user(&bus);
else {
@@ -1309,11 +1308,8 @@ int bus_connect_transport(BusTransport transport, const char *host, bool user, s
return -EHOSTDOWN;
}
-#endif // 0
r = sd_bus_default_system(&bus);
-#if 0 /// No closing bracket with elogind... Ain't we simple? ;-)
}
-#endif // 0
break;
case BUS_TRANSPORT_REMOTE: