The problem was with that specific keyserver. If I use another keyserver it
works. The keyserver was the first one returned to me by using the
keys.gnupg.net pool and as gpg 1 works with it.
I've debugged the issue.
The test case is now reduced to:
gpg2 --keyserver hkp://127.0.0.1 --search foobar
Dirmngr logs:
2014-11-26 20:35:55 dirmngr[5892.1] getnameinfo returned for '127.0.0.1':
'localhost'
2014-11-26 20:35:55 dirmngr[5892.1] can't connect to '127.0.0.1': Success
2014-11-26 20:35:55 dirmngr[5892.1] error connecting to
'http://127.0.0.1:11371': System error w/o errno
2014-11-26 20:35:55 dirmngr[5892.1] command 'KS_SEARCH' failed: System error w/o
errno
In my case this is because common/http.c (connect_server) ~ line 2200
Returns true for 127.0.0.1 (same for 75.75.183.132 which also explains why it
works with gnupg) the address is skipped but it is the only one -> loop finishes
with no errno set.
It is set in dirmngr/ks-engine-hkp.c which looks to me like: "If it is not
indicated that a host either uses IPv4 nor IPv6 ignore it." Which i find kind of
harsh. At least a debug output like:
Should be added there and of course connect_server should return an appropiate
error in case it never actually tried to connect to a server.
While debugging this I think I found another issue. You are using errno after
my_connect calls. If this expands to npth_connect the actual calls are
enter_npth()
sem_post() modifies errno
connect() modifies errno
leave_npth()
sem_wait() //modifies errno
Afaik enter / leave in npth should save errno. I could not confirm that this is
really an issue with a test but I think it is.