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 ) {
|
if ( scalar @command > 0 ) {
|
||||||
my $command_string = join ' ', @command;
|
push @server, '--', @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"} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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";
|
die "Cannot exec ssh: $!\n";
|
||||||
} else { # server
|
} else { # server
|
||||||
my ( $ip, $port, $key );
|
my ( $ip, $port, $key );
|
||||||
@@ -240,3 +234,5 @@ if ( $pid == 0 ) { # child
|
|||||||
$ENV{ 'MOSH_PREDICTION_DISPLAY' } = $predict;
|
$ENV{ 'MOSH_PREDICTION_DISPLAY' } = $predict;
|
||||||
exec {$client} ($client, $ip, $port);
|
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() );
|
command[ 0 ] = strdup( argv0.c_str() );
|
||||||
fatal_assert( command[ 0 ] );
|
fatal_assert( command[ 0 ] );
|
||||||
|
|
||||||
if ( execv( executable.c_str(), command ) < 0 ) {
|
if ( execvp( executable.c_str(), command ) < 0 ) {
|
||||||
perror( "execve" );
|
perror( "execvp" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
|
|||||||
Reference in New Issue
Block a user