Commit 219ea41b authored by Christian Persch's avatar Christian Persch
Browse files

Export vte_get_user_shell()

Bug #642184. Also fixes bug #640179.
parent de22ca4f
......@@ -98,6 +98,9 @@ vte_terminal_search_get_wrap_around
vte_terminal_search_set_gregex
vte_terminal_search_set_wrap_around
<SUBSECTION>
vte_get_user_shell
<SUBSECTION>
vte_terminal_fork_command
vte_terminal_fork_command_full
......
......@@ -105,7 +105,7 @@ libvte@VTE_LIBRARY_SUFFIX_U@_la_LIBADD = $(VTE_LIBS)
libvte@VTE_LIBRARY_SUFFIX_U@_la_LDFLAGS = \
$(VTE_LDFLAGS) \
-version-info $(LT_VERSION_INFO) \
-export-symbols-regex "^vte_terminal_.*|^vte_pty_.*|^_vte_pty_.*|^vte_reaper_.*|_vte_debug_.*" \
-export-symbols-regex "^vte_terminal_.*|^vte_pty_.*|^vte_get_.*|^_vte_pty_.*|^vte_reaper_.*|_vte_debug_.*" \
@LIBTOOL_EXPORT_OPTIONS@ @LIBTOOL_FLAGS@ \
$(AM_LDFLAGS)
......
......@@ -3674,46 +3674,40 @@ vte_terminal_watch_child (VteTerminal *terminal,
g_object_thaw_notify(object);
}
/*
* _vte_terminal_get_user_shell:
/**
* vte_get_user_shell:
*
* Uses getpwd() to determine the user's shell. If that fails, falls back
* to using the SHELL environment variable. As last-ditch fallback, returns
* "/bin/sh".
* Gets the user's shell, or %NULL. In the latter case, the
* system default (usually "/bin/sh") should be used.
*
* Returns: a newly allocated string containing the command to run the
* user's shell
* Returns: (tranfer full) (type filename): a newly allocated string with the
* user's shell, or %NULL
*/
static char *
_vte_terminal_get_user_shell (void)
char *
vte_get_user_shell (void)
{
struct passwd *pwd;
char *command;
pwd = getpwuid(getuid());
if (pwd != NULL) {
command = g_strdup (pwd->pw_shell);
_vte_debug_print(VTE_DEBUG_MISC,
"Using user's shell (%s).\n",
command ? command : "(null)");
}
if (command == NULL) {
if (g_getenv ("SHELL")) {
command = g_strdup (g_getenv ("SHELL"));
_vte_debug_print(VTE_DEBUG_MISC,
"Using $SHELL shell (%s).\n",
command);
} else {
command = g_strdup ("/bin/sh");
_vte_debug_print(VTE_DEBUG_MISC,
"Using default shell (%s).\n",
command);
}
}
if (pwd && pwd->pw_shell)
return g_strdup (pwd->pw_shell);
return NULL;
}
static char *
_vte_terminal_get_user_shell_with_fallback (void)
{
char *command;
const gchar *env;
if ((command = vte_get_user_shell ()))
return command;
g_assert (command != NULL);
if ((env = g_getenv ("SHELL")))
return g_strdup (env);
return command;
return g_strdup ("/bin/sh");
}
/*
......@@ -3737,7 +3731,7 @@ _vte_terminal_get_argv (const char *command,
char **argv2;
char *shell = NULL;
argv2 = __vte_pty_get_argv(command ? command : (shell = _vte_terminal_get_user_shell()),
argv2 = __vte_pty_get_argv(command ? command : (shell = _vte_terminal_get_user_shell_with_fallback ()),
argv,
flags);
g_free(shell);
......
......@@ -483,6 +483,8 @@ const char *vte_terminal_get_status_line(VteTerminal *terminal);
void vte_terminal_set_pty_object(VteTerminal *terminal, VtePty *pty);
VtePty *vte_terminal_get_pty_object(VteTerminal *terminal);
char *vte_get_user_shell (void);
/* Accessors for bindings. */
#if !GTK_CHECK_VERSION (2, 91, 2)
GtkAdjustment *vte_terminal_get_adjustment(VteTerminal *terminal);
......
......@@ -994,6 +994,9 @@ main(int argc, char **argv)
_VTE_DEBUG_IF(VTE_DEBUG_MISC)
vte_terminal_feed(terminal, message, -1);
if (command == NULL || *command == '\0')
command = vte_get_user_shell ();
if (command == NULL || *command == '\0')
command = g_getenv ("SHELL");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment