File permissions fix
This commit is contained in:
parent
eb611a0f64
commit
820abf1636
20
GPG.pm
20
GPG.pm
@ -33,22 +33,20 @@ sub encrypt_db {
|
|||||||
my @enc_cmd;
|
my @enc_cmd;
|
||||||
my $recipient;
|
my $recipient;
|
||||||
if ( -e $self->{_home} . "/.PM/.key" ) {
|
if ( -e $self->{_home} . "/.PM/.key" ) {
|
||||||
open my $key_f, "<" , $self->{_home} . "/.PM/.key"
|
open my $key_f, "<", $self->{_home} . "/.PM/.key"
|
||||||
or die "Cannot open file: $!\n";
|
or die "Cannot open file: $!\n";
|
||||||
while ( <$key_f> ) {
|
while (<$key_f>) {
|
||||||
$recipient = $_;
|
$recipient = $_;
|
||||||
}
|
}
|
||||||
@enc_cmd = (
|
@enc_cmd = (
|
||||||
"gpg", "--output", "$db",
|
"gpg", "--output", "$db", "-a",
|
||||||
"-a", "--recipient", "$recipient",
|
"--recipient", "$recipient", "--encrypt", "$file",
|
||||||
"--encrypt", "$file",
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# gpg --output test.gpg --encrypt test -a --default-recipient-self
|
# gpg --output test.gpg --encrypt test -a --default-recipient-self
|
||||||
@enc_cmd = (
|
@enc_cmd = (
|
||||||
"gpg", "--output", "$db",
|
"gpg", "--output", "$db", "-a", "--default-recipient-self",
|
||||||
"-a", "--default-recipient-self",
|
|
||||||
"--encrypt", "$file",
|
"--encrypt", "$file",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -60,6 +58,10 @@ sub encrypt_db {
|
|||||||
@rm_cmd = ( "rm", "-f", "$file" );
|
@rm_cmd = ( "rm", "-f", "$file" );
|
||||||
system(@rm_cmd) == 0 or die "Cannot remove file $file: $!\n";
|
system(@rm_cmd) == 0 or die "Cannot remove file $file: $!\n";
|
||||||
|
|
||||||
|
# Change file permissions
|
||||||
|
@chmod_cmd = ( "chmod", 600, $db );
|
||||||
|
system(@chmod_cmd) == 0 or die "Cannot chmod $file: $!\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,10 @@ sub decrypt_db {
|
|||||||
@dec_cmd = ( "$gpg", "--output", "$file", "--decrypt", "$db" );
|
@dec_cmd = ( "$gpg", "--output", "$file", "--decrypt", "$db" );
|
||||||
system(@dec_cmd) == 0 or die "Cannot decrypt $db: $!\n";
|
system(@dec_cmd) == 0 or die "Cannot decrypt $db: $!\n";
|
||||||
|
|
||||||
|
# Change file permissions
|
||||||
|
@chmod_cmd = ( "chmod", 600, $file );
|
||||||
|
system(@chmod_cmd) == 0 or die "Cannot chmod $file: $!\n";
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user