File permissions fix

This commit is contained in:
Difrex(Denis Zheleztsov) 2014-05-12 11:25:39 +04:00
parent eb611a0f64
commit 820abf1636

16
GPG.pm
View File

@ -39,16 +39,14 @@ sub encrypt_db {
$recipient = $_;
}
@enc_cmd = (
"gpg", "--output", "$db",
"-a", "--recipient", "$recipient",
"--encrypt", "$file",
"gpg", "--output", "$db", "-a",
"--recipient", "$recipient", "--encrypt", "$file",
);
}
else {
# gpg --output test.gpg --encrypt test -a --default-recipient-self
@enc_cmd = (
"gpg", "--output", "$db",
"-a", "--default-recipient-self",
"gpg", "--output", "$db", "-a", "--default-recipient-self",
"--encrypt", "$file",
);
}
@ -60,6 +58,10 @@ sub encrypt_db {
@rm_cmd = ( "rm", "-f", "$file" );
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;
}
@ -81,6 +83,10 @@ sub decrypt_db {
@dec_cmd = ( "$gpg", "--output", "$file", "--decrypt", "$db" );
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;
}