Monthly Archives: February 2012

Debugging a segmentation fault on dnsmasq and fritzbox

I had an issue with my FRITZ!Box, running freetz and dnsmasq, where by dnsmasq would start and then crash after a few seconds. Since it was working fine before, I figured this must be an environmental issue. dnsmasq Log files were not showing anything helpful. That’s when I remembered strace. strace is a tool which displays all system calls a process makes. It could be used as a debugging tool to gain more insight into what the process was doing at the point which it crashed. So I ran strace on the process (before it crashed, so I had to be quick).

[code]
# strace -p 7845
[/code]

And I got my answer:

[code]
open("/var/tmp/multid.leases", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission denied)
— SIGSEGV (Segmentation fault) @ 0 (0) —
Process 7845 detached
[/code]

It was trying to access a file which had corrupted permissions, which was probably a situation not handled correctly in code. Resetting the permissions on that file fixed the issue.

501 5.5.4 Invalid Address when including Sender Name on Windows Server + PHP mail + IIS SMTP or MS Exchange

An interesting issue I came across the other day was that PHP was complaining giving a 501 5.5.4 Invalid Address error when trying to send email. The server uses IIS SMTP and the sender specified using the From: header ie
From: Me
Just specifying the email by itself works fine:
From: me@example.com

It turns out that this is a conflict between IIS SMTP and PHP. You need to specify a from email address separately by setting the ini configuration sendmail_from (for the MAIL FROM: command I presume) ie.

[php]
function mail2($from_address, $from_name, $to_address, $subject, $message, $headers) {
$old_sender = ini_get(‘sendmail_from’);
ini_set(‘sendmail_from’, $from_address);
$headers = "From: " . $from_name . " <" . $from_address . ">\r\n" . trim($headers);
mail($to_address, $subject, $message, $headers);
ini_set(‘sendmail_from’, $old_sender);
}
[/php]

Presumably this is not an issue on UNIX as the external sendmail program handles delivery.