Startup script quoting cleanups per Anders Kaseorg

This commit is contained in:
Keith Winstein
2012-03-21 17:19:12 -04:00
parent 4eb3cace0b
commit 6842dbf066
2 changed files with 6 additions and 10 deletions
+4 -8
View File
@@ -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'"} @_ }