mtrojnar / osslsigncode

OpenSSL based Authenticode signing for PE/MSI/Java CAB files
Other
731 stars 124 forks source link

tests fail to stop server if localhost also resolves to IPv6 address (::1) #331

Closed mbunkus closed 6 months ago

mbunkus commented 6 months ago

osslsigncode v2.7

Building on Arch Linux with:

cmake -B . -S "../osslsigncode-2.7" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
make
ctest Release

yields the following error during testing:

        Start 173: stop_server
173/174 Test #173: stop_server .......................***Failed    0.02 sec

Testing/Temporary/LastTest.log contains:

173/174 Test: stop_server
Command: "/usr/bin/python3.11" "/home/mosu/packaging/mosu-arch/maintained/osslsigncode/src/build/Testing/client_http.py"
Directory: /home/mosu/packaging/mosu-arch/maintained/osslsigncode/src/build
"stop_server" start time: Dec 21 11:04 CET
Output:
----------------------------------------------------------
OSError: [Errno 111] Connection refused
<end of output>
Test time =   0.02 sec
----------------------------------------------------------
Test Failed.
"stop_server" end time: Dec 21 11:04 CET
"stop_server" time elapsed: 00:00:00

The server is still running, though, and the logged port number is correct:

[0 mosu@sweet-chili (master) ~/packaging/mosu-arch/maintained/osslsigncode/src/build] cat Testing/logs/port.log
41327%                                                                                                                                                                                                                                                                                                                         [0 mosu@sweet-chili (master) ~/packaging/mosu-arch/maintained/osslsigncode/src/build] lsof -PniTCP:41327
COMMAND       PID USER FD   TYPE   DEVICE SIZE/OFF NODE NAME
python3.1 1417355 mosu 4u  IPv4 43429788      0t0  TCP 127.0.0.1:41327 (LISTEN)

This is due to Testing/client_http.py trying to connect to localhost, which on my machine (and most likely a lot of others) resolves to both 127.0.0.1 & ::1. The client then tries to connect via IPv6 while server only listens on the IPv4 address. The result is the observed connection refused.

One solution is to change client_http.py to try to connect to 127.0.0.1 instead of localhost. It seems that there's no easy way to let ThreadingHTTPServer bind to both IPv4 & IPv6 when using localhost as the address, unfortunately.

mtrojnar commented 6 months ago

Is this issue also reproducible with the current GitHub master branch?

mbunkus commented 6 months ago

It sure is. See full build & test output here.

mbunkus commented 6 months ago

Thank you very much for fixing it so quickly.

mtrojnar commented 6 months ago

Thank you very much for such a good report.