Bug 101375 - It would be nice if dbus-send also accepted "--user"
Summary: It would be nice if dbus-send also accepted "--user"
Status: RESOLVED MOVED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.10
Hardware: Other All
: medium enhancement
Assignee: D-Bus Maintainers
QA Contact: D-Bus Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-11 00:09 UTC by Danny Milosavljevic
Modified: 2018-10-12 21:31 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
dbus-send: Add "--user" (2.34 KB, patch)
2017-06-11 00:09 UTC, Danny Milosavljevic
Details | Splinter Review

Description Danny Milosavljevic 2017-06-11 00:09:12 UTC
Created attachment 131848 [details] [review]
dbus-send: Add "--user"
Comment 1 Simon McVittie 2017-06-12 10:34:35 UTC
Please clarify why you want this?

If you already have a user bus, dbus-send --session will use it, because the user bus and the session bus are the same thing on such systems.

If you don't, dbus-send --session will (attempt to) contact the session bus, which (if successful) is the right place to find anything that, on systems that have a user bus, would be on the user bus.
Comment 2 Philip Withnall 2017-06-12 10:36:15 UTC
Comment on attachment 131848 [details] [review]
dbus-send: Add "--user"

Review of attachment 131848 [details] [review]:
-----------------------------------------------------------------

The man page (doc/dbus-send.1.xml.in) needs to be updated too.

::: orig/dbus-1.10.18/tools/dbus-send.c
@@ +275,5 @@
> +          dbus_bool_t user_bus_supported = FALSE;
> +          DBusString user_bus;
> +
> +	  type = DBUS_BUS_SESSION;
> +          session_or_system = FALSE;

I think you probably also want to set `is_bus = TRUE` so that the bus handshake is done.

@@ +277,5 @@
> +
> +	  type = DBUS_BUS_SESSION;
> +          session_or_system = FALSE;
> +
> +          if (! _dbus_string_init (&user_bus))

Nitpick: The coding style requires no space before the function name and after the `!`.

@@ +287,5 @@
> +              exit (1);
> +            }
> +          else if (user_bus_supported)
> +            {
> +              address = _dbus_string_get_const_data (&user_bus);

This branch will leak the contents of `user_bus`. Move the declaration to the top level and free it before exit.

@@ +292,5 @@
> +            }
> +          else
> +            {
> +              _dbus_string_free (&user_bus);
> +              fprintf(stderr, "User bus is not supported on this system.\n");

Nitpick: The coding style requires a space before the `(`.
Comment 3 Simon McVittie 2017-06-12 10:39:15 UTC
I don't think we should be adding --user unless there is a real need for it, so only fix the issues that Philip raised if there is a reason why the new option is justified.
Comment 4 Danny Milosavljevic 2017-06-13 05:10:31 UTC
We have services that registered on the user bus and want to send messages there. Right now that means we have to manually specify unix:path=${XDG_RUNTIME_DIR}/bus which isn't exactly straightforward.

Furthermore, other tools in your package support "--user".  So it's unexpected for this one not to - especially since it does support "--system" and "--session".
Comment 5 Simon McVittie 2017-06-13 10:54:02 UTC
(In reply to Danny Milosavljevic from comment #4)
> We have services that registered on the user bus and want to send messages
> there. Right now that means we have to manually specify
> unix:path=${XDG_RUNTIME_DIR}/bus which isn't exactly straightforward.

What version of dbus is this? If you ensure that XDG_RUNTIME_DIR is set, but don't set DBUS_SESSION_BUS_ADDRESS, recent libdbus (>= 1.10) defaults to unix:path=${XDG_RUNTIME_DIR}/bus (as a higher priority than trying X11 autolaunching).

> Furthermore, other tools in your package support "--user"

Which ones? `git grep '\-\-user` doesn't show me any.

One of the major motivations behind the way the "user bus" was implemented in dbus 1.10 was to avoid getting into a situation where "the user bus" and "the session bus" mean different things.
Comment 6 Simon McVittie 2017-06-13 10:55:10 UTC
(In reply to Simon McVittie from comment #5)
> What version of dbus is this? If you ensure that XDG_RUNTIME_DIR is set, but
> don't set DBUS_SESSION_BUS_ADDRESS, recent libdbus (>= 1.10) defaults to
> unix:path=${XDG_RUNTIME_DIR}/bus (as a higher priority than trying X11
> autolaunching).

For completeness, this only works for the same uid that owns the XDG_RUNTIME_DIR. If you are trying to use the XDG_RUNTIME_DIR or user bus of a different uid, that is an incorrect design and will not work.
Comment 7 GitLab Migration User 2018-10-12 21:31:11 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/178.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.