dequis/bitlbee — pull request #10 by dequis (2014-06-13 11:41:03+00:00)
Title: Fix srv_lookup issues on cygwin (and other platforms)

Patch by jcopenha

Trac ticket: http://bugs.bitlbee.org/bitlbee/ticket/1098

Blocked by overlap with openbsd SRV issues: http://bugs.bitlbee.org/bitlbee/ticket/1003

Original description follows

----

The srv_lookup routine in lib/misc.c always returns zero responses on Cygwin. It is configured to do this because the ns_initparse and ns_parserr routines are not provided on Cygwin. Because srv_lookup always returns zero results Jabber accounts where the server does not match the @server.com portion of the username have to explicitly set a server name. This means that you can not do tls_verify on those accounts. For instance, username@gmail.com with a srv_lookup fail must set server name to talk.google.com. But Google returns a certificate for gmail.com which the verify code thinks is the wrong server because it
does not match the server name.

This patch does 3 things.

1. It changes the configure script to check for res_qeruy and dn_expandname when looking for libresolv. It also has a new check for ns_initparse and ns_initparserr to see if libresolv or libc provides
them.

2. It changes the lib/misc.c srv_lookup routine to use dn_expandname instead of the custom code. This allows srv_lookup to process compressed names correctly. Cygwin res_query returns a compressed name and since bitlbee already requires libresolv this seems like the more correct solution.

3. It adds lib/ns_parse.c to provide ns_initparse and ns_parserr on platforms where those were not detected at ./configure time. This is a copy of a file from libbind-6.0 source with the copyright still in place and just minor modification. Removal of two functions that bitlbee does not use and added some #ifdefds and #include “bittlbee.h”. Reading the copyright/license notice I believe this is acceptable.

The end goal of this patch is to allow me to set up a Jabber account with username@gmail.com and tls_verify to true.