\n";
}
# dump_directories(&dump)
sub dump_directories
{
if (!&multiple_directory_support($_[0]->{'fs'})) {
return $_[0]->{'dir'};
}
elsif ($_[0]->{'tabs'}) {
return split(/\t+/, $_[0]->{'dir'});
}
else {
return split(/\s+/, $_[0]->{'dir'});
}
}
# run_ssh_command(command, output-fh, output-mode, password)
# Run some command and display it's output, possibly providing a password
# if one is requested
sub run_ssh_command
{
local ($cmd, $fh, $fhmode, $pass) = @_;
&foreign_require("proc", "proc-lib.pl");
local ($cfh, $fpid) = &proc::pty_process_exec_logged($cmd);
local ($wrong_password, $got_login, $connect_failed);
local $out;
local $stars = ("*" x length($pass));
while(1) {
local $rv = &wait_for($cfh, "password:|Password\\s+for\\s+\\S+:", "yes\\/no", "(^|\\n)\\s*Permission denied.*\n", "ssh: connect.*\n", ".*\n");
if ($wait_for_input !~ /^\s*DUMP:\s+ACLs\s+in\s+inode/i) {
$wait_for_input =~ s/\Q$pass\E/$stars/g;
if ($fhmode) {
print $fh &html_escape($wait_for_input);
}
else {
print $fh $wait_for_input;
}
}
if ($rv == 0) {
syswrite($cfh, "$pass\n");
}
elsif ($rv == 1) {
syswrite($cfh, "yes\n");
}
elsif ($rv == 2) {
$wrong_password++;
last;
}
elsif ($rv == 3) {
$connect_failed++;
}
elsif ($rv < 0) {
last;
}
}
close($cfh);
local $got = waitpid($fpid, 0);
return $?;
}
# rsh_command_input(selname, textname, value)
# Returns HTML for selecting an rsh command
sub rsh_command_input
{
local ($selname, $textname, $rsh) = @_;
local $ssh = &has_command("ssh");
local $r = $ssh && $rsh eq $ssh ? 1 :
$rsh eq $ftp_cmd ? 3 :
$rsh ? 2 : 0;
local @opts = ( $r == 0 ? ( [ 0, $text{'dump_rsh0'} ] ) : ( ),
[ 1, $text{'dump_rsh1'} ],
[ 3, $text{'dump_rsh3'} ] );
if ($r == 2) {
push(@opts, [ 2, $text{'dump_rsh2'}." ".
&ui_textbox($textname, $rsh, 30) ]);
}
return &ui_radio($selname, $r, \@opts);
}
# rsh_command_parse(selname, textname)
# Returns the rsh command to use for a backup/restore, based on %in
sub rsh_command_parse
{
local ($selname, $textname) = @_;
if ($in{$selname} == 0) {
return undef;
}
elsif ($in{$selname} == 1) {
local $ssh = &has_command("ssh");
$ssh || &error($text{'dump_essh'});
return $ssh;
}
elsif ($in{$selname} == 3) {
return $ftp_cmd;
}
else {
$in{$textname} =~ /^(\S+)/ && &has_command("$1") ||
&error($text{'dump_ersh'});
return $in{$textname};
}
}
1;
|