Description: Fix the build on non-Linux architectures. - make the CMSG_CONTROLDATA() macro work and introduce an lvalue equivalent - only use PTHREAD_MUTEX_ERRORCHECK when available - add two more kFreeBSD tests in the configure script - supply a third argument to open() with O_CREAT Forwarded: no Author: Peter Pentchev Last-Update: 2010-10-15 --- include/common.h +++ include/common.h @@ -338,8 +338,9 @@ * cast is necessary on AIX, due to buggy headers there? * needs additional testing on AIX, disable for now. */ -/* #define CMSG_CONTROLDATA(msg) ((struct cmsghdr *)((msg).msg_control)) */ -#define CMSG_CONTROLDATA(msg) ((msg).msg_control) +#define CMSG_CONTROLDATA(msg) ((struct cmsghdr *)((msg).msg_control)) +#define CMSG_CONTROLDATA_MUTABLE(msg) ((msg).msg_control) +/* #define CMSG_CONTROLDATA(msg) ((msg).msg_control) */ #else /* !HAVE_CMSGHDR */ #define CMSG_CONTROLDATA(msg) ((msg).msg_accrights) #endif /* HAVE_CMSGHDR */ --- lib/address.c +++ lib/address.c @@ -1047,8 +1047,10 @@ if (socks_pthread_mutexattr_init(&attr) != 0) serr(EXIT_FAILURE, "%s: mutexattr_init() failed", function); +#ifdef PTHREAD_MUTEX_ERRORCHECK if (socks_pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) swarn("%s: mutex_settype(PTHREAD_MUTEX_ERRORCHECK) failed", function); +#endif if (socks_pthread_mutex_init(&addrmutex, &attr) != 0) { swarn("%s: mutex_init() failed", function); --- lib/Rcompat.c +++ lib/Rcompat.c @@ -286,7 +286,7 @@ /* no cmsg on proxied sockets. */ CMSG_TOTLEN(*msg) = 0; - CMSG_CONTROLDATA(*msg) = NULL; + CMSG_CONTROLDATA_MUTABLE(*msg) = NULL; for (received = ioc = rc = 0; ioc < (size_t)msg->msg_iovlen; ++ioc) { /* LINTED pointer casts may be troublesome */ --- lib/util.c +++ lib/util.c @@ -874,7 +874,7 @@ if (strstr(newtemplate, "XXXXXX") != NULL) s = mkstemp(newtemplate); else - s = open(newtemplate, O_RDWR | O_CREAT | O_EXCL); + s = open(newtemplate, O_RDWR | O_CREAT | O_EXCL, 0600); if (s == -1) { swarn("%s: mkstemp(%s)", function, newtemplate);