head 1.7; access; symbols pkgsrc-2026Q1:1.7.0.8 pkgsrc-2026Q1-base:1.7 pkgsrc-2025Q4:1.7.0.6 pkgsrc-2025Q4-base:1.7 pkgsrc-2025Q3:1.7.0.4 pkgsrc-2025Q3-base:1.7 pkgsrc-2025Q2:1.7.0.2 pkgsrc-2025Q2-base:1.7 pkgsrc-2025Q1:1.6.0.6 pkgsrc-2025Q1-base:1.6 pkgsrc-2024Q4:1.6.0.4 pkgsrc-2024Q4-base:1.6 pkgsrc-2024Q3:1.6.0.2 pkgsrc-2024Q3-base:1.6 pkgsrc-2024Q2:1.5.0.68 pkgsrc-2024Q2-base:1.5 pkgsrc-2024Q1:1.5.0.66 pkgsrc-2024Q1-base:1.5 pkgsrc-2023Q4:1.5.0.64 pkgsrc-2023Q4-base:1.5 pkgsrc-2023Q3:1.5.0.62 pkgsrc-2023Q3-base:1.5 pkgsrc-2023Q2:1.5.0.60 pkgsrc-2023Q2-base:1.5 pkgsrc-2023Q1:1.5.0.58 pkgsrc-2023Q1-base:1.5 pkgsrc-2022Q4:1.5.0.56 pkgsrc-2022Q4-base:1.5 pkgsrc-2022Q3:1.5.0.54 pkgsrc-2022Q3-base:1.5 pkgsrc-2022Q2:1.5.0.52 pkgsrc-2022Q2-base:1.5 pkgsrc-2022Q1:1.5.0.50 pkgsrc-2022Q1-base:1.5 pkgsrc-2021Q4:1.5.0.48 pkgsrc-2021Q4-base:1.5 pkgsrc-2021Q3:1.5.0.46 pkgsrc-2021Q3-base:1.5 pkgsrc-2021Q2:1.5.0.44 pkgsrc-2021Q2-base:1.5 pkgsrc-2021Q1:1.5.0.42 pkgsrc-2021Q1-base:1.5 pkgsrc-2020Q4:1.5.0.40 pkgsrc-2020Q4-base:1.5 pkgsrc-2020Q3:1.5.0.38 pkgsrc-2020Q3-base:1.5 pkgsrc-2020Q2:1.5.0.34 pkgsrc-2020Q2-base:1.5 pkgsrc-2020Q1:1.5.0.14 pkgsrc-2020Q1-base:1.5 pkgsrc-2019Q4:1.5.0.36 pkgsrc-2019Q4-base:1.5 pkgsrc-2019Q3:1.5.0.32 pkgsrc-2019Q3-base:1.5 pkgsrc-2019Q2:1.5.0.30 pkgsrc-2019Q2-base:1.5 pkgsrc-2019Q1:1.5.0.28 pkgsrc-2019Q1-base:1.5 pkgsrc-2018Q4:1.5.0.26 pkgsrc-2018Q4-base:1.5 pkgsrc-2018Q3:1.5.0.24 pkgsrc-2018Q3-base:1.5 pkgsrc-2018Q2:1.5.0.22 pkgsrc-2018Q2-base:1.5 pkgsrc-2018Q1:1.5.0.20 pkgsrc-2018Q1-base:1.5 pkgsrc-2017Q4:1.5.0.18 pkgsrc-2017Q4-base:1.5 pkgsrc-2017Q3:1.5.0.16 pkgsrc-2017Q3-base:1.5 pkgsrc-2017Q2:1.5.0.12 pkgsrc-2017Q2-base:1.5 pkgsrc-2017Q1:1.5.0.10 pkgsrc-2017Q1-base:1.5 pkgsrc-2016Q4:1.5.0.8 pkgsrc-2016Q4-base:1.5 pkgsrc-2016Q3:1.5.0.6 pkgsrc-2016Q3-base:1.5 pkgsrc-2016Q2:1.5.0.4 pkgsrc-2016Q2-base:1.5 pkgsrc-2016Q1:1.5.0.2 pkgsrc-2016Q1-base:1.5 pkgsrc-2015Q4:1.4.0.40 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.38 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.36 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.34 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.32 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.30 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.28 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.26 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.24 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.22 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.20 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.4.0.18 pkgsrc-2013Q1-base:1.4 pkgsrc-2012Q4:1.4.0.16 pkgsrc-2012Q4-base:1.4 pkgsrc-2012Q3:1.4.0.14 pkgsrc-2012Q3-base:1.4 pkgsrc-2012Q2:1.4.0.12 pkgsrc-2012Q2-base:1.4 pkgsrc-2012Q1:1.4.0.10 pkgsrc-2012Q1-base:1.4 pkgsrc-2011Q4:1.4.0.8 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.6 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.4 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.2 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.3.0.56 pkgsrc-2010Q4-base:1.3 pkgsrc-2010Q3:1.3.0.54 pkgsrc-2010Q3-base:1.3 pkgsrc-2010Q2:1.3.0.52 pkgsrc-2010Q2-base:1.3 pkgsrc-2010Q1:1.3.0.50 pkgsrc-2010Q1-base:1.3 pkgsrc-2009Q4:1.3.0.48 pkgsrc-2009Q4-base:1.3 pkgsrc-2009Q3:1.3.0.46 pkgsrc-2009Q3-base:1.3 pkgsrc-2009Q2:1.3.0.44 pkgsrc-2009Q2-base:1.3 pkgsrc-2009Q1:1.3.0.42 pkgsrc-2009Q1-base:1.3 pkgsrc-2008Q4:1.3.0.40 pkgsrc-2008Q4-base:1.3 pkgsrc-2008Q3:1.3.0.38 pkgsrc-2008Q3-base:1.3 cube-native-xorg:1.3.0.36 cube-native-xorg-base:1.3 pkgsrc-2008Q2:1.3.0.34 pkgsrc-2008Q2-base:1.3 cwrapper:1.3.0.32 pkgsrc-2008Q1:1.3.0.30 pkgsrc-2008Q1-base:1.3 pkgsrc-2007Q4:1.3.0.28 pkgsrc-2007Q4-base:1.3 pkgsrc-2007Q3:1.3.0.26 pkgsrc-2007Q3-base:1.3 pkgsrc-2007Q2:1.3.0.24 pkgsrc-2007Q2-base:1.3 pkgsrc-2007Q1:1.3.0.22 pkgsrc-2007Q1-base:1.3 pkgsrc-2006Q4:1.3.0.20 pkgsrc-2006Q4-base:1.3 pkgsrc-2006Q3:1.3.0.18 pkgsrc-2006Q3-base:1.3 pkgsrc-2006Q2:1.3.0.16 pkgsrc-2006Q2-base:1.3 pkgsrc-2006Q1:1.3.0.14 pkgsrc-2006Q1-base:1.3 pkgsrc-2005Q4:1.3.0.12 pkgsrc-2005Q4-base:1.3 pkgsrc-2005Q3:1.3.0.10 pkgsrc-2005Q3-base:1.3 pkgsrc-2005Q2:1.3.0.8 pkgsrc-2005Q2-base:1.3 pkgsrc-2005Q1:1.3.0.6 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.4 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.2 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.2.0.8 pkgsrc-2004Q2-base:1.2 pkgsrc-2004Q1:1.2.0.6 pkgsrc-2004Q1-base:1.2 pkgsrc-2003Q4:1.2.0.4 pkgsrc-2003Q4-base:1.2 netbsd-1-6-1:1.2.0.2 netbsd-1-6-1-base:1.2; locks; strict; comment @# @; 1.7 date 2025.04.29.09.50.22; author tnn; state Exp; branches; next 1.6; commitid 36opfKvElhtXJVSF; 1.6 date 2024.08.05.10.24.32; author tnn; state Exp; branches; next 1.5; commitid HI04KkBZFxmLvCkF; 1.5 date 2015.12.29.04.04.30; author dholland; state Exp; branches; next 1.4; commitid MGywJcTuFA0OoNOy; 1.4 date 2011.01.13.15.09.58; author pooka; state Exp; branches; next 1.3; 1.3 date 2004.08.05.14.47.46; author drochner; state Exp; branches; next 1.2; 1.2 date 2002.10.08.14.29.37; author abs; state Exp; branches; next 1.1; 1.1 date 2002.08.21.06.31.57; author simonb; state Exp; branches; next ; desc @@ 1.7 log @netcat: replace K&R prototypes @ text @$NetBSD: patch-ad,v 1.6 2024/08/05 10:24:32 tnn Exp $ --- netcat.c.orig 1996-03-21 00:38:04.000000000 +0000 +++ netcat.c @@@@ -44,12 +44,7 @@@@ #include #endif -/* have to do this *before* including types.h. xxx: Linux still has it wrong */ -#ifdef FD_SETSIZE /* should be in types.h, butcha never know. */ -#undef FD_SETSIZE /* if we ever need more than 16 active */ -#endif /* fd's, something is horribly wrong! */ -#define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */ -#include /* *now* do it. Sigh, this is broken */ +#include #ifdef HAVE_RANDOM /* aficionados of ?rand48() should realize */ #define SRAND srandom /* that this doesn't need *strong* random */ @@@@ -73,6 +68,8 @@@@ #include #include #include /* O_WRONLY et al */ +#include +#include /* handy stuff: */ #define SA struct sockaddr /* socket overgeneralization braindeath */ @@@@ -151,6 +148,7 @@@@ unsigned char * stage = NULL; /* hexdump /* global cmd flags: */ USHORT o_alla = 0; +USHORT o_allowbroad = 0; unsigned int o_interval = 0; USHORT o_listen = 0; USHORT o_nflag = 0; @@@@ -160,6 +158,7 @@@@ USHORT o_udpmode = 0; USHORT o_verbose = 0; unsigned int o_wait = 0; USHORT o_zero = 0; +int o_quit = -1; /* 0 == quit-now; >0 == quit after o_quit seconds */ /* o_tn in optional section */ /* Debug macro: squirt whatever message and sleep a bit so we can see it go @@@@ -171,6 +170,7 @@@@ USHORT o_zero = 0; #define Debug(x) /* nil... */ #endif +void helpme(); /* support routines -- the bulk of this thing. Placed in such an order that we don't have to forward-declare anything: */ @@@@ -217,7 +217,7 @@@@ void bail (str, p1, p2, p3, p4, p5, p6) /* catch : no-brainer interrupt handler */ -void catch () +void catch (int signum) { errno = 0; if (o_verbose > 1) /* normally we don't care */ @@@@ -225,8 +225,16 @@@@ void catch () bail (" punt!"); } +/* quit : + handler for a "-q" timeout (exit 0 instead of 1) */ +void quit(int signum) +{ + close(netfd); + exit(0); +} + /* timeout and other signal handling cruft */ -void tmtravel () +void tmtravel (int signum) { signal (SIGALRM, SIG_IGN); alarm (0); @@@@ -333,6 +341,7 @@@@ HINF * gethostpoop (name, numeric) struct in_addr iaddr; register HINF * poop = NULL; register int x; + int rc; /* I really want to strangle the twit who dreamed up all these sockaddr and hostent abstractions, and then forced them all to be incompatible with @@@@ -361,9 +370,9 @@@@ HINF * gethostpoop (name, numeric) bail ("gethostpoop fuxored"); strcpy (poop->name, unknown); /* preload it */ /* see wzv:workarounds.c for dg/ux return-a-struct inet_addr lossage */ - iaddr.s_addr = inet_addr (name); + rc = inet_aton(name, &iaddr); - if (iaddr.s_addr == INADDR_NONE) { /* here's the great split: names... */ + if (rc == 0) { /* here's the great split: names... */ if (numeric) bail ("Can't parse %s as an IP address", name); hostent = gethostbyname (name); @@@@ -568,6 +577,7 @@@@ char * pr00gie = NULL; /* global ptr t that would be security-critical, which is why it's ifdefed out by default. Use at your own hairy risk; if you leave shells lying around behind open listening ports you deserve to lose!! */ +void doexec (fd) int fd; { @@@@ -620,6 +630,13 @@@@ newskt: rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)); if (rr == -1) holler ("nnetfd reuseaddr failed"); /* ??? */ +#ifdef SO_BROADCAST + if (o_allowbroad) { + rr = setsockopt (nnetfd, SOL_SOCKET, SO_BROADCAST, &x, sizeof (x)); + if (rr == -1) + holler ("nnetfd reuseaddr failed"); /* ??? */ + } +#endif #ifdef SO_REUSEPORT /* doesnt exist everywhere... */ rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x)); if (rr == -1) @@@@ -944,6 +961,7 @@@@ dol_err: Use the time delay between writes if given, otherwise use the "tcp ping" trick for getting the RTT. [I got that idea from pluvius, and warped it.] Return either the original fd, or clean up and return -1. */ +int udptest (fd, where) int fd; IA * where; @@@@ -1216,6 +1234,18 @@@@ Debug (("got %d from the net, errno %d", if (rr <= 0) { /* at end, or fukt, or ... */ FD_CLR (0, ding1); /* disable and close stdin */ close (0); + /* if the user asked to exit on EOF, do it */ + if (o_quit == 0) { + shutdown(netfd, 1); + close (fd); + exit (0); + } + /* if user asked to die after a while, arrange for it */ + if (o_quit > 0) { + shutdown(netfd, 1); + signal (SIGALRM, quit); + alarm(o_quit); + } } else { rzleft = rr; zp = bigbuf_in; @@@@ -1292,6 +1322,7 @@@@ Debug (("wrote %d to net, errno %d", rr, /* main : now we pull it all together... */ +int main (argc, argv) int argc; char ** argv; @@@@ -1314,10 +1345,6 @@@@ main (argc, argv) USHORT curport = 0; char * randports = NULL; -#ifdef HAVE_BIND -/* can *you* say "cc -yaddayadda netcat.c -lresolv -l44bsd" on SunLOSs? */ - res_init(); -#endif /* I was in this barbershop quartet in Skokie IL ... */ /* round up the usual suspects, i.e. malloc up all the stuff we need */ lclend = (SAI *) Hmalloc (sizeof (SA)); @@@@ -1354,7 +1381,8 @@@@ main (argc, argv) argv[1] = cp; /* head of new arg block */ fprintf (stderr, "Cmd line: "); fflush (stderr); /* I dont care if it's unbuffered or not! */ - insaved = read (0, cp, BIGSIZ); /* we're gonna fake fgets() here */ + insaved = read (0, cp, BIGSIZ-1); /* we're gonna fake fgets() here */ + cp[BIGSIZ-1] = '\0'; if (insaved <= 0) bail ("wrong"); x = findline (cp, insaved); @@@@ -1389,12 +1417,14 @@@@ main (argc, argv) /* If your shitbox doesn't have getopt, step into the nineties already. */ /* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */ - while ((x = getopt (argc, argv, "ae:g:G:hi:lno:p:rs:tuvw:z")) != EOF) { + while ((x = getopt (argc, argv, "abe:g:G:hi:lno:p:q:rs:tuvw:z")) != EOF) { /* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */ switch (x) { case 'a': bail ("all-A-records NIY"); o_alla++; break; + case 'b': + o_allowbroad++; break; #ifdef GAPING_SECURITY_HOLE case 'e': /* prog to exec */ pr00gie = optarg; @@@@ -1443,6 +1473,8 @@@@ main (argc, argv) break; case 'r': /* randomize various things */ o_random++; break; + case 'q': /* quit after stdin does EOF */ + o_quit = atoi(optarg); break; case 's': /* local source address */ /* do a full lookup [since everything else goes through the same mill], unless -n was previously specified. In fact, careful placement of -n can @@@@ -1627,6 +1659,7 @@@@ Debug (("netfd %d from port %d to port % #ifdef HAVE_HELP /* unless we wanna be *really* cryptic */ /* helpme : the obvious */ +void helpme() { o_verbose = 1; @@@@ -1642,6 +1675,7 @@@@ options:"); -e prog program to exec after connect [dangerous!!]"); #endif holler ("\ + -b allow broadcasts\n\ -g gateway source-routing hop point[s], up to 8\n\ -G num source-routing pointer: 4, 8, 12, ...\n\ -h this cruft\n\ @@@@ -1651,6 +1685,7 @@@@ options:"); -o file hex dump of traffic\n\ -p port local port number\n\ -r randomize local and remote ports\n\ + -q secs quit after EOF on stdin and delay of secs\n\ -s addr local source address"); #ifdef TELNET holler ("\ @ 1.6 log @netcat: fix assorted header and prototype problems @ text @d1 1 a1 1 $NetBSD: patch-ad,v 1.5 2015/12/29 04:04:30 dholland Exp $ d52 10 a61 1 @@@@ -225,6 +225,14 @@@@ void catch () d67 1 a67 1 +void quit() d74 2 a75 1 void tmtravel () d77 2 @ 1.5 log @Fix missing/broken rcsids. @ text @d1 1 a1 1 $NetBSD: patch-ad,v 1.4 2011/01/13 15:09:58 pooka Exp $ d3 2 a4 2 --- netcat.c.orig 1996-03-21 01:38:04.000000000 +0100 +++ netcat.c 2011-01-13 16:06:00.000000000 +0100 d19 10 a28 1 @@@@ -151,6 +146,7 @@@@ d36 1 a36 1 @@@@ -160,6 +156,7 @@@@ d44 9 a52 1 @@@@ -225,6 +222,14 @@@@ d67 1 a67 1 @@@@ -333,6 +338,7 @@@@ d75 1 a75 1 @@@@ -361,9 +367,9 @@@@ d87 9 a95 1 @@@@ -620,6 +626,13 @@@@ d109 9 a117 1 @@@@ -1216,6 +1229,18 @@@@ d136 9 a144 1 @@@@ -1314,10 +1339,6 @@@@ d155 1 a155 1 @@@@ -1354,7 +1375,8 @@@@ d165 1 a165 1 @@@@ -1389,12 +1411,14 @@@@ d181 1 a181 1 @@@@ -1443,6 +1467,8 @@@@ d190 9 a198 1 @@@@ -1642,6 +1668,7 @@@@ d206 1 a206 1 @@@@ -1651,6 +1678,7 @@@@ @ 1.4 log @Use dynamic linking by default. ok wiz Also, use the default FD_SETSIZE so that syscall interceptors have a better chance of getting lucky. @ text @d1 1 a1 1 $NetBSD$ @ 1.3 log @add a valuable feature from Debian: quit after EOF on stdin being here, apply a string termination fix from Debian bump PKGREVISION @ text @d1 1 a1 1 $NetBSD$ d3 17 a19 3 --- netcat.c.orig 2004-08-05 16:17:46.000000000 +0200 +++ netcat.c @@@@ -151,6 +151,7 @@@@ unsigned char * stage = NULL; /* hexdump d27 1 a27 1 @@@@ -160,6 +161,7 @@@@ USHORT o_udpmode = 0; d35 1 a35 1 @@@@ -225,6 +227,14 @@@@ void catch () d50 1 a50 1 @@@@ -333,6 +343,7 @@@@ HINF * gethostpoop (name, numeric) d58 1 a58 1 @@@@ -361,9 +372,9 @@@@ HINF * gethostpoop (name, numeric) d70 1 a70 1 @@@@ -620,6 +631,13 @@@@ newskt: d84 1 a84 1 @@@@ -1216,6 +1234,18 @@@@ Debug (("got %d from the net, errno %d", d103 1 a103 1 @@@@ -1314,10 +1344,6 @@@@ main (argc, argv) d114 1 a114 1 @@@@ -1354,7 +1380,8 @@@@ main (argc, argv) d124 1 a124 1 @@@@ -1389,12 +1416,14 @@@@ main (argc, argv) d140 1 a140 1 @@@@ -1443,6 +1472,8 @@@@ main (argc, argv) d149 1 a149 1 @@@@ -1642,6 +1673,7 @@@@ options:"); d157 1 a157 1 @@@@ -1651,6 +1683,7 @@@@ options:"); @ 1.2 log @Update netcat to netcat-1.10nb1 Merge two netcat.c patches into a single patch file, remove unneccessary call to res_init() and pass correct make options for Linux and (untested) Solaris. @ text @d3 1 a3 1 --- netcat.c.orig Tue Oct 8 13:24:18 2002 d13 24 a36 1 @@@@ -333,6 +334,7 @@@@ HINF * gethostpoop (name, numeric) d44 1 a44 1 @@@@ -361,9 +363,9 @@@@ HINF * gethostpoop (name, numeric) d56 1 a56 1 @@@@ -620,6 +622,13 @@@@ newskt: d70 20 a89 1 @@@@ -1314,10 +1323,6 @@@@ main (argc, argv) d100 11 a110 1 @@@@ -1389,12 +1394,14 @@@@ main (argc, argv) d115 1 a115 1 + while ((x = getopt (argc, argv, "abe:g:G:hi:lno:p:rs:tuvw:z")) != EOF) { d126 10 a135 1 @@@@ -1642,6 +1649,7 @@@@ options:"); d143 8 @ 1.1 log @Include in a few places to stop some warnings on alpha (and other 64-bit platforms?). @ text @d3 3 a5 4 --- data/rservice.c.orig Thu Feb 1 05:45:08 1996 +++ data/rservice.c @@@@ -10,6 +10,7 @@@@ ... whatever. _H*/ d7 11 a17 2 #include +#include d19 63 a81 2 /* change if you like; "id" is a good one for figuring out if you won too */ static char cmd[] = "pwd"; @