The current 30-dbus script, as run by /etc/X11/xinit/xinitrc will run dbus-launch outside of the umbrella of ck-launch-session, end result being that any dbus-spawned services
The service /usr/libexec/gvfs-gdu-volume-monitor in particular is what spawned my investigation into this issue, but it's a more general problem, as I'm sure you can appreciate.
If 30-dbus used the more-current method of appending to the $command variable instead of spawning dbus-launch immediately, it would properly be started as a child of ck-launch-session, and all would be well.
Created attachment 239713 [details, diff]
Patch to 30-dbus to append to $command
Here's one idea that does what we want. I have tested this and all dbus-spawned services do indeed inherit the appropriate consolekit session.
this must be compared to how fedora/ubuntu/debian do their xinit stuff since most of the other scripts in that directory were built from there and the sorting is important. There's also an open gentoo bug for reworking xinit to match fedora/ubuntu/debian way but I can't remember the bug # for now.
Oops, noticed that I missed completing a paragraph when I submitted the bug originally. I should have made it more clear that the end result of this problem is that any dbus-spawned services do not inherit the appropriate consolekit session and so have different privileges than the currently logged-in user who owns them.
So, a quick peek at the one Ubuntu system (9.04) where I happen to have access shows that their scripts (which are all in Xsesion.d, actually) do the same thing in the same order (roughly) as my proposed patch. They have:
75dbus_dbus-launch which contains (after all the 'should-we-start' checks):
STARTUP="$DBUSLAUNCH --exit-with-session $STARTUP"
I can't attest to how Ubuntu deals with other services like seahorse or ssh-agent that we have xinitrc.d scripts for, but the order of "source dbus before sourcing consolekit" and the practice of the later-sourced one wrapping execution of the earlier-sourced one seems to be the way it's done.
One main difference between their script and my patch is that they add the '--exit-with-session' option to dbus-launch. I really don't think it's necessary when invoked as ours is with a program argument as it will terminate when the child process terminates (and that child process will be the windowmanager), but there's also no harm to having it in there.
I have also added a codepath where if our script is called and the '$command' that Dbus would normally wrap is *not* set, we launch dbus the old way, with 'eval' and --sh-syntax and --exit-with-session. I'm not sure this is really needed either since the case of $command being unset will only occur in the fallback xinit case, and this may be better addressed by a rewrite of our xinit stuff anyway.
But my patch addresses the immediate issue (dbus-spawned services do not inherit the proper consolekit session) so perhaps it's good enough for now?
Hmmm.... One small snafu with my patch: It doesn't work well with app-crypt/seahorse, which installs 70-seahorse-agent.
70-seahorse-agent is set up just like 90-consolekit and 50-ssh-agent (and like I think 30-dbus should be), in that it will wrap all lower-numbered daemons in its environment by appending to $command
However, since seahorse needs dbus, it should be at a lower number than the dbus script, otherwise it spawns its own separate dbus session = Not good.
Renaming my patched 30-dbus script to '80-dbus' instead works fine, so the order of parsing is (on my system):
50-ssh-agent 70-seahorse-agent 80-dbus 90-consolekit
And the resulting spawn-order is:
dbus-launch which wraps
seahorse-agent which wraps
I think the important thing here is that: Consolekit must wrap dbus, and dbus must wrap seahorse. Thus dbus must appear between consolekit and seahorse in the xinitrc.d order and use the same 'append-to-command' mechanism as both of those.
This probably explains why, on that Ubuntu system I referenced earlier, dbus is actually given level 75 in their Xsession.d directory.
So I recommend adding my patch *and* renaming the file to 80-dbus. How does that sound?
*** Bug 330149 has been marked as a duplicate of this bug. ***
The suggested patch works for me.
Okay, with Cardoe's go-ahead, I have applied the patch (plus one more change I have encountered since I actually posted this patch, specifically adding --exit-with-session), and renamed 30-dbus to 80-dbus.
Revbumps with this change: 1.2.24-r1 and 1.3.0-r2