Possible bug with spam permissions

Jan-Peter Koopmann Jan-Peter.Koopmann at SECEIDOS.DE
Wed Aug 24 08:26:37 IST 2005


    [ The following text is in the "iso-8859-1" character set. ]
    [ Your display is set for the "US-ASCII" character set.  ]
    [ Some characters may be displayed incorrectly. ]

On Tuesday, August 23, 2005 4:48 PM Julian Field wrote:

> I'm having a bit of a stupid day. What do you mean by "GID: 6 0 6"
> and what is wrong? And which chown are you talking about? I don't see
> your point at all. 

OK, let me start over:

Setup: 
Run as Group = mail
Quarantine Group = getqmail

Problem:
Quarantined virus (etc.) mail is created under 

/var/spool/Mailscanner/quarantine/date/Message-ID/...

The group of those directories and the files in them is correct: getqmail. So far so good. But:

Quarantined spam mail is created under

/var/spool/Mailscanner/quarantine/date/spam/...

The directory belongs to the correct group (getqmail) but the spam mails in there belong to group mail. Which clearly is wrong. Now I debugged a bit in Message.pm and found the following bits of code:

 
>>   # Store it if they want that
>>   if ($actions{'store'}) {
>>     my($dir, $dir2, $spamdir, $uid, $gid, $changeowner);
>>     $uid = $global::MS->{quar}->{uid};
>>     $gid = $global::MS->{quar}->{gid};
>>     $changeowner = $global::MS->{quar}->{changeowner};
>>     $dir = MailScanner::Config::Value('quarantinedir', $this);
>>     #$dir2 = $dir . '/' .  MailScanner::Quarantine::TodayDir();
>>     $dir2 = $dir . '/' .  $this->{datenumber};
>>     $spamdir = $dir2 . '/' . $HamSpam;
>>     #print STDERR "dir = $dir\ndir2 = $dir2\nspamdir = $spamdir\n";
>>     umask $global::MS->{quar}->{dirumask};
>>     unless (-d $dir) {
>>       mkdir $dir, 0777;
>>       chown $uid, $gid, $dir if $changeowner;
>>     }
>>     unless (-d $dir2) {
>>       mkdir $dir2, 0777;
>>       chown $uid, $gid, $dir2 if $changeowner;
>>     }
>>     unless (-d $spamdir) {
>>     mkdir $spamdir, 0777;
>>       chown $uid, $gid, $spamdir if $changeowner;
>>     }
>>     #print STDERR "Storing spam to $spamdir/" . $this->{id} . "\n";
>>     #print STDERR "uid=$uid gid=$gid changeowner=$changeowner\n";
>>     umask $global::MS->{quar}->{fileumask};
>>     my @paths = $this->{store}->CopyEntireMessage($this, $spamdir,
>>                                                   $this->{id}, $uid,
>>     $gid, $changeowner); # Remember where we have stored the spam in
>>     an archive, so we never # archive infected messages
>>     #print STDERR "Added " . join(',', @paths) . " to spamarchive\n";
>>     push @{$this->{spamarchive}}, @paths;
>>     chown $uid, $gid, "$spamdir/" . $this->{id}; # Harmless if this
>>   fails }
>>   umask 0077; # Safety net

If I understand this correctly, this code stores spam-mails. The third last row reads

chown $uid, $gid, "$spamdir/" . $this->{id}; 

I put

Print STDERR "UID: $uid / GID: $gid\n";

in front of it and debugged it. The result was:

UID: 26 / GID: 6 0 6

uid 26 corresponds to user mailnull --> correct
Gid 6 (no idea where the 0 6 come from) corresponds to group mail --> incorrect. This definately explains why stored spam mails have the wrong group however. I suspect the broken part of the code is this:

>>     $uid = $global::MS->{quar}->{uid};
>>     $gid = $global::MS->{quar}->{gid};

Which should probably read something like this

$uid = $workarea->{uid};
$gid = $workarea->{gid};

In order to get the correct Ids from the config file. The next remaining question would be, why GID equals "6 0 6" and not only one "6". I have no idea. :-)

Kind regards,
  JP

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!



More information about the MailScanner mailing list