summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Perier <mrpouet@gentoo.org>2009-08-28 16:27:47 +0000
committerRomain Perier <mrpouet@gentoo.org>2009-08-28 16:27:47 +0000
commitd18f142f78b00c1d3d570f2db7db0b34c1b36f09 (patch)
tree9d2d35ab53fccca4976820a1753ee6fe72b02f3b /x11-terms/gnome-terminal
parentStable on alpha, bug #280266 (diff)
downloadgentoo-2-d18f142f78b00c1d3d570f2db7db0b34c1b36f09.tar.gz
gentoo-2-d18f142f78b00c1d3d570f2db7db0b34c1b36f09.tar.bz2
gentoo-2-d18f142f78b00c1d3d570f2db7db0b34c1b36f09.zip
Fix bug #269318, if we are logged in root on the first tab and if we try to open a new tab, do not open it in user on /, patch import from upstream bug #565328. Drop old revision
(Portage version: 2.2_rc40/cvs/Linux x86_64)
Diffstat (limited to 'x11-terms/gnome-terminal')
-rw-r--r--x11-terms/gnome-terminal/ChangeLog11
-rw-r--r--x11-terms/gnome-terminal/files/gnome-terminal-2.26.3.1-cwd-on-new-tab.patch220
-rw-r--r--x11-terms/gnome-terminal/gnome-terminal-2.26.3.1-r1.ebuild (renamed from x11-terms/gnome-terminal/gnome-terminal-2.26.3.1.ebuild)6
3 files changed, 235 insertions, 2 deletions
diff --git a/x11-terms/gnome-terminal/ChangeLog b/x11-terms/gnome-terminal/ChangeLog
index 6ed5bdfae247..cafd93ed7163 100644
--- a/x11-terms/gnome-terminal/ChangeLog
+++ b/x11-terms/gnome-terminal/ChangeLog
@@ -1,6 +1,15 @@
# ChangeLog for x11-terms/gnome-terminal
# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/x11-terms/gnome-terminal/ChangeLog,v 1.198 2009/07/09 22:46:37 eva Exp $
+# $Header: /var/cvsroot/gentoo-x86/x11-terms/gnome-terminal/ChangeLog,v 1.199 2009/08/28 16:27:47 mrpouet Exp $
+
+*gnome-terminal-2.26.3.1-r1 (28 Aug 2009)
+
+ 28 Aug 2009; Romain Perier <mrpouet@gentoo.org>
+ -gnome-terminal-2.26.3.1.ebuild, +gnome-terminal-2.26.3.1-r1.ebuild,
+ +files/gnome-terminal-2.26.3.1-cwd-on-new-tab.patch:
+ Fix bug #269318, if we are logged in root on the first tab and if we try
+ to open a new tab, do not open it in user on /, patch import from upstream
+ bug #565328. Drop old revision.
*gnome-terminal-2.26.3.1 (09 Jul 2009)
diff --git a/x11-terms/gnome-terminal/files/gnome-terminal-2.26.3.1-cwd-on-new-tab.patch b/x11-terms/gnome-terminal/files/gnome-terminal-2.26.3.1-cwd-on-new-tab.patch
new file mode 100644
index 000000000000..d532dc0db088
--- /dev/null
+++ b/x11-terms/gnome-terminal/files/gnome-terminal-2.26.3.1-cwd-on-new-tab.patch
@@ -0,0 +1,220 @@
+Author: Christian Persch
+Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=565328
+Date: 2009-04-22 18:33
+
+---
+
+diff --git a/src/terminal-screen.c b/src/terminal-screen.c
+index e6dd61e..10deb3f 100644
+--- a/src/terminal-screen.c
++++ b/src/terminal-screen.c
+@@ -183,6 +183,59 @@ static guint n_skey_regexes;
+
+ G_DEFINE_TYPE (TerminalScreen, terminal_screen, VTE_TYPE_TERMINAL)
+
++static char *
++cwd_of_pid (int pid)
++{
++ static const char patterns[][18] = {
++ "/proc/%d/cwd", /* Linux */
++ "/proc/%d/path/cwd", /* Solaris >= 10 */
++ };
++ guint i;
++
++ if (pid == -1)
++ return NULL;
++
++ /* Try to get the working directory using various OS-specific mechanisms */
++ for (i = 0; i < G_N_ELEMENTS (patterns); ++i)
++ {
++ char cwd_file[64];
++ char buf[PATH_MAX + 1];
++ int len;
++
++ g_snprintf (cwd_file, sizeof (cwd_file), patterns[i], pid);
++ len = readlink (cwd_file, buf, sizeof (buf) - 1);
++
++ if (len > 0 && buf[0] == '/')
++ return g_strndup (buf, len);
++
++ /* If that didn't do it, try this hack */
++ if (len <= 0)
++ {
++ char *cwd, *working_dir = NULL;
++
++ cwd = g_get_current_dir ();
++ if (cwd != NULL)
++ {
++ /* On Solaris, readlink returns an empty string, but the
++ * link can be used as a directory, including as a target
++ * of chdir().
++ */
++ if (chdir (cwd_file) == 0)
++ {
++ working_dir = g_get_current_dir ();
++ chdir (cwd);
++ }
++ g_free (cwd);
++ }
++
++ if (working_dir)
++ return working_dir;
++ }
++ }
++
++ return NULL;
++}
++
+ static void
+ free_tag_data (TagData *tagdata)
+ {
+@@ -1738,75 +1791,57 @@ terminal_screen_get_dynamic_icon_title (TerminalScreen *screen)
+ * terminal_screen_get_current_dir:
+ * @screen:
+ *
+- * Returns: a newly allocated string containing the current working directory
+- * of the foreground process in @screen's PTY; or otherwise the initial working
+- * directory as set by terminal_screen_new()
++ * Tries to determine the current working directory of the foreground process
++ * in @screen's PTY, falling back to the current working directory of the
++ * primary child.
++ *
++ * Returns: a newly allocated string containing the current working directory,
++ * or %NULL on failure
+ */
+ char*
+ terminal_screen_get_current_dir (TerminalScreen *screen)
+ {
+- static const char patterns[][18] = {
+- "/proc/%d/cwd", /* Linux */
+- "/proc/%d/path/cwd", /* Solaris >= 10 */
+- };
+ TerminalScreenPrivate *priv = screen->priv;
+- int fgpid;
+- guint i;
+-
+- g_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
++ char *cwd;
++
++ if (priv->pty_fd != -1) {
++ /* Get the foreground process ID */
++ cwd = cwd_of_pid (tcgetpgrp (priv->pty_fd));
++ if (cwd != NULL)
++ return cwd;
++
++ /* If that didn't work, try falling back to the primary child. See bug #575184. */
++ cwd = cwd_of_pid (priv->child_pid);
++ if (cwd != NULL)
++ return cwd;
++ }
+
+- if (priv->pty_fd == -1)
+- return g_strdup (priv->initial_working_directory);
++ return NULL;
++}
+
+- /* Get the foreground process ID */
+- fgpid = tcgetpgrp (priv->pty_fd);
++/**
++ * terminal_screen_get_current_dir_with_fallback:
++ * @screen:
++ *
++ * Returns: a newly allocated string containing the current working directory
++ * of the foreground process in @screen's PTY; or otherwise the initial working
++ * directory as set by terminal_screen_new(), or %NULL if unable to determine
++ * the current working directory
++ */
++char*
++terminal_screen_get_current_dir_with_fallback (TerminalScreen *screen)
++{
++ TerminalScreenPrivate *priv = screen->priv;
++ char *cwd;
+
+- /* If that didn't work, try falling back to the primary child. See bug #575184. */
+- if (fgpid == -1)
+- fgpid = priv->child_pid;
++ cwd = terminal_screen_get_current_dir (screen);
++ if (cwd != NULL)
++ return cwd;
+
+- if (fgpid == -1)
++ if (priv->initial_working_directory != NULL)
+ return g_strdup (priv->initial_working_directory);
+
+- /* Try to get the working directory using various OS-specific mechanisms */
+- for (i = 0; i < G_N_ELEMENTS (patterns); ++i)
+- {
+- char cwd_file[64];
+- char buf[PATH_MAX + 1];
+- int len;
+-
+- g_snprintf (cwd_file, sizeof (cwd_file), patterns[i], fgpid);
+- len = readlink (cwd_file, buf, sizeof (buf) - 1);
+-
+- if (len > 0 && buf[0] == '/')
+- return g_strndup (buf, len);
+-
+- /* If that didn't do it, try this hack */
+- if (len <= 0)
+- {
+- char *cwd, *working_dir = NULL;
+-
+- cwd = g_get_current_dir ();
+- if (cwd != NULL)
+- {
+- /* On Solaris, readlink returns an empty string, but the
+- * link can be used as a directory, including as a target
+- * of chdir().
+- */
+- if (chdir (cwd_file) == 0)
+- {
+- working_dir = g_get_current_dir ();
+- chdir (cwd);
+- }
+- g_free (cwd);
+- }
+-
+- if (working_dir)
+- return working_dir;
+- }
+- }
+-
+- return g_strdup (priv->initial_working_directory);
++ return g_strdup (g_get_home_dir ());
+ }
+
+ void
+diff --git a/src/terminal-screen.h b/src/terminal-screen.h
+index efd5b3c..8b1e422 100644
+--- a/src/terminal-screen.h
++++ b/src/terminal-screen.h
+@@ -110,6 +110,7 @@ const char *terminal_screen_get_dynamic_title (TerminalScreen *screen);
+ const char *terminal_screen_get_dynamic_icon_title (TerminalScreen *screen);
+
+ char *terminal_screen_get_current_dir (TerminalScreen *screen);
++char *terminal_screen_get_current_dir_with_fallback (TerminalScreen *screen);
+
+ void terminal_screen_set_font (TerminalScreen *screen);
+ void terminal_screen_set_font_scale (TerminalScreen *screen,
+diff --git a/src/terminal-window.c b/src/terminal-window.c
+index 188bdd1..05e0af1 100644
+--- a/src/terminal-window.c
++++ b/src/terminal-window.c
+@@ -2807,7 +2807,7 @@ file_new_window_callback (GtkAction *action,
+
+ new_window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)));
+
+- new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
++ new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
+ terminal_app_new_terminal (app, new_window, profile,
+ NULL, NULL,
+ new_working_directory,
+@@ -2839,7 +2839,7 @@ file_new_tab_callback (GtkAction *action,
+ if (_terminal_profile_get_forgotten (profile))
+ return;
+
+- new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
++ new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
+ terminal_app_new_terminal (app, window, profile,
+ NULL, NULL,
+ new_working_directory,
diff --git a/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1.ebuild b/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1-r1.ebuild
index 755a6074e04e..d951ddd35b7a 100644
--- a/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1.ebuild
+++ b/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1.ebuild,v 1.1 2009/07/09 22:46:37 eva Exp $
+# $Header: /var/cvsroot/gentoo-x86/x11-terms/gnome-terminal/gnome-terminal-2.26.3.1-r1.ebuild,v 1.1 2009/08/28 16:27:47 mrpouet Exp $
inherit eutils gnome2
@@ -39,6 +39,10 @@ src_unpack() {
# Use login shell by default (#12900)
epatch "${FILESDIR}"/${PN}-2.22.0-default_shell.patch
+ # If we're logged in root on the first tab, don't open a new tab
+ # in user on /, fix bug #269318, import from upstream bug #565328.
+ epatch "${FILESDIR}"/${P}-cwd-on-new-tab.patch
+
# patch gnome terminal to report as GNOME rather than xterm
# This needs to resolve a few bugs (#120294,)
# Leave out for now; causing too many problems