Comments support
This commit is contained in:
parent
f75822471b
commit
844b817b14
20
Database.pm
20
Database.pm
@ -44,26 +44,32 @@ sub mdo {
|
||||
|
||||
# Bad hack
|
||||
if ( $name eq 'all' ) {
|
||||
my $q = 'select id, name, resource, username from passwords';
|
||||
my $q
|
||||
= 'select id, name, resource, username, comment from passwords';
|
||||
|
||||
my $sth = $dbh->prepare($q);
|
||||
my $rv = $sth->execute();
|
||||
|
||||
use Term::ANSIColor;
|
||||
printf "%-11s %-11s %-11s %-11s\n",
|
||||
printf "%-11s %-11s %-11s %-11s %-11s\n",
|
||||
colored( "ID", 'white' ),
|
||||
colored( "NAME", 'magenta' ),
|
||||
colored( "RESOURCE", 'blue' ),
|
||||
colored( "USERNAME", 'green' );
|
||||
print "=========================\n";
|
||||
while ( my ( $id, $name, $resource, $username )
|
||||
colored( "USERNAME", 'green' ),
|
||||
colored( "COMMENT", 'yellow' );
|
||||
print "=================================\n";
|
||||
while ( my ( $id, $name, $resource, $username, $comment )
|
||||
= $sth->fetchrow_array() )
|
||||
{
|
||||
printf "%-11s %-11s %-11s %-11s\n",
|
||||
if ( !defined($comment) ) {
|
||||
$comment = '';
|
||||
}
|
||||
printf "%-11s %-11s %-11s %-11s %-11s\n",
|
||||
colored( $id, 'white' ),
|
||||
colored( $name, 'magenta' ),
|
||||
colored( $resource, 'blue' ),
|
||||
colored( $username, 'green' );
|
||||
colored( $username, 'green' ),
|
||||
colored( $comment, 'yellow' );
|
||||
}
|
||||
|
||||
# Remove unencrypted file
|
||||
|
14
Password.pm
14
Password.pm
@ -68,8 +68,8 @@ sub remove {
|
||||
|
||||
# Decrypt database
|
||||
my $dec_db_file = $gpg->decrypt_db();
|
||||
my $q = "delete from passwords where id=$id";
|
||||
my $mdo_q = {
|
||||
my $q = "delete from passwords where id=$id";
|
||||
my $mdo_q = {
|
||||
file => $dec_db_file,
|
||||
query => $q,
|
||||
type => 'do',
|
||||
@ -91,6 +91,12 @@ sub save {
|
||||
my $resource = $store->{resource};
|
||||
my $password = $store->{password};
|
||||
|
||||
# Comment check
|
||||
my $comment = '';
|
||||
if ( defined( $store->{comment} ) ) {
|
||||
$comment = $store->{comment};
|
||||
}
|
||||
|
||||
# Username check
|
||||
my $username = '';
|
||||
if ( defined( $store->{username} ) ) {
|
||||
@ -99,8 +105,8 @@ sub save {
|
||||
|
||||
# Decrypt database
|
||||
my $dec_db_file = $gpg->decrypt_db();
|
||||
my $q = "insert into passwords(name, resource, password, username)
|
||||
values('$name', '$resource', '$password', '$username')";
|
||||
my $q = "insert into passwords(name, resource, password, username, comment)
|
||||
values('$name', '$resource', '$password', '$username', '$comment')";
|
||||
my $mdo_q = {
|
||||
file => $dec_db_file,
|
||||
name => $name,
|
||||
|
3
Usage.pm
3
Usage.pm
@ -17,6 +17,7 @@ Simple password manager writed in Perl.
|
||||
-w store new password
|
||||
-l [Link] link to resource
|
||||
-u username
|
||||
-c comment
|
||||
-p [Password] password
|
||||
if key not selected PM generate secure password
|
||||
and copy it to xclipboard
|
||||
@ -40,7 +41,7 @@ Examples:
|
||||
\tPassword copied to clipboard. Trying to open uri.
|
||||
|
||||
Store new password:
|
||||
\tpm.pl -w -n PRON -l http://superpronsite.com/ -p my_secret_password
|
||||
\tpm.pl -w -n PRON -l http://superpronsite.com/ -p my_secret_password -c 'Most viewed site'
|
||||
\tPassword for resource PRON is stored into DB!
|
||||
|
||||
Remove password:
|
||||
|
9
pm.pl
9
pm.pl
@ -15,11 +15,11 @@ our $VERSION = '0.0.1-beta1';
|
||||
my $usage = Usage->new();
|
||||
|
||||
sub init() {
|
||||
my $opt_string = 'swn:l:p:rhvou:i:';
|
||||
my $opt_string = 'swn:l:p:rhvou:i:c:';
|
||||
getopts("$opt_string") or $usage->show();
|
||||
our (
|
||||
$opt_s, $opt_w, $opt_n, $opt_r, $opt_l, $opt_p,
|
||||
$opt_h, $opt_v, $opt_o, $opt_u, $opt_i,
|
||||
$opt_h, $opt_v, $opt_o, $opt_u, $opt_i, $opt_c,
|
||||
);
|
||||
|
||||
print "Simple password manager writed in Perl.\nVersion: "
|
||||
@ -73,6 +73,7 @@ elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {
|
||||
print $get_h->{resource} . "\n";
|
||||
print color 'reset';
|
||||
}
|
||||
|
||||
# Remove string from db
|
||||
elsif ( defined($opt_r) and defined($opt_i) ) {
|
||||
|
||||
@ -98,10 +99,11 @@ elsif ( defined($opt_w)
|
||||
resource => $opt_l,
|
||||
password => $opt_p,
|
||||
username => $opt_u,
|
||||
comment => $opt_c,
|
||||
};
|
||||
|
||||
$pass->save($store_h) == 0 or die "Oops! 105: pm.pl. $!\n";
|
||||
$copy->copy( $opt_p );
|
||||
$copy->copy($opt_p);
|
||||
print color 'green';
|
||||
print "Password was stored into DB!\n";
|
||||
print color 'reset';
|
||||
@ -120,6 +122,7 @@ elsif ( defined($opt_w)
|
||||
password => $opt_p,
|
||||
gen => 0,
|
||||
username => $opt_u,
|
||||
comment => $opt_c,
|
||||
};
|
||||
|
||||
$pass->save($store_h) == 0 or die "Oops! 122: pm.pl. $!\n";
|
||||
|
Loading…
Reference in New Issue
Block a user