After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697052 - Should not forward DESKTOP_AUTOSTART_ID when spawning applications
Should not forward DESKTOP_AUTOSTART_ID when spawning applications
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-01 16:02 UTC by Cosimo Cecchi
Modified: 2018-01-14 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
media-keys: Avoid leaking DESKTOP_AUTOSTART_ID to children (817 bytes, patch)
2013-04-02 08:54 UTC, Bastien Nocera
committed Details | Review

Description Cosimo Cecchi 2013-04-01 16:02:15 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
Comment 1 Bastien Nocera 2013-04-02 08:41:42 UTC
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.
Comment 2 Bastien Nocera 2013-04-02 08:54:32 UTC
Created attachment 240363 [details] [review]
media-keys: Avoid leaking DESKTOP_AUTOSTART_ID to children
Comment 3 Cosimo Cecchi 2013-04-02 15:52:26 UTC
(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.
Comment 4 Bastien Nocera 2013-04-11 16:25:18 UTC
Attachment 240363 [details] pushed as 44c184d - media-keys: Avoid leaking DESKTOP_AUTOSTART_ID to children
Comment 5 Sebastian 2018-01-06 13:41:02 UTC
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'.
Comment 6 Sebastian 2018-01-06 14:05:31 UTC
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.
Comment 7 Bastien Nocera 2018-01-14 14:03:01 UTC
(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.