From: Zbigniew Jędrzejewski-Szmek Date: Thu, 19 Mar 2020 20:28:25 +0000 (+0100) Subject: sd-bus: make sure SD_BUS_DEFAULT* works everywhere X-Git-Tag: v246-rc1~709^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=501ecd670c2aeb9e92a7a7fa45a0172e808180ec;p=thirdparty%2Fsystemd.git sd-bus: make sure SD_BUS_DEFAULT* works everywhere I'm not sure why those functions were not touched in 45b1f410ba699990e4033805fe64cc369b835f10. Anyway, it seems easier to just support the magic parameters everywhere. --- diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c index 4ec061644d5..a1d81a1315d 100644 --- a/src/libsystemd/sd-bus/bus-convenience.c +++ b/src/libsystemd/sd-bus/bus-convenience.c @@ -96,6 +96,7 @@ _public_ int sd_bus_call_method( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); bus_assert_return(!bus_pid_changed(bus), -ECHILD, error); if (!BUS_IS_OPEN(bus->state)) { @@ -283,6 +284,7 @@ _public_ int sd_bus_get_property( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); 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(reply, -EINVAL, error); @@ -324,6 +326,7 @@ _public_ int sd_bus_get_property_trivial( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); 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(bus_type_is_trivial(type), -EINVAL, error); @@ -368,6 +371,7 @@ _public_ int sd_bus_get_property_string( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); 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); @@ -416,6 +420,7 @@ _public_ int sd_bus_get_property_strv( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); 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); @@ -458,6 +463,7 @@ _public_ int sd_bus_set_property( int r; bus_assert_return(bus, -EINVAL, error); + bus_assert_return(bus = bus_resolve(bus), -ENOPKG, error); 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); diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 73127dfe025..b8f91f4434d 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -588,6 +588,7 @@ _public_ int sd_bus_message_new( sd_bus_message *t; assert_return(bus, -ENOTCONN); + assert_return(bus = bus_resolve(bus), -ENOPKG); assert_return(bus->state != BUS_UNSET, -ENOTCONN); assert_return(m, -EINVAL); assert_return(type < _SD_BUS_MESSAGE_TYPE_MAX, -EINVAL); @@ -623,6 +624,7 @@ _public_ int sd_bus_message_new_signal( int r; assert_return(bus, -ENOTCONN); + assert_return(bus = bus_resolve(bus), -ENOPKG); assert_return(bus->state != BUS_UNSET, -ENOTCONN); assert_return(object_path_is_valid(path), -EINVAL); assert_return(interface_name_is_valid(interface), -EINVAL); @@ -663,6 +665,7 @@ _public_ int sd_bus_message_new_method_call( int r; assert_return(bus, -ENOTCONN); + assert_return(bus = bus_resolve(bus), -ENOPKG); assert_return(bus->state != BUS_UNSET, -ENOTCONN); assert_return(!destination || service_name_is_valid(destination), -EINVAL); assert_return(object_path_is_valid(path), -EINVAL); diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index e45334c83f4..acfff6d28eb 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -3674,31 +3674,31 @@ _public_ int sd_bus_detach_event(sd_bus *bus) { } _public_ sd_event* sd_bus_get_event(sd_bus *bus) { - assert_return(bus, NULL); + assert_return(bus = bus_resolve(bus), NULL); return bus->event; } _public_ sd_bus_message* sd_bus_get_current_message(sd_bus *bus) { - assert_return(bus, NULL); + assert_return(bus = bus_resolve(bus), NULL); return bus->current_message; } _public_ sd_bus_slot* sd_bus_get_current_slot(sd_bus *bus) { - assert_return(bus, NULL); + assert_return(bus = bus_resolve(bus), NULL); return bus->current_slot; } _public_ sd_bus_message_handler_t sd_bus_get_current_handler(sd_bus *bus) { - assert_return(bus, NULL); + assert_return(bus = bus_resolve(bus), NULL); return bus->current_handler; } _public_ void* sd_bus_get_current_userdata(sd_bus *bus) { - assert_return(bus, NULL); + assert_return(bus = bus_resolve(bus), NULL); return bus->current_userdata; }