From 287ac0944055b30bf51fa9078316017d0b70cc45 Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Tue, 6 May 2014 15:01:07 +0400 Subject: [PATCH] Show all names and uri's --- Database.pm | 17 +++++++++++++++++ Password.pm | 6 +++--- pm.pl | 3 +-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Database.pm b/Database.pm index 501a86a..7dcfeae 100644 --- a/Database.pm +++ b/Database.pm @@ -41,8 +41,25 @@ sub mdo { # Select if ( $type eq 'select' ) { + + # Bad hack + if ( $name eq 'all' ) { + my $q = 'select name, resource, username from passwords'; + + my $sth = $dbh->prepare($q); + my $rv = $sth->execute(); + print "\nNAME\tRESOURCE\tUSERNAME\n"; + while ( my ( $name, $resource, $username ) + = $sth->fetchrow_array() ) + { + print "\n$name\t$resource\t$username\n"; + } + exit 0; + } + my $sth = $dbh->prepare($q); $sth->execute(); + my ( $name, $resource, $password ) = $sth->fetchrow_array(); my $q_hash = { diff --git a/Password.pm b/Password.pm index f6bbdeb..51db922 100644 --- a/Password.pm +++ b/Password.pm @@ -62,7 +62,7 @@ sub save { my $resource = $store->{resource}; my $password = $store->{password}; my $generate = $store->{gen}; - # my $username = $store->{username}; + my $username = defined($store->{username}) ? '' : ''; if ( $generate == 1 ) { $password = Password->generate(); @@ -71,8 +71,8 @@ sub save { # Decrypt database my $dec_db_file = $gpg->decrypt_db(); my $q - = "insert into passwords(name, resource, password) - values('$name', '$resource', '$password')"; + = "insert into passwords(name, resource, password, username) + values('$name', '$resource', '$password', '$username')"; my $mdo_q = { file => $dec_db_file, name => $name, diff --git a/pm.pl b/pm.pl index eb6925f..e998e6f 100755 --- a/pm.pl +++ b/pm.pl @@ -61,12 +61,11 @@ sub init() { my $pass = Password->new(); -# Don't use it's before GPG and Database if ( $pass->check_config() == 0 ) { exit 0; } -init() if $pass->check_config() == 1; +init(); my $copy = ClipPass->new();