diff -ruN mimedefang-2.72/mimedefang.pl.in mimedefang-2.72-KAM/mimedefang.pl.in --- mimedefang-2.72/mimedefang.pl.in Wed Jun 22 09:53:52 2011 +++ mimedefang-2.72-KAM/mimedefang.pl.in Mon Sep 5 12:01:22 2011 @@ -543,6 +543,22 @@ $year + 1900, $mon+1, $mday, $hour, $min, $sec); } +#*********************************************************************** +# %PROCEDURE: short_time_str +# %ARGUMENTS: +# None +# %RETURNS: +# The current time in the form: "YYYY-MM-DD-HH" +# %DESCRIPTION: +# Returns a string representing the current date and hour +#*********************************************************************** +sub short_time_str () { + my($sec, $min, $hour, $mday, $mon, $year, $junk); + ($sec, $min, $hour, $mday, $mon, $year, $junk) = localtime(time()); + return sprintf("%04d-%02d-%02d-%02d", + $year + 1900, $mon+1, $mday, $hour); +} + { # Reworked detection/usage of Sys::Syslog or Unix::Syslog as # appropriate is mostly borrowed from Log::Syslog::Abstract, to which @@ -1371,15 +1387,40 @@ my($success) = 0; my($tm); $tm = time_str(); + + my($short_tm); + $short_tm = short_time_str(); + $QuarantineSubdir = sprintf("%s/%s", + $Features{'Path:QUARANTINEDIR'}, $short_tm); + + #Create a subdir of the YYYY-MM-DD-HH to prevent a 32K limit for ext3 + unless (-d $QuarantineSubdir) { + if (mkdir($QuarantineSubdir, 0750)) { + $success = 1; + } + + if (!$success) { + md_syslog('err', "$MsgID: Error creating quarantine directory [$QuarantineSubdir] '$!'"); + #Due to race conditions where two slaves can try and create the same dir, we can check to see if it has been created again + if ($! =~ /File exists/i && -d $QuarantineSubdir) { + #NOTHING + } else { + $QuarantineSubdir = ""; + return ""; + } + } + } + do { $counter++; - $QuarantineSubdir = sprintf("%s/qdir-%s-%03d", - $Features{'Path:QUARANTINEDIR'}, $tm, $counter); + $QuarantineSubdir = sprintf("%s/%s/qdir-%s-%03d", + $Features{'Path:QUARANTINEDIR'}, $short_tm, $tm, $counter); if (mkdir($QuarantineSubdir, 0750)) { $success = 1; } } while(!$success && ($tries++ < 1000)); if (!$success) { + md_syslog('err', "$MsgID: Error creating quarantine directory [$QuarantineSubdir] '$!'"); $QuarantineSubdir = ""; return ""; }