From a4a093c763def2ff7424c4b67d4b1abafc9e7899 Mon Sep 17 00:00:00 2001 From: Difrex Date: Mon, 8 Feb 2016 19:11:37 +0300 Subject: [PATCH] Exit 1 if pass not found --- Password.pm | 2 +- pm.pl | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Password.pm b/Password.pm index ace4b32..1e8e36d 100644 --- a/Password.pm +++ b/Password.pm @@ -161,7 +161,7 @@ sub generate { my $digest; for (1..32) { open my $rnd, "<", "/dev/urandom"; - read $rnd, $value, 1000; + read $rnd, $value, 4096; my $c = unpack( "H*", $value ); close $rnd; diff --git a/pm.pl b/pm.pl index 84ac2e7..3753b44 100755 --- a/pm.pl +++ b/pm.pl @@ -45,6 +45,9 @@ if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) { my $get_h = $pass->show( $opt_n, $opt_u ); 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'} ) ) { $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) ) { 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. my @open_cmd = ( 'xdg-open', $get_h->{resource} );