Startup script quoting cleanups per Anders Kaseorg
This commit is contained in:
+4
-8
@@ -197,16 +197,10 @@ if ( $pid == 0 ) { # child
|
||||
}
|
||||
|
||||
if ( scalar @command > 0 ) {
|
||||
my $command_string = join ' ', @command;
|
||||
$command_string =~ s'\$'\$'g;
|
||||
$command_string =~ s'`'\`'g;
|
||||
$command_string =~ s'"'\"'g;
|
||||
$command_string =~ s'\\'\\'g;
|
||||
|
||||
push @server, ( '--', '/bin/sh', '-c', qq{"$command_string"} );
|
||||
push @server, '--', @command;
|
||||
}
|
||||
|
||||
exec 'ssh', '-S', 'none', '-o', "ProxyCommand=$0 --fake-proxy -- %h %p", '-t', $userhost, '--', @server;
|
||||
exec 'ssh', '-S', 'none', '-o', "ProxyCommand=$0 --fake-proxy -- %h %p", '-t', $userhost, '--', shell_quote( @server );
|
||||
die "Cannot exec ssh: $!\n";
|
||||
} else { # server
|
||||
my ( $ip, $port, $key );
|
||||
@@ -240,3 +234,5 @@ if ( $pid == 0 ) { # child
|
||||
$ENV{ 'MOSH_PREDICTION_DISPLAY' } = $predict;
|
||||
exec {$client} ($client, $ip, $port);
|
||||
}
|
||||
|
||||
sub shell_quote { join ' ', map {(my $a = $_) =~ s/'/'\\''/g; "'$a'"} @_ }
|
||||
|
||||
@@ -316,8 +316,8 @@ int run_server( const char *desired_ip, const char *desired_port,
|
||||
command[ 0 ] = strdup( argv0.c_str() );
|
||||
fatal_assert( command[ 0 ] );
|
||||
|
||||
if ( execv( executable.c_str(), command ) < 0 ) {
|
||||
perror( "execve" );
|
||||
if ( execvp( executable.c_str(), command ) < 0 ) {
|
||||
perror( "execvp" );
|
||||
exit( 1 );
|
||||
}
|
||||
exit( 0 );
|
||||
|
||||
Reference in New Issue
Block a user