GNOME Bugzilla – Bug 697052
Should not forward DESKTOP_AUTOSTART_ID when spawning applications
Last modified: 2018-01-14 14:03:01 UTC
I have a custom keyboard shortcut setup to open gnome-terminal. When g-s-d spawns the terminal, its environment is forwarded to the children. This includes the DESKTOP_AUTOSTART_ID environment variable, which should instead be private between the session and g-s-d. One practical effect is that any app that tries to register with the session spawned from such terminal will reuse the g-s-d DESKTOP_AUTOSTART_ID value, making it fail: e.g. [cosimoc@x201: ~]$ nautilus (nautilus:22948): Gtk-WARNING **: Failed to register client: GDBus.Error:org.gnome.SessionManager.AlreadyRegistered: Unable to register client
It shouldn't. The only env we pass is the output of: dbus-send --session --print-reply --dest=org.gnome.keyring /org/gnome/keyring/daemon org.gnome.keyring.Daemon.GetEnvironment (note, doesn't work in GDBus) If this command fails (you should see a warning about this in the logs), we do pass NULL to g_spawn_async() though, which would cause it to pass its own env to the child. This is easily worked-around, but doesn't fix the root-cause of the problem.
Created attachment 240363 [details] [review] media-keys: Avoid leaking DESKTOP_AUTOSTART_ID to children
(In reply to comment #1) > It shouldn't. The only env we pass is the output of: > dbus-send --session --print-reply --dest=org.gnome.keyring > /org/gnome/keyring/daemon org.gnome.keyring.Daemon.GetEnvironment > (note, doesn't work in GDBus) > > If this command fails (you should see a warning about this in the logs), we do > pass NULL to g_spawn_async() though, which would cause it to pass its own env > to the child. This is easily worked-around, but doesn't fix the root-cause of > the problem. In my testing I see all the environment vars forwarded from the keyring daemon are present in the spawned terminal, but also DESKTOP_AUTOSTART_ID. I also checked it's not gnome-terminal doing anything fancy - I can reproduce the same thing launching xterm instead.
Attachment 240363 [details] pushed as 44c184d - media-keys: Avoid leaking DESKTOP_AUTOSTART_ID to children
I am wondering if there has been a regression that is causing this bug to appear again. I am using a shortcut to start gnome-terminal with CTRL+ALT+T, when I start the terminal via this hotkey then DESKTOP_AUTOSTART_ID is set. By querying the SessionManager I can see that it corresponds to org.gnome.SettingsDaemon.MediaKeys.desktop'.
One more thing. When I start a gnome-terminal from the desktop shell, then the DESKTOP_AUTOSTART_ID is not set. However both processes end-up as children of the same gnome-terminal-server process, which also does not have DESKTOP_AUTOSTART_ID set in its environment file (e.g. in /proc/<pid>/environ). So gnome-terminal windows started via hotkey by MediaKeys must somehow receive this environment variable. While gnome-terminal windows started from the desktop menu do not receive it.
(In reply to Sebastian from comment #5) > I am wondering if there has been a regression that is causing this bug to > appear again. I am using a shortcut to start gnome-terminal with CTRL+ALT+T, > when I start the terminal via this hotkey then DESKTOP_AUTOSTART_ID is set. > By querying the SessionManager I can see that it corresponds to > org.gnome.SettingsDaemon.MediaKeys.desktop'. File a new bug. There's no point adding more comments to a bug that was closed 5 years prior.