Created
February 19, 2021 14:20
-
-
Save holishing/2d94033592c35b5c7c08572889adabf1 to your computer and use it in GitHub Desktop.
tmp workaround for dreambbs docker not working in pure ipv4 env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b0c620994d90522ef00309b94d53091e063516f7 Mon Sep 17 00:00:00 2001 | |
From: "0@0" <test@test> | |
Date: Fri, 19 Feb 2021 22:18:29 +0800 | |
Subject: [PATCH] Revert "fix(IPv6 socket): fix misuse of AF_UNSPEC for server | |
socket" | |
This reverts commit 2e3fe5fc1e462b7e2bb75ff071b09cfa4e850c65. | |
--- | |
innbbsd/channel.c | 2 +- | |
maple/bbsd.c | 10 ++++------ | |
maple/talk.c | 5 +++-- | |
maple/xchatd.c | 9 ++++----- | |
4 files changed, 12 insertions(+), 14 deletions(-) | |
diff --git a/innbbsd/channel.c b/innbbsd/channel.c | |
index c031494..3f75639 100644 | |
--- a/innbbsd/channel.c | |
+++ b/innbbsd/channel.c | |
@@ -238,7 +238,7 @@ initinetserver(void) | |
struct linger foobar; | |
char port_str[12]; | |
- hints.ai_family = AF_INET6; | |
+ hints.ai_family = AF_UNSPEC; | |
hints.ai_socktype = SOCK_STREAM; | |
hints.ai_protocol = IPPROTO_TCP; | |
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_NUMERICSERV | AI_PASSIVE; | |
diff --git a/maple/bbsd.c b/maple/bbsd.c | |
index 34f5bb8..93eeb62 100644 | |
--- a/maple/bbsd.c | |
+++ b/maple/bbsd.c | |
@@ -1440,6 +1440,7 @@ static int start_daemon(int argc, char *const argv[]) | |
#endif | |
char buf[80], data[80]; | |
int fd; | |
+ bool listen_success = false; | |
int port; | |
@@ -1563,7 +1564,7 @@ static int start_daemon(int argc, char *const argv[]) | |
} | |
else | |
{ | |
- hints.ai_family = AF_INET6; | |
+ hints.ai_family = AF_UNSPEC; | |
hints.ai_socktype = SOCK_STREAM; | |
hints.ai_protocol = IPPROTO_TCP; | |
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_NUMERICSERV | AI_PASSIVE; | |
@@ -1610,7 +1611,6 @@ static int start_daemon(int argc, char *const argv[]) | |
if ((bind(fd, host->ai_addr, host->ai_addrlen) < 0) || (listen(fd, QLEN) < 0)) | |
{ | |
close(fd); | |
- fd = -1; | |
continue; | |
} | |
@@ -1619,13 +1619,11 @@ static int start_daemon(int argc, char *const argv[]) | |
chown(unix_path, BBSUID, WWWGID); | |
chmod(unix_path, 0660); | |
} | |
- | |
- /* Success */ | |
- break; | |
+ listen_success = true; | |
} | |
if (port != -2) | |
freeaddrinfo(hosts); | |
- if (fd < 0) | |
+ if (!listen_success) | |
exit(1); | |
/* --------------------------------------------------- */ | |
diff --git a/maple/talk.c b/maple/talk.c | |
index ef65d7e..e651d04 100644 | |
--- a/maple/talk.c | |
+++ b/maple/talk.c | |
@@ -2868,9 +2868,10 @@ talk_page( | |
} | |
#endif | |
- hints.ai_family = AF_INET6; | |
+ hints.ai_family = AF_UNSPEC; | |
hints.ai_socktype = SOCK_STREAM; | |
- hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_NUMERICSERV | AI_PASSIVE; | |
+ hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_NUMERICSERV; | |
+ hints.ai_flags |= AI_PASSIVE; | |
if (getaddrinfo(NULL, "0", &hints, &hs)) | |
return -1; | |
diff --git a/maple/xchatd.c b/maple/xchatd.c | |
index a6eaa75..bb08973 100644 | |
--- a/maple/xchatd.c | |
+++ b/maple/xchatd.c | |
@@ -3003,6 +3003,7 @@ servo_daemon( | |
#ifdef RLIMIT | |
struct rlimit limit; | |
#endif //RLIMIT | |
+ bool listen_success = false; | |
/* | |
* More idiot speed-hacking --- the first time conversion makes the C | |
@@ -3073,7 +3074,7 @@ servo_daemon( | |
/* bind the service port */ | |
/* --------------------------------------------------- */ | |
- hints.ai_family = AF_INET6; | |
+ hints.ai_family = AF_UNSPEC; | |
hints.ai_socktype = SOCK_STREAM; | |
hints.ai_protocol = IPPROTO_TCP; | |
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_NUMERICSERV | AI_PASSIVE; | |
@@ -3110,15 +3111,13 @@ servo_daemon( | |
(listen(fd, SOCK_QLEN) < 0)) | |
{ | |
close(fd); | |
- fd = -1; | |
continue; | |
} | |
- /* Success */ | |
- break; | |
+ listen_success = true; | |
} | |
freeaddrinfo(hosts); | |
- if (fd < 0) | |
+ if (!listen_success) | |
exit(1); | |
return fd; | |
-- | |
2.27.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment