summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/sd_bus_add_node_enumerator.xml2
-rw-r--r--man/sd_bus_add_object.xml2
-rw-r--r--man/sd_bus_add_object_manager.xml2
-rw-r--r--man/sd_bus_attach_event.xml2
-rw-r--r--man/sd_bus_close.xml2
-rw-r--r--man/sd_bus_emit_signal.xml2
-rw-r--r--man/sd_bus_enqueue_for_read.xml2
-rw-r--r--man/sd_bus_get_n_queued_read.xml2
-rw-r--r--man/sd_bus_get_name_creds.xml2
-rw-r--r--man/sd_bus_get_name_machine_id.xml2
-rw-r--r--man/sd_bus_is_open.xml2
-rw-r--r--man/sd_bus_list_names.xml2
-rw-r--r--man/sd_bus_negotiate_fds.xml2
-rw-r--r--man/sd_bus_query_sender_creds.xml2
-rw-r--r--man/sd_bus_set_close_on_exit.xml2
-rw-r--r--man/sd_bus_set_connected_signal.xml2
-rw-r--r--man/sd_bus_set_description.xml2
-rw-r--r--man/sd_bus_set_exit_on_disconnect.xml2
-rw-r--r--man/sd_bus_set_sender.xml2
-rw-r--r--man/sd_bus_set_server.xml2
-rw-r--r--man/sd_bus_set_watch_bind.xml2
-rw-r--r--man/sd_bus_slot_set_floating.xml2
-rw-r--r--src/libsystemd/sd-bus/bus-control.c18
-rw-r--r--src/libsystemd/sd-bus/bus-convenience.c36
-rw-r--r--src/libsystemd/sd-bus/bus-internal.h4
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c24
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c122
-rw-r--r--src/libsystemd/sd-bus/test-bus-cleanup.c27
28 files changed, 148 insertions, 127 deletions
diff --git a/man/sd_bus_add_node_enumerator.xml b/man/sd_bus_add_node_enumerator.xml
index c6beb1dcd1..541fa7b06d 100644
--- a/man/sd_bus_add_node_enumerator.xml
+++ b/man/sd_bus_add_node_enumerator.xml
@@ -111,7 +111,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_add_object.xml b/man/sd_bus_add_object.xml
index 991f3a8064..5a9e67abb0 100644
--- a/man/sd_bus_add_object.xml
+++ b/man/sd_bus_add_object.xml
@@ -649,7 +649,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_add_object_manager.xml b/man/sd_bus_add_object_manager.xml
index df2704ac99..6c66fd3001 100644
--- a/man/sd_bus_add_object_manager.xml
+++ b/man/sd_bus_add_object_manager.xml
@@ -90,7 +90,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_attach_event.xml b/man/sd_bus_attach_event.xml
index bb34d4a7b9..ba3e58c25d 100644
--- a/man/sd_bus_attach_event.xml
+++ b/man/sd_bus_attach_event.xml
@@ -94,7 +94,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_close.xml b/man/sd_bus_close.xml
index 95427bd7f9..dab1d77336 100644
--- a/man/sd_bus_close.xml
+++ b/man/sd_bus_close.xml
@@ -96,7 +96,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para>
</listitem>
</varlistentry>
</variablelist>
diff --git a/man/sd_bus_emit_signal.xml b/man/sd_bus_emit_signal.xml
index 52d08b7a92..ec2a7976fd 100644
--- a/man/sd_bus_emit_signal.xml
+++ b/man/sd_bus_emit_signal.xml
@@ -226,7 +226,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_enqueue_for_read.xml b/man/sd_bus_enqueue_for_read.xml
index 9bdf498195..601edafd6a 100644
--- a/man/sd_bus_enqueue_for_read.xml
+++ b/man/sd_bus_enqueue_for_read.xml
@@ -67,7 +67,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_get_n_queued_read.xml b/man/sd_bus_get_n_queued_read.xml
index c9978d8ba7..3b0f6148f8 100644
--- a/man/sd_bus_get_n_queued_read.xml
+++ b/man/sd_bus_get_n_queued_read.xml
@@ -78,7 +78,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection was created in a different process.</para></listitem>
+ <listitem><para>The bus connection was created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
diff --git a/man/sd_bus_get_name_creds.xml b/man/sd_bus_get_name_creds.xml
index 6f0541d97a..5444eeddb1 100644
--- a/man/sd_bus_get_name_creds.xml
+++ b/man/sd_bus_get_name_creds.xml
@@ -95,7 +95,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_get_name_machine_id.xml b/man/sd_bus_get_name_machine_id.xml
index 8249485f25..cd702e4063 100644
--- a/man/sd_bus_get_name_machine_id.xml
+++ b/man/sd_bus_get_name_machine_id.xml
@@ -72,7 +72,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_is_open.xml b/man/sd_bus_is_open.xml
index 621ed272bb..8f6b3bcba1 100644
--- a/man/sd_bus_is_open.xml
+++ b/man/sd_bus_is_open.xml
@@ -83,7 +83,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_list_names.xml b/man/sd_bus_list_names.xml
index d8f7e60b7d..998c286663 100644
--- a/man/sd_bus_list_names.xml
+++ b/man/sd_bus_list_names.xml
@@ -79,7 +79,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_negotiate_fds.xml b/man/sd_bus_negotiate_fds.xml
index a4893b62e7..22b6817de3 100644
--- a/man/sd_bus_negotiate_fds.xml
+++ b/man/sd_bus_negotiate_fds.xml
@@ -137,7 +137,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_query_sender_creds.xml b/man/sd_bus_query_sender_creds.xml
index 47cc336706..b8fc7b3991 100644
--- a/man/sd_bus_query_sender_creds.xml
+++ b/man/sd_bus_query_sender_creds.xml
@@ -103,7 +103,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus of <parameter>m</parameter> was created in a different process.
+ <listitem><para>The bus of <parameter>m</parameter> was created in a different process, library or module instance.
</para></listitem>
</varlistentry>
diff --git a/man/sd_bus_set_close_on_exit.xml b/man/sd_bus_set_close_on_exit.xml
index cf3bbae0b5..5ee34a934a 100644
--- a/man/sd_bus_set_close_on_exit.xml
+++ b/man/sd_bus_set_close_on_exit.xml
@@ -84,7 +84,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection was created in a different process.</para>
+ <listitem><para>The bus connection was created in a different process, library or module instance.</para>
</listitem>
</varlistentry>
</variablelist>
diff --git a/man/sd_bus_set_connected_signal.xml b/man/sd_bus_set_connected_signal.xml
index b2dfcf0cf9..09dcb5978a 100644
--- a/man/sd_bus_set_connected_signal.xml
+++ b/man/sd_bus_set_connected_signal.xml
@@ -86,7 +86,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_set_description.xml b/man/sd_bus_set_description.xml
index 0c38c16128..783a0b7922 100644
--- a/man/sd_bus_set_description.xml
+++ b/man/sd_bus_set_description.xml
@@ -202,7 +202,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus was created in a different process.</para></listitem>
+ <listitem><para>The bus was created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_set_exit_on_disconnect.xml b/man/sd_bus_set_exit_on_disconnect.xml
index a694aef4f2..aee5adffb3 100644
--- a/man/sd_bus_set_exit_on_disconnect.xml
+++ b/man/sd_bus_set_exit_on_disconnect.xml
@@ -92,7 +92,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection was created in a different process.</para></listitem>
+ <listitem><para>The bus connection was created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_set_sender.xml b/man/sd_bus_set_sender.xml
index c6e07acc97..2aedbfc01a 100644
--- a/man/sd_bus_set_sender.xml
+++ b/man/sd_bus_set_sender.xml
@@ -75,7 +75,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_set_server.xml b/man/sd_bus_set_server.xml
index e2cd74da90..7c4b087628 100644
--- a/man/sd_bus_set_server.xml
+++ b/man/sd_bus_set_server.xml
@@ -147,7 +147,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/man/sd_bus_set_watch_bind.xml b/man/sd_bus_set_watch_bind.xml
index 20f6f53a2c..123cef48a6 100644
--- a/man/sd_bus_set_watch_bind.xml
+++ b/man/sd_bus_set_watch_bind.xml
@@ -92,7 +92,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
diff --git a/man/sd_bus_slot_set_floating.xml b/man/sd_bus_slot_set_floating.xml
index dd3a9500cf..3309147847 100644
--- a/man/sd_bus_slot_set_floating.xml
+++ b/man/sd_bus_slot_set_floating.xml
@@ -88,7 +88,7 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
- <listitem><para>The bus connection has been created in a different process.</para></listitem>
+ <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 83d68562dc..864acd73ac 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -26,7 +26,7 @@ _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(unique, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!bus->bus_client)
return -EINVAL;
@@ -89,7 +89,7 @@ _public_ int sd_bus_request_name(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(name, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
r = validate_request_name_parameters(bus, name, flags, &param);
if (r < 0)
@@ -193,7 +193,7 @@ _public_ int sd_bus_request_name_async(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(name, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
r = validate_request_name_parameters(bus, name, flags, &param);
if (r < 0)
@@ -247,7 +247,7 @@ _public_ int sd_bus_release_name(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(name, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
r = validate_release_name_parameters(bus, name);
if (r < 0)
@@ -340,7 +340,7 @@ _public_ int sd_bus_release_name_async(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(name, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
r = validate_release_name_parameters(bus, name);
if (r < 0)
@@ -367,7 +367,7 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatabl
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(acquired || activatable, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!bus->bus_client)
return -EINVAL;
@@ -438,7 +438,7 @@ _public_ int sd_bus_get_name_creds(
assert_return(name, -EINVAL);
assert_return((mask & ~SD_BUS_CREDS_AUGMENT) <= _SD_BUS_CREDS_ALL, -EOPNOTSUPP);
assert_return(mask == 0 || creds, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(service_name_is_valid(name), -EINVAL);
if (!bus->bus_client)
@@ -732,7 +732,7 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return((mask & ~SD_BUS_CREDS_AUGMENT) <= _SD_BUS_CREDS_ALL, -EOPNOTSUPP);
assert_return(ret, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -903,7 +903,7 @@ _public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(name, -EINVAL);
assert_return(machine, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(service_name_is_valid(name), -EINVAL);
if (!bus->bus_client)
diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c
index 6974e210a2..81892c3254 100644
--- a/src/libsystemd/sd-bus/bus-convenience.c
+++ b/src/libsystemd/sd-bus/bus-convenience.c
@@ -12,7 +12,7 @@
_public_ int sd_bus_message_send(sd_bus_message *reply) {
assert_return(reply, -EINVAL);
assert_return(reply->bus, -EINVAL);
- assert_return(!bus_pid_changed(reply->bus), -ECHILD);
+ assert_return(!bus_origin_changed(reply->bus), -ECHILD);
return sd_bus_send(reply->bus, reply, NULL);
}
@@ -30,7 +30,7 @@ _public_ int sd_bus_emit_signal_tov(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -109,7 +109,7 @@ _public_ int sd_bus_call_method_asyncv(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -163,7 +163,7 @@ _public_ int sd_bus_call_methodv(
bus_assert_return(bus, -EINVAL, error);
bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -217,7 +217,7 @@ _public_ int sd_bus_reply_method_returnv(
assert_return(call->sealed, -EPERM);
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -264,7 +264,7 @@ _public_ int sd_bus_reply_method_error(
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(sd_bus_error_is_set(e), -EINVAL);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -291,7 +291,7 @@ _public_ int sd_bus_reply_method_errorfv(
assert_return(call->sealed, -EPERM);
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -331,7 +331,7 @@ _public_ int sd_bus_reply_method_errno(
assert_return(call->sealed, -EPERM);
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -359,7 +359,7 @@ _public_ int sd_bus_reply_method_errnofv(
assert_return(call->sealed, -EPERM);
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -407,7 +407,7 @@ _public_ int sd_bus_get_property(
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(reply, -EINVAL, error);
bus_assert_return(signature_is_single(type, false), -EINVAL, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -452,7 +452,7 @@ _public_ int sd_bus_get_property_trivial(
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(bus_type_is_trivial(type), -EINVAL, error);
bus_assert_return(ptr, -EINVAL, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -496,7 +496,7 @@ _public_ int sd_bus_get_property_string(
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(ret, -EINVAL, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -545,7 +545,7 @@ _public_ int sd_bus_get_property_strv(
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(ret, -EINVAL, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -587,7 +587,7 @@ _public_ int sd_bus_set_propertyv(
bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
bus_assert_return(member_name_is_valid(member), -EINVAL, error);
bus_assert_return(signature_is_single(type, false), -EINVAL, error);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -646,7 +646,7 @@ _public_ int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_b
assert_return(call, -EINVAL);
assert_return(call->sealed, -EPERM);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
assert_return(ret, -EINVAL);
if (!BUS_IS_OPEN(call->bus->state))
@@ -694,7 +694,7 @@ _public_ int sd_bus_query_sender_privilege(sd_bus_message *call, int capability)
assert_return(call, -EINVAL);
assert_return(call->sealed, -EPERM);
assert_return(call->bus, -EINVAL);
- assert_return(!bus_pid_changed(call->bus), -ECHILD);
+ assert_return(!bus_origin_changed(call->bus), -ECHILD);
if (!BUS_IS_OPEN(call->bus->state))
return -ENOTCONN;
@@ -786,7 +786,7 @@ _public_ int sd_bus_match_signal(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(!sender || service_name_is_valid(sender), -EINVAL);
assert_return(!path || object_path_is_valid(path), -EINVAL);
assert_return(!interface || interface_name_is_valid(interface), -EINVAL);
@@ -812,7 +812,7 @@ _public_ int sd_bus_match_signal_async(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(!sender || service_name_is_valid(sender), -EINVAL);
assert_return(!path || object_path_is_valid(path), -EINVAL);
assert_return(!interface || interface_name_is_valid(interface), -EINVAL);
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index a9acdc7d0a..aaef6ac378 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -286,7 +286,7 @@ struct sd_bus {
struct memfd_cache memfd_cache[MEMFD_CACHE_MAX];
unsigned n_memfd_cache;
- pid_t original_pid;
+ uint64_t origin_id;
pid_t busexec_pid;
unsigned iteration_counter;
@@ -377,7 +377,7 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m);
int bus_rqueue_make_room(sd_bus *bus);
-bool bus_pid_changed(sd_bus *bus);
+bool bus_origin_changed(sd_bus *bus);
char *bus_address_escape(const char *v);
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index 2ad7a9993d..80dc86d01a 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -1610,7 +1610,7 @@ static int bus_add_object(
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(callback, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
n = bus_node_allocate(bus, path);
if (!n)
@@ -1806,7 +1806,7 @@ static int add_object_vtable_internal(
assert_return(vtable[0].x.start.element_size == VTABLE_ELEMENT_SIZE_221 ||
vtable[0].x.start.element_size >= VTABLE_ELEMENT_SIZE_242,
-EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(!streq(interface, "org.freedesktop.DBus.Properties") &&
!streq(interface, "org.freedesktop.DBus.Introspectable") &&
!streq(interface, "org.freedesktop.DBus.Peer") &&
@@ -2028,7 +2028,7 @@ _public_ int sd_bus_add_node_enumerator(
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(callback, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
n = bus_node_allocate(bus, path);
if (!n)
@@ -2280,7 +2280,7 @@ _public_ int sd_bus_emit_properties_changed_strv(
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2334,7 +2334,7 @@ _public_ int sd_bus_emit_properties_changed(
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
assert_return(interface_name_is_valid(interface), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2523,7 +2523,7 @@ _public_ int sd_bus_emit_object_added(sd_bus *bus, const char *path) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2703,7 +2703,7 @@ _public_ int sd_bus_emit_object_removed(sd_bus *bus, const char *path) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2862,7 +2862,7 @@ _public_ int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, ch
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2932,7 +2932,7 @@ _public_ int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const c
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2950,7 +2950,7 @@ _public_ int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path,
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2986,7 +2986,7 @@ _public_ int sd_bus_emit_interfaces_removed(sd_bus *bus, const char *path, const
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -3004,7 +3004,7 @@ _public_ int sd_bus_add_object_manager(sd_bus *bus, sd_bus_slot **slot, const ch
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(object_path_is_valid(path), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
n = bus_node_allocate(bus, path);
if (!n)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index f4f2e350f3..6e0b88e9d7 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -38,6 +38,7 @@
#include "memory-util.h"
#include "missing_syscall.h"
#include "missing_threads.h"
+#include "origin-id.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
@@ -232,6 +233,8 @@ static sd_bus* bus_free(sd_bus *b) {
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, bus_free);
+DEFINE_ORIGIN_ID_HELPERS(sd_bus, bus);
+
_public_ int sd_bus_new(sd_bus **ret) {
_cleanup_free_ sd_bus *b = NULL;
@@ -249,7 +252,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
.message_version = 1,
.creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME,
.accept_fd = true,
- .original_pid = getpid_cached(),
+ .origin_id = origin_id_query(),
.n_groups = SIZE_MAX,
.close_on_exit = true,
.ucred = UCRED_INVALID,
@@ -271,7 +274,7 @@ _public_ int sd_bus_set_address(sd_bus *bus, const char *address) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(address, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return free_and_strdup(&bus->address, address);
}
@@ -282,7 +285,7 @@ _public_ int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd) {
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(input_fd >= 0, -EBADF);
assert_return(output_fd >= 0, -EBADF);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->input_fd = input_fd;
bus->output_fd = output_fd;
@@ -298,7 +301,7 @@ _public_ int sd_bus_set_exec(sd_bus *bus, const char *path, char *const *argv) {
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(path, -EINVAL);
assert_return(!strv_isempty(argv), -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
a = strv_copy(argv);
if (!a)
@@ -316,7 +319,7 @@ _public_ int sd_bus_set_bus_client(sd_bus *bus, int b) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus->patch_sender, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->bus_client = !!b;
return 0;
@@ -326,7 +329,7 @@ _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->is_monitor = !!b;
return 0;
@@ -336,7 +339,7 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->accept_fd = !!b;
return 0;
@@ -346,7 +349,7 @@ _public_ int sd_bus_negotiate_timestamp(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(!IN_SET(bus->state, BUS_CLOSING, BUS_CLOSED), -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
/* This is not actually supported by any of our transports these days, but we do honour it for synthetic
* replies, and maybe one day classic D-Bus learns this too */
@@ -360,7 +363,7 @@ _public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(mask <= _SD_BUS_CREDS_ALL, -EINVAL);
assert_return(!IN_SET(bus->state, BUS_CLOSING, BUS_CLOSED), -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
SET_FLAG(bus->creds_mask, mask, b);
@@ -375,7 +378,7 @@ _public_ int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(b || sd_id128_equal(server_id, SD_ID128_NULL), -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->is_server = !!b;
bus->server_id = server_id;
@@ -386,7 +389,7 @@ _public_ int sd_bus_set_anonymous(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->anonymous_auth = !!b;
return 0;
@@ -396,7 +399,7 @@ _public_ int sd_bus_set_trusted(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->trusted = !!b;
return 0;
@@ -406,7 +409,7 @@ _public_ int sd_bus_set_description(sd_bus *bus, const char *description) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return free_and_strdup(&bus->description, description);
}
@@ -414,7 +417,7 @@ _public_ int sd_bus_set_description(sd_bus *bus, const char *description) {
_public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->allow_interactive_authorization = !!b;
return 0;
@@ -423,7 +426,7 @@ _public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
_public_ int sd_bus_get_allow_interactive_authorization(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->allow_interactive_authorization;
}
@@ -432,7 +435,7 @@ _public_ int sd_bus_set_watch_bind(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->watch_bind = !!b;
return 0;
@@ -441,7 +444,7 @@ _public_ int sd_bus_set_watch_bind(sd_bus *bus, int b) {
_public_ int sd_bus_get_watch_bind(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->watch_bind;
}
@@ -450,7 +453,7 @@ _public_ int sd_bus_set_connected_signal(sd_bus *bus, int b) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus->connected_signal = !!b;
return 0;
@@ -459,7 +462,7 @@ _public_ int sd_bus_set_connected_signal(sd_bus *bus, int b) {
_public_ int sd_bus_get_connected_signal(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->connected_signal;
}
@@ -1197,7 +1200,7 @@ _public_ int sd_bus_start(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state == BUS_UNSET, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
bus_set_state(bus, BUS_OPENING);
@@ -1758,7 +1761,7 @@ _public_ void sd_bus_close(sd_bus *bus) {
return;
if (bus->state == BUS_CLOSED)
return;
- if (bus_pid_changed(bus))
+ if (bus_origin_changed(bus))
return;
/* Don't leave ssh hanging around */
@@ -1779,7 +1782,7 @@ _public_ void sd_bus_close(sd_bus *bus) {
_public_ sd_bus *sd_bus_close_unref(sd_bus *bus) {
if (!bus)
return NULL;
- if (bus_pid_changed(bus))
+ if (bus_origin_changed(bus))
return NULL;
sd_bus_close(bus);
@@ -1790,7 +1793,7 @@ _public_ sd_bus *sd_bus_close_unref(sd_bus *bus) {
_public_ sd_bus* sd_bus_flush_close_unref(sd_bus *bus) {
if (!bus)
return NULL;
- if (bus_pid_changed(bus))
+ if (bus_origin_changed(bus))
return NULL;
/* Have to do this before flush() to prevent hang */
@@ -1813,7 +1816,7 @@ void bus_enter_closing(sd_bus *bus) {
_public_ sd_bus *sd_bus_ref(sd_bus *bus) {
if (!bus)
return NULL;
- if (bus_pid_changed(bus))
+ if (bus_origin_changed(bus))
return NULL;
bus->n_ref++;
@@ -1824,7 +1827,7 @@ _public_ sd_bus *sd_bus_ref(sd_bus *bus) {
_public_ sd_bus* sd_bus_unref(sd_bus *bus) {
if (!bus)
return NULL;
- if (bus_pid_changed(bus))
+ if (bus_origin_changed(bus))
return NULL;
assert(bus->n_ref > 0);
@@ -1839,7 +1842,7 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
return 0;
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return BUS_IS_OPEN(bus->state);
}
@@ -1849,7 +1852,7 @@ _public_ int sd_bus_is_ready(sd_bus *bus) {
return 0;
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->state == BUS_RUNNING;
}
@@ -1860,7 +1863,7 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->state != BUS_UNSET, -ENOTCONN);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->is_monitor)
return 0;
@@ -1885,7 +1888,7 @@ _public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(id, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
r = bus_ensure_running(bus);
if (r < 0)
@@ -2138,7 +2141,7 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2223,7 +2226,7 @@ _public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destinat
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2291,7 +2294,7 @@ _public_ int sd_bus_call_async(
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
@@ -2399,7 +2402,7 @@ _public_ int sd_bus_call(
assert_return(bus = bus_resolve(bus), -ENOPKG);
else
assert_return(bus = m->bus, -ENOTCONN);
- bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);
+ bus_assert_return(!bus_origin_changed(bus), -ECHILD, error);
if (!BUS_IS_OPEN(bus->state)) {
r = -ENOTCONN;
@@ -2532,7 +2535,7 @@ _public_ int sd_bus_get_fd(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(bus->input_fd == bus->output_fd, -EPERM);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->state == BUS_CLOSED)
return -ENOTCONN;
@@ -2551,7 +2554,7 @@ _public_ int sd_bus_get_events(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
switch (bus->state) {
@@ -2598,7 +2601,7 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(timeout_usec, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state) && bus->state != BUS_CLOSING)
return -ENOTCONN;
@@ -3237,7 +3240,7 @@ static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
/* We don't allow recursively invoking sd_bus_process(). */
assert_return(!bus->current_message, -EBUSY);
@@ -3371,7 +3374,7 @@ _public_ int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->state == BUS_CLOSING)
return 0;
@@ -3394,7 +3397,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->state == BUS_CLOSING)
return 0;
@@ -3448,7 +3451,7 @@ _public_ int sd_bus_add_filter(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(callback, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
s = bus_slot_allocate(bus, !slot, BUS_FILTER_CALLBACK, sizeof(struct filter_callback), userdata);
if (!s)
@@ -3545,7 +3548,7 @@ static int bus_add_match_full(
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(match, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
CLEANUP_ARRAY(components, n_components, bus_match_parse_free);
@@ -3630,15 +3633,6 @@ _public_ int sd_bus_add_match_async(
return bus_add_match_full(bus, slot, true, match, callback, install_callback, userdata);
}
-bool bus_pid_changed(sd_bus *bus) {
- assert(bus);
-
- /* We don't support people creating a bus connection and
- * keeping it around over a fork(). Let's complain. */
-
- return bus->original_pid != getpid_cached();
-}
-
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_bus *bus = ASSERT_PTR(userdata);
int r;
@@ -3969,7 +3963,7 @@ _public_ int sd_bus_default(sd_bus **ret) {
_public_ int sd_bus_get_tid(sd_bus *b, pid_t *tid) {
assert_return(b, -EINVAL);
assert_return(tid, -EINVAL);
- assert_return(!bus_pid_changed(b), -ECHILD);
+ assert_return(!bus_origin_changed(b), -ECHILD);
if (b->tid != 0) {
*tid = b->tid;
@@ -4195,7 +4189,7 @@ _public_ int sd_bus_path_decode_many(const char *path, const char *path_template
_public_ int sd_bus_try_close(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return -EOPNOTSUPP;
}
@@ -4205,7 +4199,7 @@ _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(description, -EINVAL);
assert_return(bus->description, -ENXIO);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->description)
*description = bus->description;
@@ -4219,7 +4213,7 @@ _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(scope, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->runtime_scope < 0)
return -ENODATA;
@@ -4232,7 +4226,7 @@ _public_ int sd_bus_get_address(sd_bus *bus, const char **address) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(address, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (bus->address) {
*address = bus->address;
@@ -4246,7 +4240,7 @@ _public_ int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(mask, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
*mask = bus->creds_mask;
return 0;
@@ -4255,7 +4249,7 @@ _public_ int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) {
_public_ int sd_bus_is_bus_client(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->bus_client;
}
@@ -4263,7 +4257,7 @@ _public_ int sd_bus_is_bus_client(sd_bus *bus) {
_public_ int sd_bus_is_server(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->is_server;
}
@@ -4271,7 +4265,7 @@ _public_ int sd_bus_is_server(sd_bus *bus) {
_public_ int sd_bus_is_anonymous(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->anonymous_auth;
}
@@ -4279,7 +4273,7 @@ _public_ int sd_bus_is_anonymous(sd_bus *bus) {
_public_ int sd_bus_is_trusted(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->trusted;
}
@@ -4287,7 +4281,7 @@ _public_ int sd_bus_is_trusted(sd_bus *bus) {
_public_ int sd_bus_is_monitor(sd_bus *bus) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
return bus->is_monitor;
}
@@ -4353,7 +4347,7 @@ _public_ int sd_bus_get_sender(sd_bus *bus, const char **ret) {
_public_ int sd_bus_get_n_queued_read(sd_bus *bus, uint64_t *ret) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(ret, -EINVAL);
*ret = bus->rqueue_size;
@@ -4363,7 +4357,7 @@ _public_ int sd_bus_get_n_queued_read(sd_bus *bus, uint64_t *ret) {
_public_ int sd_bus_get_n_queued_write(sd_bus *bus, uint64_t *ret) {
assert_return(bus, -EINVAL);
assert_return(bus = bus_resolve(bus), -ENOPKG);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
assert_return(ret, -EINVAL);
*ret = bus->wqueue_size;
@@ -4425,7 +4419,7 @@ _public_ int sd_bus_enqueue_for_read(sd_bus *bus, sd_bus_message *m) {
assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(m, -EINVAL);
assert_return(m->sealed, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
+ assert_return(!bus_origin_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
return -ENOTCONN;
diff --git a/src/libsystemd/sd-bus/test-bus-cleanup.c b/src/libsystemd/sd-bus/test-bus-cleanup.c
index f563db74e6..3e14627c75 100644
--- a/src/libsystemd/sd-bus/test-bus-cleanup.c
+++ b/src/libsystemd/sd-bus/test-bus-cleanup.c
@@ -1,11 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
+#include <unistd.h>
#include "sd-bus.h"
#include "bus-internal.h"
#include "bus-message.h"
+#include "process-util.h"
#include "tests.h"
static bool use_system_bus = false;
@@ -17,6 +19,30 @@ static void test_bus_new(void) {
assert_se(bus->n_ref == 1);
}
+static void test_bus_fork(void) {
+ _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+ int r;
+
+ assert_se(sd_bus_new(&bus) == 0);
+ assert_se(bus->n_ref == 1);
+
+ /* Check that after a fork the cleanup functions return NULL */
+ r = safe_fork("(bus-fork-test)", FORK_WAIT|FORK_LOG, NULL);
+ if (r == 0) {
+ assert_se(bus);
+ assert_se(sd_bus_is_ready(bus) == -ECHILD);
+ assert_se(sd_bus_flush_close_unref(bus) == NULL);
+ assert_se(sd_bus_close_unref(bus) == NULL);
+ assert_se(sd_bus_unref(bus) == NULL);
+ sd_bus_close(bus);
+ assert_se(bus->n_ref == 1);
+ _exit(EXIT_SUCCESS);
+ }
+
+ assert_se(r >= 0);
+ assert_se(bus->n_ref == 1);
+}
+
static int test_bus_open(void) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
@@ -67,6 +93,7 @@ int main(int argc, char **argv) {
test_setup_logging(LOG_INFO);
test_bus_new();
+ test_bus_fork();
if (test_bus_open() < 0)
return log_tests_skipped("Failed to connect to bus");