Start working on GPG module
This commit is contained in:
parent
2423a6d942
commit
dcb70474e3
14
Database.pm
14
Database.pm
@ -9,8 +9,11 @@ sub new {
|
|||||||
# Get home dir
|
# Get home dir
|
||||||
my $home = $ENV->{HOME};
|
my $home = $ENV->{HOME};
|
||||||
|
|
||||||
|
my $gpg = GPG->new();
|
||||||
|
|
||||||
my $self = {
|
my $self = {
|
||||||
_home => $home,
|
_home => $home,
|
||||||
|
_gpg => $gpg,
|
||||||
};
|
};
|
||||||
|
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
@ -39,18 +42,21 @@ sub create_base {
|
|||||||
|
|
||||||
# Check dir
|
# Check dir
|
||||||
if ( !( -d $pm_dir ) ) {
|
if ( !( -d $pm_dir ) ) {
|
||||||
|
|
||||||
# Create dirrectory
|
# Create dirrectory
|
||||||
@mkdir_cmd = ("mkdir", "$pm_dir");
|
my @mkdir_cmd = ( "mkdir", "$pm_dir" );
|
||||||
system(@mkdir_cmd) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
system(@mkdir_cmd) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
||||||
|
|
||||||
# Create DB file
|
# Create DB file
|
||||||
@createdb_cmd = ("touch", "$pm_dir/db.sqlite");
|
my @createdb_cmd = ( "touch", "$pm_dir/db.sqlite" );
|
||||||
system(@createdb_cmd) == 0 or die "Cannot create database file: $!\n";
|
system(@createdb_cmd) == 0 or die "Cannot create database file: $!\n";
|
||||||
|
|
||||||
# Create table. TODO: write this
|
# Create table. TODO: write this
|
||||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$pm_dir/db.sqlite","","");
|
my $dbh
|
||||||
|
= DBI->connect( "dbi:SQLite:dbname=$pm_dir/db.sqlite", "", "" );
|
||||||
print "Create database schema\n";
|
print "Create database schema\n";
|
||||||
my $q_table = "create table passwords(name VARCHAR(32), resource TEXT, password TEXT)";
|
my $q_table
|
||||||
|
= "create table passwords(name VARCHAR(32), resource TEXT, password TEXT)";
|
||||||
$dbh->do($q_table);
|
$dbh->do($q_table);
|
||||||
|
|
||||||
# Encrypt db
|
# Encrypt db
|
||||||
|
10
pm.pl
10
pm.pl
@ -44,11 +44,12 @@ EOF
|
|||||||
sub init() {
|
sub init() {
|
||||||
my $opt_string = 'swn:l:p:rhv';
|
my $opt_string = 'swn:l:p:rhv';
|
||||||
getopts("$opt_string") or usage();
|
getopts("$opt_string") or usage();
|
||||||
our ($opt_s, $opt_w, $opt_n, $opt_r,
|
our ( $opt_s, $opt_w, $opt_n, $opt_r, $opt_l, $opt_p, $opt_h, $opt_v );
|
||||||
$opt_l, $opt_p, $opt_h, $opt_v);
|
|
||||||
|
|
||||||
print "Simple password manager writed in Perl.\nVersion: ".
|
print "Simple password manager writed in Perl.\nVersion: "
|
||||||
$VERSION."\n" and exit 0 if $opt_v;
|
. $VERSION
|
||||||
|
. "\n" and exit 0
|
||||||
|
if $opt_v;
|
||||||
usage if $opt_h;
|
usage if $opt_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,5 +57,6 @@ sub init() {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
my $pass = Password->new();
|
my $pass = Password->new();
|
||||||
|
|
||||||
# Don't use it's before GPG and Database
|
# Don't use it's before GPG and Database
|
||||||
# $pass->check_config() == 0 or die "$!\n";
|
# $pass->check_config() == 0 or die "$!\n";
|
Loading…
Reference in New Issue
Block a user