Permalink
Browse files

added writable permissions check for directories

git-svn-id: file:///home/mbr/svn/gpgdir_repos/gpgdir/trunk@358 958e171a-1414-0410-8e2f-9d295d3c0db0
  • Loading branch information...
mrash committed Apr 25, 2010
1 parent 8f084c4 commit a1638dc139da02f1ea386ff84dad85a82c81ea3e
Showing with 10 additions and 2 deletions.
  1. +10 −2 gpgdir
View
12 gpgdir
@@ -33,6 +33,7 @@
use File::Find;
use File::Copy;
+use Fcntl qw/:mode/;
use IO::File;
use IO::Handle;
use Getopt::Long;
@@ -1356,8 +1357,6 @@ sub check_file_criteria() {
### skip all links, zero size files, all hidden
### files (includes the .gnupg directory), etc.
- return if -d $file;
-
unless ($force_mode) {
if ($file =~ m|/\.|) {
print "[-] Skipping file: $file\n"
@@ -1366,6 +1365,15 @@ sub check_file_criteria() {
}
}
+ if (-d $file) {
+ ### skip all directories but only after we have verified
+ ### whether they are writable
+ unless ((stat($file))[2] & S_IWUSR) {
+ die "[*] Directory: '$file' is not writable by the current user.";
+ }
+ return;
+ }
+
if (-e $file and not -l $file and -s $file != 0
and $file !~ m|\.gpgdir\.pid| and $file !~ m|\.gnupg|) {
if ($encrypt_mode or $signing_mode) {

0 comments on commit a1638dc

Please sign in to comment.