Improvements to wrapper -- now runs user's shell

This commit is contained in:
Keith Winstein
2011-02-04 01:33:07 -05:00
parent 1b3972eac6
commit c4366234b1
2 changed files with 25 additions and 8 deletions
+24 -7
View File
@@ -17,6 +17,8 @@
#include <fcntl.h>
#include <sys/signalfd.h>
#include <termios.h>
#include <sys/types.h>
#include <pwd.h>
#include "parser.hpp"
#include "terminal.hpp"
@@ -30,9 +32,7 @@ int termemu( int host_fd, int src_fd, bool user, int debug_fd,
Parser::UTF8Parser *parser,
Terminal::Emulator *terminal );
int main( int argc,
char *argv[],
char *envp[] )
int main( int argc, char *argv[] )
{
int debug_fd;
if ( argc == 1 ) {
@@ -82,13 +82,30 @@ int main( int argc,
if ( child == 0 ) {
/* child */
char *my_argv[ 2 ];
my_argv[ 0 ] = strdup( "/bin/bash" );
assert( my_argv[ 0 ] );
if ( setenv( "TERM", "xterm", true ) < 0 ) {
perror( "setenv" );
exit( 1 );
}
/* ask ncurses to send UTF-8 instead of ISO 2022 for line-drawing chars */
if ( setenv( "NCURSES_NO_UTF8_ACS", "1", true ) < 0 ) {
perror( "setenv" );
exit( 1 );
}
/* get shell name */
struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) {
perror( "getpwuid" );
exit( 1 );
}
char *my_argv[ 2 ];
my_argv[ 0 ] = strdup( pw->pw_shell );
assert( my_argv[ 0 ] );
my_argv[ 1 ] = NULL;
if ( execve( "/bin/bash", my_argv, envp ) < 0 ) {
if ( execve( pw->pw_shell, my_argv, environ ) < 0 ) {
perror( "execve" );
exit( 1 );
}
+1 -1
View File
@@ -127,7 +127,7 @@ void Emulator::debug_printout( int fd )
screen.append( "\033[H" );
/* set window title */
screen.append( "\033]0;" );
screen.append( "\033]0;[rtm] " );
std::vector<wchar_t> window_title = fb.get_window_title();
for ( std::vector<wchar_t>::iterator i = window_title.begin();
i != window_title.end();