/usr/share/perl5/Object/Remote/Prompt.pm is in libobject-remote-perl 0.004000-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | package Object::Remote::Prompt;
use strictures 1;
use IO::Handle;
use Exporter;
our @EXPORT = qw(prompt prompt_pw);
our ($prompt, $prompt_pw);
sub _local_prompt {
_local_prompt_core(0, @_);
}
sub _local_prompt_pw {
_local_prompt_core(1, @_);
}
our %Prompt_Cache;
sub _local_prompt_core {
my ($pw, $message, $default, $opts) = @_;
if ($opts->{cache} and my $hit = $Prompt_Cache{$message}) {
return $hit;
}
STDOUT->autoflush(1);
system('stty -echo') if $pw;
print STDOUT "${message}: ";
chomp(my $res = <STDIN>);
print STDOUT "\n" if $pw;
system('stty echo') if $pw;
$Prompt_Cache{$message} = $res if $opts->{cache};
return $res;
}
sub prompt {
die "User input wanted - $_[0] - but no prompt available"
unless $prompt;
goto &$prompt;
}
sub prompt_pw {
die "User input wanted - $_[0] - but no password prompt available"
unless $prompt_pw;
goto &$prompt_pw;
}
if (-t STDIN) {
$prompt = \&_local_prompt;
$prompt_pw = \&_local_prompt_pw;
}
sub set_local_prompt_command {
($prompt, $prompt_pw) = @_;
return;
}
sub maybe_set_prompt_command_on {
return unless $prompt;
my ($conn) = @_;
$conn->remote_sub('Object::Remote::Prompt::set_local_prompt_command')
->($prompt, $prompt_pw);
}
1;
|