local *_;
my $time_bar = time - 120;
- my @trash;
+ my @trash; my $badname_count = 0;
my %possible;
# Get list of all possible files from incoming dir.
#
# require acceptable filenames
unless (length($_) <= MAX_FILE_NAME_LEN && /^($RE_filename_here)$/) {
m/^(.*)$/; # untaint the value
- push @trash, File::Spec->catfile($directory, $1);
+ push @trash, File::Spec->catfile($directory, $1); $badname_count++;
# This is safe for unlink (which is all we will do with @trash)
# because the filename came from a directory entry, so it must be a
# valid filename and cannot indicate directory traversal.
or ftp_die("FATAL: closedir($directory) failed: $!");
# dispose of any garbage files
+ ftp_syslog('info', "$badname_count files with bogus names were trashcanned")
+ if $badname_count;
ftp_syslog('info', "Trashcanned files removed")
if unlink @trash;
@trash = (); # and empty the array to be safe, since it contained
set A(scan,$expect_out(1,string)) 1
exp_continue
}
+ -re {^gatekeeper\[[0-9]+\]: \(Test\)\
+ [0-9]+ files with bogus names were trashcanned} {
+ # from scan_incoming, reporting count of bad file names
+ exp_continue
+ }
-re {^gatekeeper\[[0-9]+\]: \(Test\)\
Trashcanned files removed} {
# from scan_incoming, when garbage files are purged