Author: delphij Date: Mon Apr 15 05:31:59 2013 New Revision: 249499 URL: http://svnweb.freebsd.org/changeset/base/249499
Log: MFV r249496,249498. The most visible change is that we no longer shuts down the connection when stdin closes, by default. This matches Hobbit's original netcat and GNU netcat. Old behavior can be restored with the new -N flag. MFC after: 2 weeks Modified: head/contrib/netcat/atomicio.c head/contrib/netcat/nc.1 head/contrib/netcat/netcat.c Directory Properties: head/contrib/netcat/ (props changed) Modified: head/contrib/netcat/atomicio.c ============================================================================== --- head/contrib/netcat/atomicio.c Mon Apr 15 05:24:43 2013 (r249498) +++ head/contrib/netcat/atomicio.c Mon Apr 15 05:31:59 2013 (r249499) @@ -1,4 +1,4 @@ -/* $OpenBSD: atomicio.c,v 1.10 2011/01/08 00:47:19 jeremy Exp $ */ +/* $OpenBSD: atomicio.c,v 1.11 2012/12/04 02:24:47 deraadt Exp $ */ /* * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. @@ -26,8 +26,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> - #include <errno.h> #include <poll.h> #include <unistd.h> Modified: head/contrib/netcat/nc.1 ============================================================================== --- head/contrib/netcat/nc.1 Mon Apr 15 05:24:43 2013 (r249498) +++ head/contrib/netcat/nc.1 Mon Apr 15 05:31:59 2013 (r249499) @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.61 2012/07/07 15:33:02 haesbaert Exp $ +.\" $OpenBSD: nc.1,v 1.62 2013/03/20 09:27:56 sthen Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 7, 2012 +.Dd July 7, 2012 .Dt NC 1 .Os .Sh NAME @@ -36,7 +36,7 @@ .Sh SYNOPSIS .Nm nc .Bk -words -.Op Fl 46DdEhklnrStUuvz +.Op Fl 46DdEhklNnrStUuvz .Op Fl e Ar IPsec_policy .Op Fl I Ar length .Op Fl i Ar interval @@ -155,6 +155,10 @@ options. Additionally, any timeouts specified with the .Fl w option are ignored. +.It Fl N +.Xr shutdown 2 +the network socket after EOF on the input. +Some servers require this to finish their work. .It Fl n Do not do any DNS or service lookups on any specified addresses, hostnames or ports. Modified: head/contrib/netcat/netcat.c ============================================================================== --- head/contrib/netcat/netcat.c Mon Apr 15 05:24:43 2013 (r249498) +++ head/contrib/netcat/netcat.c Mon Apr 15 05:31:59 2013 (r249499) @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.109 2012/07/07 15:33:02 haesbaert Exp $ */ +/* $OpenBSD: netcat.c,v 1.111 2013/03/20 09:27:56 sthen Exp $ */ /* * Copyright (c) 2001 Eric Jackson <er...@monkey.org> * @@ -77,6 +77,7 @@ int dflag; /* detached, no stdin */ unsigned int iflag; /* Interval Flag */ int kflag; /* More than one connect */ int lflag; /* Bind to local port */ +int Nflag; /* shutdown() network socket */ int nflag; /* Don't do name look up */ int FreeBSD_Oflag; /* Do not use TCP options */ char *Pflag; /* Proxy username */ @@ -153,7 +154,7 @@ main(int argc, char *argv[]) sv = NULL; while ((ch = getopt_long(argc, argv, - "46DdEe:hI:i:klnoO:P:p:rSs:tT:UuV:vw:X:x:z", + "46DdEe:hI:i:klNnoO:P:p:rSs:tT:UuV:vw:X:x:z", longopts, NULL)) != -1) { switch (ch) { case '4': @@ -207,6 +208,9 @@ main(int argc, char *argv[]) case 'l': lflag = 1; break; + case 'N': + Nflag = 1; + break; case 'n': nflag = 1; break; @@ -424,9 +428,10 @@ main(int argc, char *argv[]) len = sizeof(cliaddr); connfd = accept(s, (struct sockaddr *)&cliaddr, &len); - if (connfd == -1) - err(1, "accept"); - + if (connfd == -1) { + /* For now, all errnos are fatal */ + err(1, "accept"); + } if (vflag) report_connect((struct sockaddr *)&cliaddr, len); @@ -833,7 +838,8 @@ readwrite(int nfd) if ((n = read(wfd, buf, plen)) < 0) return; else if (n == 0) { - shutdown(nfd, SHUT_WR); + if (Nflag) + shutdown(nfd, SHUT_WR); pfd[1].fd = -1; pfd[1].events = 0; } else { @@ -1087,6 +1093,7 @@ help(void) \t-i secs\t Delay interval for lines sent, ports scanned\n\ \t-k Keep inbound sockets open for multiple connects\n\ \t-l Listen mode, for inbound connects\n\ + \t-N Shutdown the network socket after EOF on stdin\n\ \t-n Suppress name/port resolutions\n\ \t--no-tcpopt Disable TCP options\n\ \t-O length TCP send buffer length\n\ @@ -1139,9 +1146,9 @@ usage(int ret) { fprintf(stderr, #ifdef IPSEC - "usage: nc [-46DdEhklnrStUuvz] [-e policy] [-I length] [-i interval] [-O length]\n" + "usage: nc [-46DdEhklNnrStUuvz] [-e policy] [-I length] [-i interval] [-O length]\n" #else - "usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n" + "usage: nc [-46DdhklNnrStUuvz] [-I length] [-i interval] [-O length]\n" #endif "\t [-P proxy_username] [-p source_port] [-s source] [-T ToS]\n" "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n" _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"