Bug 496947

Summary: Incorrect default folder when opening a new tab
Product: [Fedora] Fedora Reporter: Mathieu Bridon <bochecha>
Component: gnome-terminalAssignee: Behdad Esfahbod <behdad>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: behdad, lsof, maxim, mclasen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-01-14 13:06:32 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Mathieu Bridon 2009-04-21 14:47:05 EDT
Description of problem:
Somewhere between  gnome-terminal-2.24.3 and gnome-terminal-2.26.1, gnome-terminal's CWD changed to / and now it seems like terminal_screen_get_current_dir is returning / when it can't chdir to the target working dir.


Version-Release number of selected component (if applicable):
gnome-terminal-2.26.1-1.fc11.x86_64


How reproducible:
Always


Steps to Reproduce:
1. Open a gnome-terminal as your normal user
2. $ su -
  => You get a root shell in /root
3. CTRL + SHIFT + T
  => you get a new tab as your normal user in /

Alternatively:
1. $ cd /tmp
2. $ mkdir foo
3. $ cd foo
4. $ chmod a-x .
5. CTRL + SHIFT + T
  => you get a new tab as your normal user in /

Expected results:
Opening new tab in both of these cases should open a shell as your normal user in its $HOME.

Additional info:
1. $ cd /tmp
2. $ mkdir foo
3. $ cd foo
4. don't do the « chmod a-x . » so that /tmp/foo is 755
5. CTRL + SHIFT + T
  => you get a new tab as your normal user in /tmp/foo, which is expected.


Thanks a lot to wwoods and nanonyme in #fedora-qa for helping me understand  the issue and for digging it.
Comment 1 Matthias Clasen 2009-04-21 15:08:46 EDT
Related bug: http://bugzilla.gnome.org/show_bug.cgi?id=579291
Comment 2 Matthias Clasen 2009-04-21 15:09:42 EDT
http://bugzilla.gnome.org/show_bug.cgi?id=525450
Comment 3 Mathieu Bridon 2009-04-21 15:24:57 EDT
Actually, those 2 bugs are not the same issue as the one I reported.

Those 2 complain about the fact that new tabs are opened in the same folder as the tab you were in before opening the new one.

I'm not complaining about that, I _love_ this behaviour.

The issue here is that if it's not possible to chdir to this dir when opening the new tab (the x bit is not set), you're left in / when you should be left in $HOME.
Comment 4 Will Woods 2009-04-21 15:50:29 EDT
I'm guessing this bug stems from the fact that F-10 gnome-terminal (2.24.x) ran with cwd=$HOME:

  home_dir = g_get_home_dir ();
  if (home_dir)
    g_chdir (home_dir);

  gtk_main ();

2.26.x changed to cwd=/, due to http://bugzilla.gnome.org/show_bug.cgi?id=565328:

  if (chdir ("/") < 0)
    g_warning ("Failed to chdir to /: %s", g_strerror (errno));

  gtk_main ();

Perhaps terminal_screen_launch_child should chdir() to the user's homedir before calling vte_terminal_fork_command() - then if vte_terminal_fork_command() fails to chdir(), we'll end up in $HOME instead of /.
Comment 5 Matthias Clasen 2009-04-21 18:53:34 EDT
I've reopened the upstream bug and added some comments there.
Comment 6 Matthias Clasen 2009-04-22 16:22:11 EDT
Can you try gnome-terminal-2.26.1-2.fc11, which has the proposed upstream fix ?
Comment 7 Mathieu Bridon 2009-04-22 17:29:38 EDT
Just installed it.

That fixes the first case I mentioned (tab1 as root then CTRL + SHIFT + T), but not the second one (tab1 as same user but in a folder you don't have exec permission).

That's weird, we figured it was the same problem for both :-/
Comment 8 Will Woods 2009-05-27 17:05:43 EDT
*** Bug 495910 has been marked as a duplicate of this bug. ***
Comment 9 Bug Zapper 2009-06-09 10:20:40 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 10 Mathieu Bridon 2009-06-20 05:55:59 EDT
Still present with gnome-terminal-2.26.2-1.fc11.x86_64
Comment 11 Need Real Name 2009-11-18 07:52:09 EST
Seems fixed in gnome-terminal-2.28.1-1.fc12.x86_64
Comment 12 Mathieu Bridon 2009-11-18 14:31:52 EST
As the initial reporter, I confirm both issues are fixed in F12 (same version as comment #11).
Comment 13 Need Real Name 2010-01-06 09:52:22 EST
mark as closed currentversion?