MailScanner / v5

MailScanner v5
GNU General Public License v2.0
188 stars 60 forks source link

Exim v4.97 #672

Closed chirpy2605 closed 10 months ago

chirpy2605 commented 1 year ago

Exim v4.97 has changed the length of the Message-ID, this breaks mail delivery in MailScanner.

As noted on the MailScanner mailing list, the magic number 19 used in EximDiskStore.pm needs to be changed to 26 in 3 locations. There is an additional subroutine that needs to change:

sub OutQDir {
  my $name = shift;

  if (MailScanner::Config::Value('spliteximspool')) {
    return '/' . substr($name,-13,1) . '/';
  } else {
    return '/';
  }
}

This is determining which of the exim split spools to place the new message. In exim this is determined by the 6th character of the Message-ID.

For the magic number 19, 19 - 13 = 6

Now that exim is using magic number 26, this needs changing so that 26 - 20 = 6, otherwise the email goes into the wrong split spool directory and exim ignores it. So it needs to change to:

sub OutQDir {
  my $name = shift;

  if (MailScanner::Config::Value('spliteximspool')) {
    return '/' . substr($name,-20,1) . '/';
  } else {
    return '/';
  }
}

I also changed all the references (3) from 19 to 26. As a serious workaround hack I stored these changes in a different perl module name and tested the exim version in the main MailScanner script:

if (/exim/i) {
  $MTAmod = 'Exim.pm';
  $MTADSmod = 'EximDiskStore.pm';
  my @out = `exim -bV`;
  my @line = split(/ /, $out[0]);
  my $ver = $line[2];
  $ver =~ /\d+\.\d+/;
  if ($ver >= 4.97) {
    $MTAmod = 'Exim.pm';
    $MTADSmod = 'EximDiskStoreNew.pm';
  }
}
github-actions[bot] commented 1 year ago

Thank you for submitting your first issue to MailScanner! We will respond to you soon!

shawniverson commented 1 year ago

@chirpy2605 I like how you are pulling the exim version. I would like to adapt this in a way that two nearly identical EximDiskStore.pm files are not needed. Maybe check the version and store the value in a config variable, then check it inside of EximDiskStore.pm to conditionally choose the right values for the Message-ID handling.