Show password to terminal if X is not runnig

This commit is contained in:
Denis(Difrex) Zheleztsov 2014-09-15 16:07:10 +04:00
parent 00338851fe
commit e9b88a0942

10
pm.pl
View File

@ -46,11 +46,21 @@ if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) {
my $get_h = $pass->show( $opt_n, $opt_u ); my $get_h = $pass->show( $opt_n, $opt_u );
my $get_pass = $get_h->{password}; my $get_pass = $get_h->{password};
if ( defined( $ENV{'DISPLAY'} ) ) {
$copy->copy($get_pass); $copy->copy($get_pass);
print colored("Password copied to xclipboard.", 'green'); print colored("Password copied to xclipboard.", 'green');
print "\nURI is "; print "\nURI is ";
print colored($get_h->{resource} . "\n", 'bold blue'); print colored($get_h->{resource} . "\n", 'bold blue');
}
else {
print colored("Warning! Password will show to terminal!", 'red');
print " Yes/No: ";
my $ans = <STDIN>;
chomp($ans);
print "$get_pass\n" if $ans eq "Yes";
print "Cancel\n" if $ans ne "Yes";
}
} }
elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) { elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {