~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to contrib/cleanup-partial.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
# ---- Settings ----
4
 
# TemporaryDirectory in clamd.conf
5
 
my $TMPDIR='/tmp';
6
 
# How long to wait for next part of RFC1341 message (seconds)
7
 
my $cleanup_interval=3600;
8
 
 
9
 
# ---- End of Settings ----
10
 
 
11
 
my $partial_dir = "$TMPDIR/clamav-partial";
12
 
#  if there is no partial directory, nothing to clean up
13
 
opendir(DIR, $partial_dir) || exit 0;
14
 
 
15
 
my $cleanup_threshold = time - $cleanup_interval;
16
 
while(my $file = readdir(DIR)) {
17
 
        next unless $file =~ m/^clamav-partial-([0-9]+)_[0-9a-f]{32}-[0-9]+$/;
18
 
        my $filetime = $1;
19
 
        unlink "$partial_dir/$file" unless $filetime > $cleanup_threshold;
20
 
}
21
 
closedir DIR;