1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-02 06:03:50 +00:00

Fix build on 9.x.

This commit is contained in:
Hiroki Sato 2016-06-14 07:39:24 +00:00
parent b3876a8558
commit c7753f7164
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=416877
3 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,52 @@
--- ipc.c.orig 2016-02-17 21:02:06 UTC
+++ ipc.c
@@ -50,9 +50,22 @@ int ipc_server_init(void)
if (server_sd >= 0)
close(server_sd);
+#ifdef SOCK_CLOEXEC
server_sd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+#else
+ server_sd = socket(AF_UNIX, SOCK_STREAM, 0);
+#endif
if (server_sd < 0)
return -1;
+#ifndef SOCK_CLOEXEC
+ if (fcntl(server_sd, F_SETFD, FD_CLOEXEC) < 0) {
+ int err = errno;
+ close(server_sd);
+ server_sd = -1;
+ errno = err;
+ return server_sd;
+ }
+#endif
#ifdef HAVE_SOCKADDR_UN_SUN_LEN
sa.sun_len = 0; /* <- correct length is set by the OS */
@@ -89,10 +102,26 @@ int ipc_client_init(void)
if (client_sd >= 0)
close(client_sd);
+#ifdef SOCK_CLOEXEC
client_sd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+#else
+ client_sd = socket(AF_UNIX, SOCK_STREAM, 0);
+#endif
if (client_sd < 0)
return -1;
+#ifndef SOCK_CLOEXEC
+ if (fcntl(client_sd, F_SETFD, FD_CLOEXEC) < 0) {
+ int err = errno;
+
+ close(client_sd);
+ client_sd = -1;
+
+ errno = err;
+ return -1;
+ }
+#endif
+
#ifdef HAVE_SOCKADDR_UN_SUN_LEN
sa.sun_len = 0; /* <- correct length is set by the OS */
#endif

View File

@ -0,0 +1,50 @@
--- mcgroup.c.orig 2016-02-17 21:02:06 UTC
+++ mcgroup.c
@@ -54,11 +54,23 @@ static struct iface *find_valid_iface(co
static void mcgroup4_init(void)
{
if (mcgroup4_socket < 0) {
+#ifdef SOCK_CLOEXEC
mcgroup4_socket = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+#else
+ mcgroup4_socket = socket(AF_INET, SOCK_DGRAM, 0);
+#endif
if (mcgroup4_socket < 0) {
smclog(LOG_ERR, "Failed creating socket for joining IPv4 multicast groups: %m");
exit(255);
}
+#ifndef SOCK_CLOEXEC
+ if (fcntl(mcgroup4_socket, F_SETFD, FD_CLOEXEC) < 0) {
+ smclog(LOG_WARNING, "Failed creating socket for joining IPv4 multicast groups: %m");
+ close(mcgroup4_socket);
+ mcgroup4_socket = -1;
+ return;
+ }
+#endif
#ifdef __linux__
if (setsockopt(mcgroup4_socket, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0)
@@ -132,11 +144,23 @@ static int mcgroup6_socket = -1;
static void mcgroup6_init(void)
{
if (mcgroup6_socket < 0) {
+#ifdef SOCK_CLOEXEC
mcgroup6_socket = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
+#else
+ mcgroup6_socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+#endif
if (mcgroup6_socket < 0) {
smclog(LOG_WARNING, "Failed creating socket for joining IPv6 multicast groups: %m");
return;
}
+#ifndef SOCK_CLOEXEC
+ if (fcntl(mcgroup6_socket, F_SETFD, FD_CLOEXEC) < 0) {
+ smclog(LOG_WARNING, "Failed creating socket for joining IPv6 multicast groups: %m");
+ close(mcgroup6_socket);
+ mcgroup6_socket = -1;
+ return;
+ }
+#endif
#ifdef __linux__
if (setsockopt(mcgroup6_socket, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0)

View File

@ -0,0 +1,55 @@
--- mroute-api.c.orig 2016-02-17 21:02:06 UTC
+++ mroute-api.c
@@ -98,13 +98,26 @@ int mroute4_enable(void)
unsigned int i;
struct iface *iface;
+#ifdef SOCK_CLOEXEC
mroute4_socket = socket(AF_INET, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_IGMP);
+#else
+ mroute4_socket = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
+#endif
if (mroute4_socket < 0) {
if (ENOPROTOOPT == errno)
smclog(LOG_WARNING, "Kernel does not support IPv4 multicast routing, skipping ...");
return -1;
}
+#ifndef SOCK_CLOEXEC
+ if (fcntl(mroute4_socket, F_SETFD, FD_CLOEXEC) < 0) {
+ smclog(LOG_INIT, "Failed initializing IPv4 multicast routing API: %m");
+ close(mroute4_socket);
+ mroute4_socket = -1;
+
+ return -1;
+ }
+#endif
if (setsockopt(mroute4_socket, IPPROTO_IP, MRT_INIT, (void *)&arg, sizeof(arg))) {
switch (errno) {
@@ -472,12 +485,25 @@ int mroute6_enable(void)
unsigned int i;
struct iface *iface;
+#ifdef SOCK_CLOEXEC
if ((mroute6_socket = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_ICMPV6)) < 0) {
+#else
+ if ((mroute6_socket = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
+#endif
if (ENOPROTOOPT == errno)
smclog(LOG_WARNING, "Kernel does not support IPv6 multicast routing, skipping ...");
return -1;
}
+#ifndef SOCK_CLOEXEC
+ if (fcntl(mroute6_socket, F_SETFD, FD_CLOEXEC) < 0) {
+ smclog(LOG_INIT, "Failed initializing IPv6 multicast routing API: %m");
+ close(mroute6_socket);
+ mroute6_socket = -1;
+
+ return -1;
+ }
+#endif
if (setsockopt(mroute6_socket, IPPROTO_IPV6, MRT6_INIT, (void *)&arg, sizeof(arg))) {
switch (errno) {
case EADDRINUSE: