diff --git a/auth-juniper.c b/auth-juniper.c index 30ceb3aee80c5bf7c74df81a93bd5c2490d0fd62..7c92b2d90899236d40da11505d4e872bf1cdb8a7 100644 --- a/auth-juniper.c +++ b/auth-juniper.c @@ -344,7 +344,7 @@ static int tncc_preauth(struct openconnect_info *vpninfo) struct oc_vpn_option *cookie; const char *dspreauth = NULL, *dssignin = "null"; char recvbuf[1024], *p; - int len; + int len, flags; for (cookie = vpninfo->cookies; cookie; cookie = cookie->next) { if (!strcmp(cookie->option, "DSPREAUTH")) @@ -368,11 +368,21 @@ static int tncc_preauth(struct openconnect_info *vpninfo) _("Failed to allocate memory for communication with TNCC\n")); return buf_free(buf); } + +#ifdef __APPLE__ + // Equally, you cannot use SOCK_SEQPACKET with AF_UNIX on Mac OS + // https://stackoverflow.com/questions/13287333/sock-seqpacket-availability + + flags = SOCK_STREAM; +#else + flags = SOCK_SEQPACKET; +#endif + #ifdef SOCK_CLOEXEC - if (socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockfd)) + if (socketpair(AF_UNIX, flags | SOCK_CLOEXEC, 0, sockfd)) #endif { - if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockfd)) { + if (socketpair(AF_UNIX, flags, 0, sockfd)) { buf_free(buf); return -errno; }