version 1.1.1.2, 2013/10/14 07:51:15
|
version 1.1.1.3, 2021/03/17 00:32:36
|
Line 1
|
Line 1
|
#!/usr/bin/perl | #!/usr/bin/env perl |
# This script can be used as a "remote shell" command that is only | # This is a "local shell" command that works like a remote shell but only for |
# capable of pretending to connect to "localhost". This is useful | # the local host. See the usage message for more details. |
# for testing or for running a local copy where the sender and the | |
# receiver needs to use different options (e.g. --fake-super). If | |
# we get -l USER, we try to become the USER, either directly (must | |
# be root) or by using "sudo -H -u USER" (requires --sudo option). | |
|
|
use strict; |
use strict; |
use warnings; |
use warnings; |
Line 26 my $host = shift;
|
Line 22 my $host = shift;
|
if ($host =~ s/^([^@]+)\@//) { |
if ($host =~ s/^([^@]+)\@//) { |
$login_name = $1; |
$login_name = $1; |
} |
} |
if ($host ne 'localhost') { | if ($host eq 'lh') { |
| $no_chdir = 1; |
| } elsif ($host ne 'localhost') { |
die "lsh: unable to connect to host $host\n"; |
die "lsh: unable to connect to host $host\n"; |
} |
} |
|
|
Line 76 die "Failed to exec: $!\n";
|
Line 74 die "Failed to exec: $!\n";
|
sub usage |
sub usage |
{ |
{ |
die <<EOT; |
die <<EOT; |
Usage: lsh [-l user] [--sudo] [--no-cd] localhost COMMAND [...] | Usage: lsh [-l USER] [--sudo] [--no-cd] localhost COMMAND [...] |
| |
| This is a "local shell" command that works like a remote shell but only for the |
| local host. This is useful for rsync testing or for running a local copy where |
| the sender and the receiver need to use different options (e.g. --fake-super). |
| If the -l option is used, we try to become the USER, either directly (when |
| root) or by using "sudo -H -u USER" (requires --sudo option). |
| |
| Note that if you pass hostname "lh" instead of "localhost" that the --no-cd |
| option is implied. The default is to "cd \$HOME" to simulate ssh behavior. |
EOT |
EOT |
} |
} |