Finally getting around to trying out nc on some more platforms for LibreSSL-portable, and ran into Sun/Oracle's silly definition of 'sun' in the system headers. OK to rename the local sockaddr_un variables?
Portable contains a patch full of #ifdef's around other systems-specific nc features (e.g. rdomain support). I'm not sure if any of those should also move into cvs or stay in the portable patch. Index: netcat.c =================================================================== RCS file: /cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.143 diff -u -p -u -p -r1.143 netcat.c --- netcat.c 13 Nov 2015 18:13:13 -0000 1.143 +++ netcat.c 22 Nov 2015 22:26:08 -0000 @@ -643,7 +643,7 @@ main(int argc, char *argv[]) int unix_bind(char *path, int flags) { - struct sockaddr_un sun; + struct sockaddr_un s_un; int s; /* Create unix domain socket. */ @@ -651,17 +651,17 @@ unix_bind(char *path, int flags) 0)) < 0) return (-1); - memset(&sun, 0, sizeof(struct sockaddr_un)); - sun.sun_family = AF_UNIX; + memset(&s_un, 0, sizeof(struct sockaddr_un)); + s_un.sun_family = AF_UNIX; - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= - sizeof(sun.sun_path)) { + if (strlcpy(s_un.sun_path, path, sizeof(s_un.sun_path)) >= + sizeof(s_un.sun_path)) { close(s); errno = ENAMETOOLONG; return (-1); } - if (bind(s, (struct sockaddr *)&sun, sizeof(sun)) < 0) { + if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) { close(s); return (-1); } @@ -737,7 +737,7 @@ tls_setup_server(struct tls *tls_ctx, in int unix_connect(char *path) { - struct sockaddr_un sun; + struct sockaddr_un s_un; int s; if (uflag) { @@ -748,16 +748,16 @@ unix_connect(char *path) return (-1); } - memset(&sun, 0, sizeof(struct sockaddr_un)); - sun.sun_family = AF_UNIX; + memset(&s_un, 0, sizeof(struct sockaddr_un)); + s_un.sun_family = AF_UNIX; - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= - sizeof(sun.sun_path)) { + if (strlcpy(s_un.sun_path, path, sizeof(s_un.sun_path)) >= + sizeof(s_un.sun_path)) { close(s); errno = ENAMETOOLONG; return (-1); } - if (connect(s, (struct sockaddr *)&sun, sizeof(sun)) < 0) { + if (connect(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) { close(s); return (-1); }