6914801: IPv6 unavailable if stdin is a socket

Reviewed-by: michaelm
This commit is contained in:
Daniel Jeliński 2023-01-09 07:39:12 +00:00
parent d03a5d9580
commit 8d17d1ee6f
7 changed files with 177 additions and 38 deletions

View file

@ -123,18 +123,7 @@ jint IPv6_supported()
*/
return JNI_FALSE;
}
/*
* If fd 0 is a socket it means we may have been launched from inetd or
* xinetd. If it's a socket then check the family - if it's an
* IPv4 socket then we need to disable IPv6.
*/
if (getsockname(0, &sa.sa, &sa_len) == 0) {
if (sa.sa.sa_family == AF_INET) {
close(fd);
return JNI_FALSE;
}
}
close(fd);
/**
* Linux - check if any interface has an IPv6 address.
@ -147,13 +136,11 @@ jint IPv6_supported()
char *bufP;
if (fP == NULL) {
close(fd);
return JNI_FALSE;
}
bufP = fgets(buf, sizeof(buf), fP);
fclose(fP);
if (bufP == NULL) {
close(fd);
return JNI_FALSE;
}
}
@ -164,7 +151,6 @@ jint IPv6_supported()
* we should also check if the APIs are available.
*/
ipv6_fn = JVM_FindLibraryEntry(RTLD_DEFAULT, "inet_pton");
close(fd);
if (ipv6_fn == NULL ) {
return JNI_FALSE;
} else {