Skip to content

Commit

Permalink
added writable permissions check for directories
Browse files Browse the repository at this point in the history
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 a1638dc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gpgdir
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@


use File::Find; use File::Find;
use File::Copy; use File::Copy;
use Fcntl qw/:mode/;
use IO::File; use IO::File;
use IO::Handle; use IO::Handle;
use Getopt::Long; use Getopt::Long;
Expand Down Expand Up @@ -1356,8 +1357,6 @@ sub check_file_criteria() {


### skip all links, zero size files, all hidden ### skip all links, zero size files, all hidden
### files (includes the .gnupg directory), etc. ### files (includes the .gnupg directory), etc.
return if -d $file;

unless ($force_mode) { unless ($force_mode) {
if ($file =~ m|/\.|) { if ($file =~ m|/\.|) {
print "[-] Skipping file: $file\n" print "[-] Skipping file: $file\n"
Expand All @@ -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 if (-e $file and not -l $file and -s $file != 0
and $file !~ m|\.gpgdir\.pid| and $file !~ m|\.gnupg|) { and $file !~ m|\.gpgdir\.pid| and $file !~ m|\.gnupg|) {
if ($encrypt_mode or $signing_mode) { if ($encrypt_mode or $signing_mode) {
Expand Down

0 comments on commit a1638dc

Please sign in to comment.