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 98715 - loses parent environment variables on startup
loses parent environment variables on startup
Status: RESOLVED FIXED
Product: gnome-terminal
Classification: Core
Component: general
2.12.x
Other All
: Normal normal
: ---
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
: 121679 123085 324443 324716 325292 325433 497044 (view as bug list)
Depends on: 399209
Blocks:
 
 
Reported: 2002-11-16 19:01 UTC by Christian Marillat
Modified: 2008-09-25 18:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
implementation (12.95 KB, patch)
2005-11-23 08:39 UTC, Danielle Madeley
needs-work Details | Review

Description Christian Marillat 2002-11-16 19:01:17 UTC
Hi,

http://bugs.debian.org/169368

gnome-terminal loses the environment varibles which are set in the
calling process. If one sets an environment variable in his shell and
then starts a new gnome-terminal:

% export BLA=1
% gnome-terminal

The variable BLA will be lost in the new terminal. In practice this
causes problems with the ssh-agent that is started from
/etc/X11/gdm/Session/Gnome, since the $SSH_* variables don't make it
into the gnome-terminal. I am not really sure what the cause for this
is, but it has something to do with the way new terminals are startet.
A workaround is to start the gnome-terminal with the parameter
--disable-factor or setting:

'terminal.c:85:static gboolean terminal_factory_disabled = FALSE;

to TRUE.
Comment 1 Havoc Pennington 2002-11-16 19:07:59 UTC
it's sort of unclear how to fix this (since there's only one g-t
process in factory mode, and it can only have one environment).

I suppose we could store an environment per-terminal-tab/window, but 
that probably creates other issues.

An in-between road might special-case the forwarding of some specific 
env variables, just as ssh does.
Comment 2 Heath Harrelson 2002-11-18 22:42:56 UTC
Adding keywords.
Comment 3 Mariano Suárez-Alvarez 2003-09-24 01:37:28 UTC
*** Bug 123085 has been marked as a duplicate of this bug. ***
Comment 4 Mariano Suárez-Alvarez 2003-10-06 09:43:44 UTC
*** Bug 121679 has been marked as a duplicate of this bug. ***
Comment 5 Mariano Suárez-Alvarez 2003-10-06 09:44:51 UTC
Bug 121697 suggested, at least, documenting this behaviour.
Comment 6 Danielle Madeley 2005-11-04 09:21:16 UTC
Just came across this with someone on #gnome just now.

The hideous workaround fix is to pass:
LANG=C gnome-terminal --disable-factory

Perhaps it would be possible to pass environ from gnome-terminal to the factory
to be used when execve-ing.
Comment 7 Mathias Hasselmann (IRC: tbf) 2005-11-04 09:31:24 UTC
Why not just save all environment variables passed on startup? To save memory
for unmodified variables, GQuark could be used to intern() the strings.
Comment 8 Danielle Madeley 2005-11-04 09:42:44 UTC
On Linux at least, it is possible to retrieve environ for another process you
own. Without having read any code, I could envision this happening like so.

 - client sends signal to factory telling it to create a new terminal, it
includes its PID;
 - Factory does the bits and pieces to create a new shell and fork()s process
for shell;
 - child process gets environ for original PID, calls execve with this environ;
 - shell comes into existance with this environ, client is let terminate

Not sure how portable this is, but would require almost zero extra IPC.
Comment 9 Olav Vitters 2005-11-04 12:21:15 UTC
Davyd: Looking forward to your implementation (as a we lack an active maintainer).
Comment 10 Danielle Madeley 2005-11-04 13:00:56 UTC
I might see what I can do after the exams. There are a couple of other things in
gnome-terminal that could possibly do with some love. It would be nice to find a
new maintainer however.
Comment 11 Danielle Madeley 2005-11-23 08:39:22 UTC
Created attachment 55138 [details] [review]
implementation

Environ is transferred with the factory connection.

Things to note,
 - we can't pass a NULL delimiter (the only thing argv can't contain), so we
pass
   environ first with a text delimiter that isn't an environment variable.
 - this has not been widely tested for leaks or dodginess, but seems to work
Comment 12 Havoc Pennington 2005-11-23 18:42:13 UTC
Comment on attachment 55138 [details] [review]
implementation

patch looks plausible to me, not that I am maintaining this thing. :-P
Comment 13 Kjartan Maraas 2005-11-30 21:56:15 UTC
Commited to HEAD.
Comment 14 Daniel Holbach 2005-12-14 22:03:10 UTC
In Ubuntu we had trouble with the latest release (2.13.0). People could in some
cases open only one terminal (reproducibly with --geometry=100x37). After
reverting this very patch, everybody was happy again. I'd rather REOPEN this bug
and re-review the patch.
Comment 15 Olav Vitters 2005-12-14 22:11:19 UTC
Causes hangs.
Comment 16 Danielle Madeley 2005-12-15 02:13:31 UTC
Ok. Looking at this quickly. The problem with starting new terminals was because
you have to firstly shut down the factory (since the factory protocol has now
changed).

There is however a problem with sending the argv it seems (any argv seems to be
a problem). I'll look into it.
Comment 17 Saleem Abdulrasool 2005-12-21 23:04:57 UTC
*** Bug 324716 has been marked as a duplicate of this bug. ***
Comment 18 Olav Vitters 2005-12-22 00:51:04 UTC
*** Bug 324443 has been marked as a duplicate of this bug. ***
Comment 19 Ilya Konstantinov 2005-12-28 12:12:12 UTC
Meanwhile, please back the patch out of CVS.
Comment 20 Ilya Konstantinov 2005-12-28 12:36:38 UTC
For the reference, I've opened a Fedora bug for reverting this patch, cause it causes a memory corruption (and a hang when glibc is trying to get the stack trace):
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=176642
Comment 21 Danielle Madeley 2005-12-28 13:29:46 UTC
This is not a stable tree, I think cooking a fix to this issue will be more productive than backing it out.

I can reproduce the glibc memory corruption message, but have not yet determined where it is taking place. Some help in this matter would be most appreciated.
Comment 22 Ilya Konstantinov 2005-12-28 13:48:25 UTC
If you wanna keep it in the tree so someone else could fix it, okay.
Alternatively, I've posted a reversal patch to the Fedora bugzilla (or simply patch -R'ing your patch works as well).
Comment 23 Olav Vitters 2005-12-30 12:29:45 UTC
*** Bug 325292 has been marked as a duplicate of this bug. ***
Comment 24 Olav Vitters 2006-01-01 21:10:43 UTC
I've backed out the patch. Gnome-terminal is unusable with this patch and it is very close to a new release.
Comment 25 Olav Vitters 2006-01-02 06:58:29 UTC
*** Bug 325433 has been marked as a duplicate of this bug. ***
Comment 26 Christian Persch 2008-05-29 19:45:21 UTC
Marking depending on bug 399209 so we remember to fix this when we switch the single-instance protocol.
Comment 27 Christian Persch 2008-06-29 12:59:52 UTC
*** Bug 497044 has been marked as a duplicate of this bug. ***
Comment 28 Christian Persch 2008-09-25 18:54:50 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.