Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 329317

Summary: sys-apps/dbus xinitrc.d/30-dbus script needs to work better with consolekit and seahorse
Product: Gentoo Linux Reporter: Jim Ramsay (lack) (RETIRED) <lack>
Component: Current packagesAssignee: Freedesktop bugs <freedesktop-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: cardoe, michal, steev
Priority: High    
Version: 10.0   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Patch to 30-dbus to append to $command

Description Jim Ramsay (lack) (RETIRED) gentoo-dev 2010-07-21 19:24:01 UTC
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.
Comment 1 Jim Ramsay (lack) (RETIRED) gentoo-dev 2010-07-21 19:27:00 UTC
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.
Comment 2 Gilles Dartiguelongue (RETIRED) gentoo-dev 2010-07-22 08:27:51 UTC
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.
Comment 3 Jim Ramsay (lack) (RETIRED) gentoo-dev 2010-07-22 14:18:21 UTC
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"

90consolekit has:
  STARTUP="$CK_LAUNCH_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?
Comment 4 Jim Ramsay (lack) (RETIRED) gentoo-dev 2010-07-26 19:28:30 UTC
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:
  ck-launch-session wraps
    dbus-launch which wraps
      seahorse-agent which wraps
        ssh-agent

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?
Comment 5 RĂ©mi Cardona (RETIRED) gentoo-dev 2010-07-28 06:31:15 UTC
*** Bug 330149 has been marked as a duplicate of this bug. ***
Comment 6 Carl Michal 2010-07-28 23:03:34 UTC
The suggested patch works for me.
Comment 7 Jim Ramsay (lack) (RETIRED) gentoo-dev 2010-08-05 20:05:02 UTC
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