tests/servers: generate temp names in /tmp for unix domain sockets

... instead of putting them in the regular pid directories because
systems generally have strict length requirements for the path name to
be shorter than 107 bytes and we easily hit that boundary otherwise.

The new concept generates two random names: one for the socks daemon and
one for http.

Reported-by: Andy Fiddaman
Fixes #11152
Closes #11166
This commit is contained in:
Daniel Stenberg 2023-05-20 17:56:37 +02:00
parent f4b5c88ab7
commit 8cf4189529
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 13 additions and 5 deletions

View File

@ -42,7 +42,7 @@ socks5unix
HTTP GET via SOCKS5 proxy via unix sockets
</name>
<command>
--socks5 localhost%PWD/%SOCKSUNIXPATH http://%HOSTIP:%HTTPPORT/%TESTNUMBER
--socks5 localhost%SOCKSUNIXPATH http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>

View File

@ -43,7 +43,7 @@ socks5unix
HTTP GET with host name using SOCKS5h via unix sockets
</name>
<command>
http://this.is.a.host.name:%HTTPPORT/%TESTNUMBER --proxy socks5h://localhost%PWD/%SOCKSUNIXPATH
http://this.is.a.host.name:%HTTPPORT/%TESTNUMBER --proxy socks5h://localhost%SOCKSUNIXPATH
</command>
</client>

View File

@ -45,7 +45,7 @@ socks5unix
HTTPS GET with host name using SOCKS5h via unix sockets
</name>
<command>
https://this.is.a.host.name:%HTTPSPORT/%TESTNUMBER -k --proxy socks5h://localhost%PWD/%SOCKSUNIXPATH
https://this.is.a.host.name:%HTTPSPORT/%TESTNUMBER -k --proxy socks5h://localhost%SOCKSUNIXPATH
</command>
</client>

View File

@ -180,11 +180,19 @@ sub getfreeport {
return $server->sockport();
}
use File::Temp qw/ tempfile/;
#######################################################################
# Initialize configuration variables
sub initserverconfig {
$SOCKSUNIXPATH = "$LOGDIR/$PIDDIR/socks.sock"; # SOCKS Unix domain socket
$HTTPUNIXPATH = "$LOGDIR/$PIDDIR/http.sock"; # HTTP Unix domain socket
my ($fh, $socks) = tempfile("/tmp/curl-socksd-XXXXXXXX");
close($fh);
unlink($socks);
my ($f2, $http) = tempfile("/tmp/curl-http-XXXXXXXX");
close($f2);
unlink($http);
$SOCKSUNIXPATH = $socks; # SOCKS Unix domain socket
$HTTPUNIXPATH = $http; # HTTP Unix domain socket
$stunnel = checkcmd("stunnel4") || checkcmd("tstunnel") || checkcmd("stunnel");
# get the name of the current user