[systemd-devel] [PATCH] bus-proxyd: overwrite 'sender' field in process_driver() function

Lukasz Skalski l.skalski at samsung.com
Wed Jan 7 01:14:07 PST 2015


This patch doesn't work as I expected so please skip it - sorry for the
confusion.

On 01/05/2015 05:03 PM, Lukasz Skalski wrote:
> To keep compatibility with dbus-1, before we use synthetic_reply_method_*()
> functions, we should overwrite 'sender' field - otherwise functions
> sd_bus_message_new_method_return() and sd_bus_message_new_method_error() never
> set 'destination' field.
> 
> Thanks to this we have proper 'destination' value:
> 
> dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply / org.freedesktop.DBus.ListNames
> method return sender=org.freedesktop.DBus -> dest=:1.338 reply_serial=2
>    array [
>       string ":1.1"
>       string ":1.18"
>       string ":1.27"
>       string ":1.338"
>       string ":1.35"
>       string "org.freedesktop.DBus"
>       string "org.freedesktop.login1"
>       string "org.freedesktop.systemd1"
>    ]
> 
> instead of '(null destination)':
> 
> dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply / org.freedesktop.DBus.ListNames
> method return sender=org.freedesktop.DBus -> dest=(null destination) reply_serial=2
> 
> ---
>  src/bus-proxyd/bus-proxyd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
> index fc70cce..add1ccb 100644
> --- a/src/bus-proxyd/bus-proxyd.c
> +++ b/src/bus-proxyd/bus-proxyd.c
> @@ -456,6 +456,7 @@ static int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, s
>  
>  static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred, Set *owned_names) {
>          int r;
> +        _cleanup_free_ const char *unique;
>  
>          assert(a);
>          assert(b);
> @@ -467,6 +468,11 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
>          if (!streq_ptr(sd_bus_message_get_destination(m), "org.freedesktop.DBus"))
>                  return 0;
>  
> +        r = sd_bus_get_unique_name(a, &unique);
> +        if (r < 0)
> +                return 0;
> +        m->sender = unique;
> +
>          /* The "Hello()" call is is handled in process_hello() */
>  
>          if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
> 

-- 
Lukasz Skalski
Samsung R&D Institute Poland
Samsung Electronics
l.skalski at samsung.com


More information about the systemd-devel mailing list