diff options
author | Brent Cook <bcook@openbsd.org> | 2015-09-13 11:56:41 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2015-09-13 18:42:15 -0500 |
commit | 8c90be2a29053ac613dfe0c11a423da16c7c4520 (patch) | |
tree | cf31a8e35cd9793f5f6f622b0ffcce61bbad8652 /patches/netcat.c.patch | |
parent | 627b0261a81bb18ef95156baa37101ddcb14e356 (diff) | |
download | portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.tar.gz portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.tar.bz2 portable-8c90be2a29053ac613dfe0c11a423da16c7c4520.zip |
allow nc to build on linux and os x
Diffstat (limited to 'patches/netcat.c.patch')
-rw-r--r-- | patches/netcat.c.patch | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch new file mode 100644 index 0000000..c5206f6 --- /dev/null +++ b/patches/netcat.c.patch | |||
@@ -0,0 +1,137 @@ | |||
1 | --- apps/nc/netcat.c.orig Sun Sep 13 08:12:39 2015 | ||
2 | +++ apps/nc/netcat.c Sun Sep 13 16:39:51 2015 | ||
3 | @@ -98,9 +98,13 @@ | ||
4 | int Dflag; /* sodebug */ | ||
5 | int Iflag; /* TCP receive buffer size */ | ||
6 | int Oflag; /* TCP send buffer size */ | ||
7 | +#ifdef TCP_MD5SIG | ||
8 | int Sflag; /* TCP MD5 signature option */ | ||
9 | +#endif | ||
10 | int Tflag = -1; /* IP Type of Service */ | ||
11 | +#ifdef SO_RTABLE | ||
12 | int rtableid = -1; | ||
13 | +#endif | ||
14 | |||
15 | int usetls; /* use TLS */ | ||
16 | char *Cflag; /* Public cert file */ | ||
17 | @@ -150,7 +154,7 @@ | ||
18 | struct servent *sv; | ||
19 | socklen_t len; | ||
20 | struct sockaddr_storage cliaddr; | ||
21 | - char *proxy; | ||
22 | + char *proxy = NULL; | ||
23 | const char *errstr, *proxyhost = "", *proxyport = NULL; | ||
24 | struct addrinfo proxyhints; | ||
25 | char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; | ||
26 | @@ -251,12 +255,14 @@ | ||
27 | case 'u': | ||
28 | uflag = 1; | ||
29 | break; | ||
30 | +#ifdef SO_RTABLE | ||
31 | case 'V': | ||
32 | rtableid = (int)strtonum(optarg, 0, | ||
33 | RT_TABLEID_MAX, &errstr); | ||
34 | if (errstr) | ||
35 | errx(1, "rtable %s: %s", errstr, optarg); | ||
36 | break; | ||
37 | +#endif | ||
38 | case 'v': | ||
39 | vflag = 1; | ||
40 | break; | ||
41 | @@ -289,9 +295,11 @@ | ||
42 | errx(1, "TCP send window %s: %s", | ||
43 | errstr, optarg); | ||
44 | break; | ||
45 | +#ifdef TCP_MD5SIG | ||
46 | case 'S': | ||
47 | Sflag = 1; | ||
48 | break; | ||
49 | +#endif | ||
50 | case 'T': | ||
51 | errstr = NULL; | ||
52 | errno = 0; | ||
53 | @@ -776,7 +784,10 @@ | ||
54 | remote_connect(const char *host, const char *port, struct addrinfo hints) | ||
55 | { | ||
56 | struct addrinfo *res, *res0; | ||
57 | - int s, error, on = 1; | ||
58 | + int s, error; | ||
59 | +#ifdef SO_BINDANY | ||
60 | + int on = 1; | ||
61 | +#endif | ||
62 | |||
63 | if ((error = getaddrinfo(host, port, &hints, &res))) | ||
64 | errx(1, "getaddrinfo: %s", gai_strerror(error)); | ||
65 | @@ -787,16 +798,20 @@ | ||
66 | SOCK_NONBLOCK, res0->ai_protocol)) < 0) | ||
67 | continue; | ||
68 | |||
69 | +#ifdef SO_RTABLE | ||
70 | if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, | ||
71 | &rtableid, sizeof(rtableid)) == -1)) | ||
72 | err(1, "setsockopt SO_RTABLE"); | ||
73 | +#endif | ||
74 | |||
75 | /* Bind to a local port or source address if specified. */ | ||
76 | if (sflag || pflag) { | ||
77 | struct addrinfo ahints, *ares; | ||
78 | |||
79 | +#ifdef SO_BINDANY | ||
80 | /* try SO_BINDANY, but don't insist */ | ||
81 | setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on)); | ||
82 | +#endif | ||
83 | memset(&ahints, 0, sizeof(struct addrinfo)); | ||
84 | ahints.ai_family = res0->ai_family; | ||
85 | ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; | ||
86 | @@ -887,9 +902,11 @@ | ||
87 | res0->ai_protocol)) < 0) | ||
88 | continue; | ||
89 | |||
90 | +#ifdef SO_RTABLE | ||
91 | if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, | ||
92 | &rtableid, sizeof(rtableid)) == -1)) | ||
93 | err(1, "setsockopt SO_RTABLE"); | ||
94 | +#endif | ||
95 | |||
96 | ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); | ||
97 | if (ret == -1) | ||
98 | @@ -1337,11 +1354,13 @@ | ||
99 | { | ||
100 | int x = 1; | ||
101 | |||
102 | +#ifdef TCP_MD5SIG | ||
103 | if (Sflag) { | ||
104 | if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, | ||
105 | &x, sizeof(x)) == -1) | ||
106 | err(1, NULL); | ||
107 | } | ||
108 | +#endif | ||
109 | if (Dflag) { | ||
110 | if (setsockopt(s, SOL_SOCKET, SO_DEBUG, | ||
111 | &x, sizeof(x)) == -1) | ||
112 | @@ -1516,15 +1535,19 @@ | ||
113 | \t-P proxyuser\tUsername for proxy authentication\n\ | ||
114 | \t-p port\t Specify local port for remote connects\n\ | ||
115 | \t-R CAfile CA bundle\n\ | ||
116 | - \t-r Randomize remote ports\n\ | ||
117 | - \t-S Enable the TCP MD5 signature option\n\ | ||
118 | - \t-s source Local source address\n\ | ||
119 | + \t-r Randomize remote ports\n" | ||
120 | +#ifdef TCP_MD5SIG | ||
121 | + "\t-S Enable the TCP MD5 signature option\n" | ||
122 | +#endif | ||
123 | + "\t-s source Local source address\n\ | ||
124 | \t-T keyword TOS value or TLS options\n\ | ||
125 | \t-t Answer TELNET negotiation\n\ | ||
126 | \t-U Use UNIX domain socket\n\ | ||
127 | - \t-u UDP mode\n\ | ||
128 | - \t-V rtable Specify alternate routing table\n\ | ||
129 | - \t-v Verbose\n\ | ||
130 | + \t-u UDP mode\n" | ||
131 | +#ifdef SO_RTABLE | ||
132 | + "\t-V rtable Specify alternate routing table\n" | ||
133 | +#endif | ||
134 | + "\t-v Verbose\n\ | ||
135 | \t-w timeout Timeout for connects and final net reads\n\ | ||
136 | \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ | ||
137 | \t-x addr[:port]\tSpecify proxy address and port\n\ | ||