Bug 5566 - Access denied writing to tmp file
Summary: Access denied writing to tmp file
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 3.2.1
Hardware: All Linux
: P3 normal
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-18 12:51 UTC by Diego Pomatta
Modified: 2018-03-23 22:45 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Pomatta 2007-07-18 12:51:46 UTC
spamd reports
warn: util: secure_tmpfile failed to create file
'/root/tmp/.spamassassin7688bq4Fdstmp': Permission denied

...followed by a series of warnings about working on closed filehandle $tmpfile

spamd is running as root
/root/tmp permissions are 770
TMPDIR=/root/tmp

Apparently the failure to create the temp file should have been caught but it
wasn't.
Comment 1 Theo Van Dinter 2007-07-18 13:30:31 UTC
it's worth noting that when this came up (on the users@ list iirc), it was
specifically related to the Message code using temp files for non-text raw
parts.  it appeared, based on the errors, that even if secure_tmpfile() failed,
Message continued on assuming the file existed, thereby causing a bunch of other
errors to pop up later on if that part was accessed.

the code looks like it's doing the right thing, but then why do the errors come
up? :)   so we should verify the issue anyway.


  if ($msg->{'type'} !~ m@^(?:text/(?:plain|html)$|message\b)@) {
    my $filepath;
    ($filepath, $msg->{'raw'}) = Mail::SpamAssassin::Util::secure_tmpfile();

    if ($filepath) {
      # The temp file was created, add it to the list of pending deletions
      # we cannot just delete immediately in the POSIX idiom, as this is
      # unportable (to win32 at least)
      push @{$self->{tmpfiles}}, $filepath;
      $msg->{'raw'}->print(@{$body});
    }
  }

  # if the part didn't get a temp file, go ahead and store the data in memory
  if (!exists $msg->{'raw'}) {
    $msg->{'raw'} = $body;
  }
Comment 2 Giovanni Bechis 2018-03-23 22:45:43 UTC
This part of code has been changed during those 10 years and those errors should now be catched.