PDA

View Full Version : Direct Admin + Exim 'unseen' problem [dirty fix]


Klopper
05-19-2008, 09:12 AM
I've had a problem with sending mails to support@domain.com (using the pipe). Every time someone sent a mail to the E-mailaddress, it came in the database TWICE and the user got 2 messages saying it's ticket has been added...
After a small investigation I found out that the problem is related to Direct Admin and Exim. Exim.conf has a certain (security-)patch that's a problem with the piping-method of any (web-based) system.
The problem lies here:
virtual_aliases_nostar:
driver = redirect
allow_defer
allow_fail
data = ${if exists{/etc/virtual/${domain}/aliases}{${lookup{$local_part}lsearch{/etc/virtual/${domain}/aliases}}}}
file_transport = address_file
group = mail
pipe_transport = virtual_address_pipe
retry_use_local_part
unseen
#include_domain = trueMany webhosts don't want to comment out the 'unseen'-rule out because of a security-issue... So I wrote my own piece of code to find a way around the double 'mailing'. (ALL HAIL OPEN SOURCE :D)
$sql = mysql_query("SELECT * FROM `ost_ticket` WHERE
`email` = '" . mysql_real_escape_string($var['email']) . "' AND
`subject` = '" . mysql_real_escape_string($var['subject']) . "' AND
`name` = '" . mysql_real_escape_string($var['name']) . "'
ORDER BY `ticket_id` DESC LIMIT 1");

if(mysql_num_rows($sql) != 0)
{
$row = mysql_fetch_assoc($sql);
$sql2 = mysql_query("SELECT * FROM `ost_ticket_message` WHERE
`ticket_id` = '" . mysql_real_escape_string($row['ticket_id']) . "' AND
`message` = '" . mysql_real_escape_string($var['message']) . "' AND
`headers` = '" . mysql_real_escape_string($var['header']) . "'
LIMIT 1");

if(mysql_num_rows($sql2) != 0)
api_exit(EX_SUCCESS);
}You can paste this part between "$ticlet=null;" (yeah, Peter Rotich left a typo here :p) and "if(ereg ("[[][#][0-9]{1,10}[]]",$var['subject'],$regs)) {".

This is a quick and dirty fix!

I hope this piece of code can help people with the same problem at Direct Admin + Exim OR any other system with the same problem.