Opera, HELO_LOCALHOST, and /etc/hosts vs /etc/hostname

I just found a really annoying bug/problem in Opera Mail (submitted as Bug #323363). I'm not sure how many other users are affected.
For a while now, each e-mail I sent from my laptop had been marked as spam by the SpamAssassin installation running on our departments mail server. Thus, many people's mail client put my e-mails into the Suspect-Mail folder, hiding them from plain view.
SpamAssassin has a rule called HELO_LOCALHOST which is triggered if the sending host authenticated itself as localhost. As I could see from the e-mail headers this rule caused every one of my e-mails to be marked as spam.
But why did Opera authenticate as localhost to the SMTP server? My /etc/hostname file contains the correct name of my laptop, and running the hostname command returns the same name. Where did this localhost come from.
After some investigation, I found the culprit: /etc/hosts. It had as the first line:

127.0.0.1   localhost   my_hostname

This is absolutely correct. The same format (containing localhsot and the real hostname) can be found on many (all?) other (Debian) Linux systems.
For some stupid reason, Opera used the first hostname entry for the loopback interface in /etc/hosts for authentication. That seems twice stupid to me. First, Opera should read /etc/hostname for determining the hostname, not /etc/hosts. And, second, Opera should not use the entry for the loopback interface, as it is not even used for sending the e-mail.

Workaround: Change the order of the names for the 127.0.0.1 line in /etc/hosts, so that the first name is not localhost but the actual name of your computer.

Leave a comment

1 Comment

  1. anonymous

     /  June 21, 2011

    Anonymous writes:/etc/hostname is a non-standard file, /etc/hosts is.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: