Exit 1 if pass not found

This commit is contained in:
Difrex 2016-02-08 19:11:37 +03:00
parent d7059449d9
commit a4a093c763
2 changed files with 10 additions and 2 deletions

View File

@ -161,7 +161,7 @@ sub generate {
my $digest; my $digest;
for (1..32) { for (1..32) {
open my $rnd, "<", "/dev/urandom"; open my $rnd, "<", "/dev/urandom";
read $rnd, $value, 1000; read $rnd, $value, 4096;
my $c = unpack( "H*", $value ); my $c = unpack( "H*", $value );
close $rnd; close $rnd;

10
pm.pl
View File

@ -46,6 +46,9 @@ 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};
print colored( "Password for $opt_n not found\n", 'red' ) and exit 1
if !($get_pass);
if ( defined( $ENV{'DISPLAY'} ) ) { if ( defined( $ENV{'DISPLAY'} ) ) {
$copy->copy($get_pass); $copy->copy($get_pass);
@ -72,7 +75,12 @@ if ( defined($opt_s) and defined($opt_g) ) {
elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) { elsif ( 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 );
$copy->copy( $get_h->{password} );
my $get_pass = $get_h->{password};
print colored( "Password for $opt_n not found\n", 'red' ) and exit 1
if !($get_pass);
$copy->copy( $get_pass );
# Open resource. # Open resource.
my @open_cmd = ( 'xdg-open', $get_h->{resource} ); my @open_cmd = ( 'xdg-open', $get_h->{resource} );