Possible bug with spam permissions

Julian Field MailScanner at ecs.soton.ac.uk
Wed Aug 24 08:48:13 IST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 24 Aug 2005, at 08:26, Jan-Peter Koopmann wrote:

> 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. :-)

I don't agree. Your suggested code change will make the spam  
quarantine be owned by the user/group used for the /var/spool/ 
MailScanner/incoming directories, whereas it should be owned by the  
user/group used for the quarantine.
In MailScanner.conf, what are these set to:

Incoming Work User
Incoming Work Group
Quarantine User
Quarantine Group
MTA
Run As User
Run As Group
- -- 
Julian Field
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654


-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.2 (Build 2425)

iQA/AwUBQwwmQBH2WUcUFbZUEQLyhgCg0GAw4OyAJ7/HqF9ANwt9ZWcCXYgAnRUg
S20TN5wpZD43sNSLuMrrDeJU
=HGCj
-----END PGP SIGNATURE-----

------------------------ 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