Hi tech@,

I just ran into this while fiddling with some netcat-based plumbing.
When I connect to the specified socket from another shell, the
listening nc dies if it is AF_UNIX:

    $ tail -10f /var/log/messages | nc -vkU -l ~/.xlog_socket
    nc: getnameinfo: Invalid argument

The attached patch fixes the issue:

    $ tail -10f /var/log/messages | \
        /usr/obj/usr.bin/nc/nc -vkU -l ~/.xlog_socket
    Connection on /home/attila/.xlog_socket received!

Feedback, comments most welcome.

Pax, -A
--
http://haqistan.net/~attila | [email protected] | 0x62A729CF
Index: netcat.c
===================================================================
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.150
diff -u -p -r1.150 netcat.c
--- netcat.c	4 Jan 2016 02:18:31 -0000	1.150
+++ netcat.c	28 May 2016 16:31:27 -0000
@@ -527,8 +527,16 @@ main(int argc, char *argv[])
 					/* For now, all errnos are fatal */
 					err(1, "accept");
 				}
-				if (vflag)
-					report_connect((struct sockaddr *)&cliaddr, len);
+				if (vflag) {
+					if (family == AF_UNIX)
+						fprintf(stderr,
+						    "Connection on %s "
+						    "received!\n", host);
+					else
+						report_connect(
+						    (struct sockaddr *)&cliaddr,
+						    len);
+				}
 				if ((usetls) &&
 				    (tls_cctx = tls_setup_server(tls_ctx, connfd, host)))
 					readwrite(connfd, tls_cctx);

Reply via email to