FIXED: Re: can't open tmpfile: Invalid argument

Julian Field mailscanner at
Tue Dec 30 16:30:20 GMT 2003

I have finally found a workaround for this problem. It appears to be a bug
in some BSD systems where the new_tmpfile call doesn't work properly, and
gives an "invalid argument" error in some circumstances.
The solution for now is to patch your as follows:

---      2003-12-30 15:24:48.000000000 +0000
+++  2003-12-30 15:25:43.000000000 +0000
@@ -820,6 +820,7 @@
    $parser->extract_uuencode(1); # uue is off by default
    $parser->output_to_core('NONE'); # everything into files
+  $parser->tmp_to_core(1); # For machines with buggy IO::File::new_tmpfile()

    # Create the message stream
    # NOTE: This still uses the real path of the message body file.
@@ -838,7 +839,7 @@
      waitpid $pid, 0;
      MailScanner::Log::WarnLog("Cannot parse " . $this->{headerspath} . "
and " .
-                 $this->{dpath} . ", $@");
+                 $this->{store}{dpath} . ", $@");
      $this->{entity} = $entity; # In case it failed due to too many
      $this->{cantparse} = 1;
      $this->{otherinfected} = 1;

The first change is the actual patch, the 2nd change fixes the error
message so it says what I intended.
The only drawback is that unpacking a large attachment may use a lot of
virtual memory temporarily, so make sure you have plenty of swap configured
in your system. I have tested the patch briefly and it doesn't appear to
cause any other problems with other MailScanner functionality.

So if you keep getting these "Cannot parse" errors, apply the patch above.
Should work with virtually any revision of MailScanner version 4.


At 21:07 28/12/2003, you wrote:
>Please Help!
>We have used MailScanner with no problem until we upgraded to FreeBSD 5.0
>from 4.8.
>Now we are getting this message in our logs and outgoing email is not
>delivered. We searched the archives and have seen several others with
>similar problem. Please advise if there is any solution to this problem,
>MailScanner has been a fantastic solution for us but downgrading back to
>4.8 is not an option.
>Cannot parse /var/spool/MailScanner/incoming/15871/hBSKjl87015878.header
>and , MIME::Parser: can't open tmpfile: Invalid argument
>Any advice is greatly appreciated!

Julian Field
Professional Support Services at
MailScanner thanks transtec Computers for their support
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654

More information about the MailScanner mailing list