Re: [Tails-dev] [urgent] Tails 0.12 test results (we've got …

Delete this message

Reply to this message
Author: Maxim Kammerer
Date:  
To: The Tails public development discussion list
Subject: Re: [Tails-dev] [urgent] Tails 0.12 test results (we've got a potential blocker)
Hi,

On Wed, Jun 13, 2012 at 4:46 PM, anonym <anonym@???> wrote:
> Yup. I've opened bugs/claws_with_torsocks_leaks_hostname to track this
> issue.


This is possibly not a bug with torsocks, but a result of its extended
functionality. Claws-Mail 3.8.0, when used with set_domain=0, uses its
get_domain_name() function (in compose.c) to retrieve the domain name.
get_domain_name() (commons/utils.c) calls gethostname() to retrieve
the current hostname, and then calls gethostbyname() to get the
canonical hostname. I couldn't find /etc/hosts in Tails' git, but I
guess that it contains something like:

127.0.0.1 localhost amnesia

When gethostbyname() is called on "amnesia", it will consider
"localhost" as the canonical name (h_name). tsocks doesn't change that
behavior. However, torsocks forwards gethostbyname() over Tor, fails
("amnesia" fails to resolve on an exit node), and then Claws-Mail's
get_domain_name() uses the original gethostname() result as a fallback
(and you should see perror("gethostbyname") on stderr). Note that
tsocks can also forward gethostbyname() via SOCKS, but it apparently
doesn't do that for "local" hostnames.

Feel free to explore the sample code below (emulating Claws-Mail's
behavior) with torsocks/tsocks:

#define _BSD_SOURCE

#include <unistd.h>
#include <stdio.h>
#include <netdb.h>

int main() {
char s[256];
struct hostent *hp;

  if (!gethostname(s, sizeof(s))) {
    printf("hostname: %s\n", s);


    if ((hp = gethostbyname(s)))
      printf("h_name: %s\n", hp->h_name);
    else
      herror("gethostbyname");
  }
  else
    perror("gethostname");


return 0;
}

--
Maxim Kammerer
Liberté Linux: http://dee.su/liberte