Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:musl commit in: net-misc/iputils/, net-misc/iputils/files/
Date: Fri, 24 Jan 2014 15:38:41
Message-Id: 1390577912.2ad924a100245db36999df518ffd06cf9572246d.blueness@gentoo
1 commit: 2ad924a100245db36999df518ffd06cf9572246d
2 Author: layman <layman <AT> localhost>
3 AuthorDate: Fri Jan 24 15:35:10 2014 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 24 15:38:32 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=2ad924a1
7
8 net-misc/iputils: multiple fixes
9
10 ---
11 .../files/021109-uclibc-no-ether_ntohost.patch | 24 +++
12 .../iputils/files/iputils-20100418-makefile.patch | 35 ++++
13 .../files/iputils-20100418-printf-size.patch | 62 ++++++
14 .../iputils/files/iputils-20100418-so_mark.patch | 22 ++
15 .../files/iputils-20101006-owl-pingsock.diff | 224 +++++++++++++++++++++
16 .../files/iputils-20121221-add-bits_types_h.patch | 94 +++++++++
17 .../files/iputils-20121221-crypto-build.patch | 35 ++++
18 .../files/iputils-20121221-fix-init-elemnt.patch | 23 +++
19 .../files/iputils-20121221-fix-musl-headers.patch | 89 ++++++++
20 .../iputils/files/iputils-20121221-makefile.patch | 61 ++++++
21 .../iputils/files/iputils-20121221-openssl.patch | 92 +++++++++
22 .../files/iputils-20121221-owl-pingsock.diff | 224 +++++++++++++++++++++
23 .../files/iputils-20121221-printf-size.patch | 64 ++++++
24 ...ls-20121221-remove-rdisc-glibc-assumption.patch | 30 +++
25 net-misc/iputils/iputils-20121221-r99.ebuild | 103 ++++++++++
26 net-misc/iputils/metadata.xml | 11 +
27 16 files changed, 1193 insertions(+)
28
29 diff --git a/net-misc/iputils/files/021109-uclibc-no-ether_ntohost.patch b/net-misc/iputils/files/021109-uclibc-no-ether_ntohost.patch
30 new file mode 100644
31 index 0000000..e790d2b
32 --- /dev/null
33 +++ b/net-misc/iputils/files/021109-uclibc-no-ether_ntohost.patch
34 @@ -0,0 +1,24 @@
35 +--- iputils/rarpd.c.mps 2004-06-10 15:27:01.000000000 +0200
36 ++++ iputils/rarpd.c 2004-06-10 15:26:29.000000000 +0200
37 +@@ -42,7 +42,9 @@ int listen_arp;
38 + char *ifname;
39 + char *tftp_dir = "/etc/tftpboot";
40 +
41 ++#ifndef __UCLIBC__
42 + extern int ether_ntohost(char *name, unsigned char *ea);
43 ++#endif
44 + void usage(void) __attribute__((noreturn));
45 +
46 + struct iflink
47 +@@ -305,7 +307,11 @@ struct rarp_map *rarp_lookup(int ifindex
48 + 6,
49 + };
50 +
51 ++#ifndef __UCLIBC__
52 + if (ether_ntohost(ename, lladdr) != 0 ||
53 ++#else
54 ++ if (
55 ++#endif
56 + (hp = gethostbyname(ename)) == NULL) {
57 + if (verbose)
58 + syslog(LOG_INFO, "not found in /etc/ethers");
59
60 diff --git a/net-misc/iputils/files/iputils-20100418-makefile.patch b/net-misc/iputils/files/iputils-20100418-makefile.patch
61 new file mode 100644
62 index 0000000..50a0e81
63 --- /dev/null
64 +++ b/net-misc/iputils/files/iputils-20100418-makefile.patch
65 @@ -0,0 +1,35 @@
66 +--- Makefile
67 ++++ Makefile
68 +@@ -1,20 +1,17 @@
69 + # Path to parent kernel include files directory
70 + LIBC_INCLUDE=/usr/include
71 +
72 +-DEFINES=
73 +-
74 + #options if you have a bind>=4.9.4 libresolv (or, maybe, glibc)
75 + LDLIBS=
76 +-ADDLIB=
77 +
78 + #options if you compile with libc5, and without a bind>=4.9.4 libresolv
79 + # NOT AVAILABLE. Please, use libresolv.
80 +
81 +-CC=gcc
82 + # What a pity, all new gccs are buggy and -Werror does not work. Sigh.
83 + #CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g -Werror
84 +-CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
85 +-CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
86 ++CFLAGS ?= -O2 -g
87 ++CFLAGS += -Wstrict-prototypes -Wall
88 ++CPPFLAGS += -D_GNU_SOURCE
89 +
90 + IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
91 + IPV6_TARGETS=tracepath6 traceroute6 ping6
92 +@@ -35,7 +32,7 @@
93 + rdisc_srv: rdisc_srv.o
94 +
95 + rdisc_srv.o: rdisc.c
96 +- $(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
97 ++ $(CC) $(CFLAGS) $(CPPFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
98 +
99 +
100 + check-kernel:
101
102 diff --git a/net-misc/iputils/files/iputils-20100418-printf-size.patch b/net-misc/iputils/files/iputils-20100418-printf-size.patch
103 new file mode 100644
104 index 0000000..edde65b
105 --- /dev/null
106 +++ b/net-misc/iputils/files/iputils-20100418-printf-size.patch
107 @@ -0,0 +1,62 @@
108 +From 6ccd3b91c18d8b13bc468ef962a9ef9dfc6c4515 Mon Sep 17 00:00:00 2001
109 +From: Mike Frysinger <vapier@g.o>
110 +Date: Sat, 14 Aug 2010 01:16:42 -0400
111 +Subject: [PATCH] tracepath: re-use printf return in print_host
112 +
113 +The printf funcs take an int for field widths, not a size_t. Also, since
114 +the printf funcs already return the length of chars displayed, use that
115 +value instead of re-calculating the length with strlen.
116 +
117 +Signed-off-by: Mike Frysinger <vapier@g.o>
118 +---
119 + tracepath.c | 11 ++++-------
120 + tracepath6.c | 11 ++++-------
121 + 2 files changed, 8 insertions(+), 14 deletions(-)
122 +
123 +diff --git a/tracepath.c b/tracepath.c
124 +index 81c22e9..ca84a69 100644
125 +--- a/tracepath.c
126 ++++ b/tracepath.c
127 +@@ -68,13 +68,10 @@ void data_wait(int fd)
128 +
129 + void print_host(const char *a, const char *b, int both)
130 + {
131 +- size_t plen = 0;
132 +- printf("%s", a);
133 +- plen = strlen(a);
134 +- if (both) {
135 +- printf(" (%s)", b);
136 +- plen += strlen(b) + 3;
137 +- }
138 ++ int plen;
139 ++ plen = printf("%s", a);
140 ++ if (both)
141 ++ plen += printf(" (%s)", b);
142 + if (plen >= HOST_COLUMN_SIZE)
143 + plen = HOST_COLUMN_SIZE - 1;
144 + printf("%*s", HOST_COLUMN_SIZE - plen, "");
145 +diff --git a/tracepath6.c b/tracepath6.c
146 +index 5cc7424..5c2db8f 100644
147 +--- a/tracepath6.c
148 ++++ b/tracepath6.c
149 +@@ -80,13 +80,10 @@ void data_wait(int fd)
150 +
151 + void print_host(const char *a, const char *b, int both)
152 + {
153 +- size_t plen = 0;
154 +- printf("%s", a);
155 +- plen = strlen(a);
156 +- if (both) {
157 +- printf(" (%s)", b);
158 +- plen += strlen(b) + 3;
159 +- }
160 ++ int plen;
161 ++ plen = printf("%s", a);
162 ++ if (both)
163 ++ plen += printf(" (%s)", b);
164 + if (plen >= HOST_COLUMN_SIZE)
165 + plen = HOST_COLUMN_SIZE - 1;
166 + printf("%*s", HOST_COLUMN_SIZE - plen, "");
167 +--
168 +1.7.1.1
169 +
170
171 diff --git a/net-misc/iputils/files/iputils-20100418-so_mark.patch b/net-misc/iputils/files/iputils-20100418-so_mark.patch
172 new file mode 100644
173 index 0000000..ad92254
174 --- /dev/null
175 +++ b/net-misc/iputils/files/iputils-20100418-so_mark.patch
176 @@ -0,0 +1,22 @@
177 +https://bugs.gentoo.org/335347
178 +
179 +fix building with older linux headers that don't define SO_MARK
180 +
181 +--- ping_common.c
182 ++++ ping_common.c
183 +@@ -485,6 +485,7 @@
184 + fprintf(stderr, "Warning: no SO_TIMESTAMP support, falling back to SIOCGSTAMP\n");
185 + }
186 + #endif
187 ++#ifdef SO_MARK
188 + if (options & F_MARK) {
189 + if (setsockopt(icmp_sock, SOL_SOCKET, SO_MARK,
190 + &mark, sizeof(mark)) == -1) {
191 +@@ -494,6 +495,7 @@
192 + fprintf(stderr, "Warning: Failed to set mark %d\n", mark);
193 + }
194 + }
195 ++#endif
196 +
197 + /* Set some SNDTIMEO to prevent blocking forever
198 + * on sends, when device is too slow or stalls. Just put limit
199
200 diff --git a/net-misc/iputils/files/iputils-20101006-owl-pingsock.diff b/net-misc/iputils/files/iputils-20101006-owl-pingsock.diff
201 new file mode 100644
202 index 0000000..86c85bc
203 --- /dev/null
204 +++ b/net-misc/iputils/files/iputils-20101006-owl-pingsock.diff
205 @@ -0,0 +1,224 @@
206 +http://openwall.info/wiki/people/segoon/ping
207 +
208 +--- iputils-s20101006/ping.c
209 ++++ iputils-s20101006/ping.c
210 +@@ -88,6 +88,7 @@ struct sockaddr_in whereto; /* who to pi
211 + int optlen = 0;
212 + int settos = 0; /* Set TOS, Precendence or other QOS options */
213 + int icmp_sock; /* socket file descriptor */
214 ++int using_ping_socket = 0;
215 + u_char outpack[0x10000];
216 + int maxpacket = sizeof(outpack);
217 +
218 +@@ -123,7 +124,11 @@ main(int argc, char **argv)
219 + char *target, hnamebuf[MAX_HOSTNAMELEN];
220 + char rspace[3 + 4 * NROUTES + 1]; /* record route space */
221 +
222 +- icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
223 ++ icmp_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
224 ++ if (icmp_sock != -1)
225 ++ using_ping_socket = 1;
226 ++ else
227 ++ icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
228 + socket_errno = errno;
229 +
230 + uid = getuid();
231 +@@ -377,13 +382,35 @@ main(int argc, char **argv)
232 + }
233 + }
234 +
235 +- if ((options&F_STRICTSOURCE) &&
236 +- bind(icmp_sock, (struct sockaddr*)&source, sizeof(source)) == -1) {
237 +- perror("bind");
238 +- exit(2);
239 ++ if (!using_ping_socket) {
240 ++ if ((options&F_STRICTSOURCE) &&
241 ++ bind(icmp_sock, (struct sockaddr*)&source, sizeof(source)) == -1) {
242 ++ perror("bind");
243 ++ exit(2);
244 ++ }
245 ++ } else {
246 ++ struct sockaddr_in sa;
247 ++ socklen_t sl;
248 ++
249 ++ sa.sin_family = AF_INET;
250 ++ sa.sin_port = 0;
251 ++ sa.sin_addr.s_addr = (options&F_STRICTSOURCE) ?
252 ++ source.sin_addr.s_addr : 0;
253 ++ sl = sizeof(sa);
254 ++
255 ++ if (bind(icmp_sock, (struct sockaddr *) &sa, sl) == -1) {
256 ++ perror("bind");
257 ++ exit(2);
258 ++ }
259 ++
260 ++ if (getsockname(icmp_sock, (struct sockaddr *) &sa, &sl) == -1) {
261 ++ perror("getsockname");
262 ++ exit(2);
263 ++ }
264 ++ ident = sa.sin_port;
265 + }
266 +
267 +- if (1) {
268 ++ if (!using_ping_socket) {
269 + struct icmp_filter filt;
270 + filt.data = ~((1<<ICMP_SOURCE_QUENCH)|
271 + (1<<ICMP_DEST_UNREACH)|
272 +@@ -398,6 +425,12 @@ main(int argc, char **argv)
273 + hold = 1;
274 + if (setsockopt(icmp_sock, SOL_IP, IP_RECVERR, (char *)&hold, sizeof(hold)))
275 + fprintf(stderr, "WARNING: your kernel is veeery old. No problems.\n");
276 ++ if (using_ping_socket) {
277 ++ if (setsockopt(icmp_sock, SOL_IP, IP_RECVTTL, (char *)&hold, sizeof(hold)))
278 ++ perror("WARNING: setsockopt(IP_RECVTTL)");
279 ++ if (setsockopt(icmp_sock, SOL_IP, IP_RETOPTS, (char *)&hold, sizeof(hold)))
280 ++ perror("WARNING: setsockopt(IP_RETOPTS)");
281 ++ }
282 +
283 + /* record route option */
284 + if (options & F_RROUTE) {
285 +@@ -566,6 +599,7 @@ int receive_error_msg()
286 + nerrors++;
287 + } else if (e->ee_origin == SO_EE_ORIGIN_ICMP) {
288 + struct sockaddr_in *sin = (struct sockaddr_in*)(e+1);
289 ++ int error_pkt;
290 +
291 + if (res < sizeof(icmph) ||
292 + target.sin_addr.s_addr != whereto.sin_addr.s_addr ||
293 +@@ -576,9 +610,18 @@ int receive_error_msg()
294 + goto out;
295 + }
296 +
297 +- acknowledge(ntohs(icmph.un.echo.sequence));
298 ++ error_pkt = (e->ee_type != ICMP_REDIRECT &&
299 ++ e->ee_type != ICMP_SOURCE_QUENCH);
300 ++ if (error_pkt) {
301 ++ acknowledge(ntohs(icmph.un.echo.sequence));
302 ++ net_errors++;
303 ++ nerrors++;
304 ++ }
305 ++ else {
306 ++ saved_errno = 0;
307 ++ }
308 +
309 +- if (!working_recverr) {
310 ++ if (!using_ping_socket && !working_recverr) {
311 + struct icmp_filter filt;
312 + working_recverr = 1;
313 + /* OK, it works. Add stronger filter. */
314 +@@ -589,15 +632,14 @@ int receive_error_msg()
315 + perror("\rWARNING: setsockopt(ICMP_FILTER)");
316 + }
317 +
318 +- net_errors++;
319 +- nerrors++;
320 + if (options & F_QUIET)
321 + goto out;
322 + if (options & F_FLOOD) {
323 +- write(STDOUT_FILENO, "\bE", 2);
324 ++ if (error_pkt)
325 ++ write(STDOUT_FILENO, "\bE", 2);
326 + } else {
327 + print_timestamp();
328 +- printf("From %s icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
329 ++ printf("From %s: icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
330 + pr_icmph(e->ee_type, e->ee_code, e->ee_info, NULL);
331 + fflush(stdout);
332 + }
333 +@@ -695,15 +737,41 @@ parse_reply(struct msghdr *msg, int cc,
334 + struct iphdr *ip;
335 + int hlen;
336 + int csfailed;
337 ++ struct cmsghdr *cmsg;
338 ++ int ttl;
339 ++ __u8 *opts;
340 ++ int optlen;
341 +
342 + /* Check the IP header */
343 + ip = (struct iphdr *)buf;
344 +- hlen = ip->ihl*4;
345 +- if (cc < hlen + 8 || ip->ihl < 5) {
346 +- if (options & F_VERBOSE)
347 +- fprintf(stderr, "ping: packet too short (%d bytes) from %s\n", cc,
348 +- pr_addr(from->sin_addr.s_addr));
349 +- return 1;
350 ++ if (!using_ping_socket) {
351 ++ hlen = ip->ihl*4;
352 ++ if (cc < hlen + 8 || ip->ihl < 5) {
353 ++ if (options & F_VERBOSE)
354 ++ fprintf(stderr, "ping: packet too short (%d bytes) from %s\n", cc,
355 ++ pr_addr(from->sin_addr.s_addr));
356 ++ return 1;
357 ++ }
358 ++ ttl = ip->ttl;
359 ++ opts = buf + sizeof(struct iphdr);
360 ++ optlen = hlen - sizeof(struct iphdr);
361 ++ } else {
362 ++ hlen = 0;
363 ++ ttl = 0;
364 ++ opts = buf;
365 ++ optlen = 0;
366 ++ for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
367 ++ if (cmsg->cmsg_level != SOL_IP)
368 ++ continue;
369 ++ if (cmsg->cmsg_type == IP_TTL) {
370 ++ if (cmsg->cmsg_len < sizeof(int))
371 ++ continue;
372 ++ ttl = *(int *) CMSG_DATA(cmsg);
373 ++ } else if (cmsg->cmsg_type == IP_RETOPTS) {
374 ++ opts = (__u8 *) CMSG_DATA(cmsg);
375 ++ optlen = cmsg->cmsg_len;
376 ++ }
377 ++ }
378 + }
379 +
380 + /* Now the ICMP part */
381 +@@ -716,7 +784,7 @@ parse_reply(struct msghdr *msg, int cc,
382 + return 1; /* 'Twas not our ECHO */
383 + if (gather_statistics((__u8*)icp, sizeof(*icp), cc,
384 + ntohs(icp->un.echo.sequence),
385 +- ip->ttl, 0, tv, pr_addr(from->sin_addr.s_addr),
386 ++ ttl, 0, tv, pr_addr(from->sin_addr.s_addr),
387 + pr_echo_reply))
388 + return 0;
389 + } else {
390 +@@ -807,7 +875,7 @@ parse_reply(struct msghdr *msg, int cc,
391 + }
392 +
393 + if (!(options & F_FLOOD)) {
394 +- pr_options(buf + sizeof(struct iphdr), hlen);
395 ++ pr_options(opts, optlen + sizeof(struct iphdr));
396 +
397 + if (options & F_AUDIBLE)
398 + putchar('\a');
399 +@@ -916,8 +984,7 @@ void pr_icmph(__u8 type, __u8 code, __u3
400 + printf("Redirect, Bad Code: %d", code);
401 + break;
402 + }
403 +- if (icp)
404 +- printf("(New nexthop: %s)\n", pr_addr(icp->un.gateway));
405 ++ printf("(New nexthop: %s)\n", pr_addr(icp ? icp->un.gateway : info));
406 + if (icp && (options & F_VERBOSE))
407 + pr_iph((struct iphdr*)(icp + 1));
408 + break;
409 +@@ -1217,7 +1284,7 @@ void install_filter(void)
410 + insns
411 + };
412 +
413 +- if (once)
414 ++ if (once || using_ping_socket)
415 + return;
416 + once = 1;
417 +
418 +--- iputils-s20101006/ping_common.c
419 ++++ iputils-s20101006/ping_common.c
420 +@@ -515,7 +515,8 @@ void setup(int icmp_sock)
421 + *p++ = i;
422 + }
423 +
424 +- ident = htons(getpid() & 0xFFFF);
425 ++ if (!ident)
426 ++ ident = htons(getpid() & 0xFFFF);
427 +
428 + set_signal(SIGINT, sigexit);
429 + set_signal(SIGALRM, sigexit);
430
431 diff --git a/net-misc/iputils/files/iputils-20121221-add-bits_types_h.patch b/net-misc/iputils/files/iputils-20121221-add-bits_types_h.patch
432 new file mode 100644
433 index 0000000..9ea3418
434 --- /dev/null
435 +++ b/net-misc/iputils/files/iputils-20121221-add-bits_types_h.patch
436 @@ -0,0 +1,94 @@
437 +diff -Naur iputils-s20121221.orig/clockdiff.c iputils-s20121221/clockdiff.c
438 +--- iputils-s20121221.orig/clockdiff.c 2014-01-24 15:32:49.111934548 +0000
439 ++++ iputils-s20121221/clockdiff.c 2014-01-24 15:32:14.438932610 +0000
440 +@@ -23,6 +23,8 @@
441 + #include <sys/capability.h>
442 + #endif
443 +
444 ++#include "types.h"
445 ++
446 + void usage(void) __attribute__((noreturn));
447 +
448 + #define MAX_HOSTNAMELEN NI_MAXHOST
449 +diff -Naur iputils-s20121221.orig/ping.c iputils-s20121221/ping.c
450 +--- iputils-s20121221.orig/ping.c 2014-01-24 15:32:49.111934548 +0000
451 ++++ iputils-s20121221/ping.c 2014-01-24 15:32:14.459932611 +0000
452 +@@ -59,6 +59,7 @@
453 + */
454 +
455 + #include "ping_common.h"
456 ++#include "types.h"
457 +
458 + #include <netinet/ip.h>
459 + #include <netinet/ip_icmp.h>
460 +diff -Naur iputils-s20121221.orig/ping6.c iputils-s20121221/ping6.c
461 +--- iputils-s20121221.orig/ping6.c 2014-01-24 15:32:49.112934549 +0000
462 ++++ iputils-s20121221/ping6.c 2014-01-24 15:32:14.439932610 +0000
463 +@@ -67,6 +67,7 @@
464 + * This program has to run SUID to ROOT to access the ICMP socket.
465 + */
466 + #include "ping_common.h"
467 ++#include "types.h"
468 +
469 + #include <linux/filter.h>
470 + #include <netinet/ip6.h>
471 +diff -Naur iputils-s20121221.orig/ping_common.c iputils-s20121221/ping_common.c
472 +--- iputils-s20121221.orig/ping_common.c 2014-01-24 15:32:49.112934549 +0000
473 ++++ iputils-s20121221/ping_common.c 2014-01-24 15:32:14.439932610 +0000
474 +@@ -1,4 +1,5 @@
475 + #include "ping_common.h"
476 ++#include "types.h"
477 + #include <ctype.h>
478 + #include <sched.h>
479 + #include <math.h>
480 +diff -Naur iputils-s20121221.orig/ping_common.h iputils-s20121221/ping_common.h
481 +--- iputils-s20121221.orig/ping_common.h 2014-01-24 15:32:14.419932609 +0000
482 ++++ iputils-s20121221/ping_common.h 2014-01-24 15:33:08.206935616 +0000
483 +@@ -35,6 +35,7 @@
484 + #include <linux/errqueue.h>
485 +
486 + #include "SNAPSHOT.h"
487 ++#include "types.h"
488 +
489 + #define DEFDATALEN (64 - 8) /* default data length */
490 +
491 +diff -Naur iputils-s20121221.orig/rdisc.c iputils-s20121221/rdisc.c
492 +--- iputils-s20121221.orig/rdisc.c 2014-01-24 15:32:49.113934549 +0000
493 ++++ iputils-s20121221/rdisc.c 2014-01-24 15:32:14.450932610 +0000
494 +@@ -62,6 +62,7 @@
495 + #include <syslog.h>
496 +
497 + #include "SNAPSHOT.h"
498 ++#include "types.h"
499 +
500 + struct interface
501 + {
502 +diff -Naur iputils-s20121221.orig/traceroute6.c iputils-s20121221/traceroute6.c
503 +--- iputils-s20121221.orig/traceroute6.c 2014-01-24 15:32:49.113934549 +0000
504 ++++ iputils-s20121221/traceroute6.c 2014-01-24 15:32:14.440932610 +0000
505 +@@ -267,6 +267,7 @@
506 + #include <string.h>
507 + #include <unistd.h>
508 +
509 ++#include "types.h"
510 + #include "SNAPSHOT.h"
511 +
512 + #ifndef SOL_IPV6
513 +diff -Naur iputils-s20121221.orig/types.h iputils-s20121221/types.h
514 +--- iputils-s20121221.orig/types.h 1970-01-01 00:00:00.000000000 +0000
515 ++++ iputils-s20121221/types.h 2014-01-24 15:32:14.440932610 +0000
516 +@@ -0,0 +1,14 @@
517 ++/* This is a small version of <bits/types.h> from glibc
518 ++ * to take care of type u_char.
519 ++ *
520 ++ * Anthony G. Basile <blueness@g.o>
521 ++ */
522 ++#ifndef _BITS_TYPES_H
523 ++#define _BITS_TYPES_H 1
524 ++
525 ++typedef unsigned char u_char;
526 ++typedef unsigned short int u_short;
527 ++typedef unsigned int u_int;
528 ++typedef unsigned long int u_long;
529 ++
530 ++#endif /* mini <bits/types.h> */
531
532 diff --git a/net-misc/iputils/files/iputils-20121221-crypto-build.patch b/net-misc/iputils/files/iputils-20121221-crypto-build.patch
533 new file mode 100644
534 index 0000000..1ec3c10
535 --- /dev/null
536 +++ b/net-misc/iputils/files/iputils-20121221-crypto-build.patch
537 @@ -0,0 +1,35 @@
538 +From 568e990d30fc7e9416e0a6f8c74ea5013921eaec Mon Sep 17 00:00:00 2001
539 +From: Arjan van de Ven <arjanvandeven@×××××.com>
540 +Date: Wed, 16 Jan 2013 03:12:15 +0900
541 +Subject: [PATCH [iputils]] ping6: Fix build command line argument with gnutls.
542 +
543 +The ping6 command can use either openssl or gnutls...
544 +and the Makefile has a bunch of setup for defining which of the two to use.
545 +
546 +Unfortunately, the final -D define on the commandline to enable gnutls
547 +inside the ping6.c file didn't actually make it onto the gcc
548 +commandline.
549 +This patch adds the $(DEF_CRYPTO) Makefile variable to fix this gap.
550 +
551 +Signed-off-by: Arjan van de Ven <arjanvandeven@×××××.com>
552 +Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@××××××××××.org>
553 +---
554 + Makefile | 2 +-
555 + 1 file changed, 1 insertion(+), 1 deletion(-)
556 +
557 +diff --git a/Makefile b/Makefile
558 +index c62d9df..89249f5 100644
559 +--- a/Makefile
560 ++++ b/Makefile
561 +@@ -149,7 +149,7 @@ LIB_clockdiff = $(LIB_CAP)
562 + DEF_ping_common = $(DEF_CAP) $(DEF_IDN)
563 + DEF_ping = $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS)
564 + LIB_ping = $(LIB_CAP) $(LIB_IDN)
565 +-DEF_ping6 = $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS) $(DEF_ENABLE_PING6_RTHDR)
566 ++DEF_ping6 = $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS) $(DEF_ENABLE_PING6_RTHDR) $(DEF_CRYPTO)
567 + LIB_ping6 = $(LIB_CAP) $(LIB_IDN) $(LIB_RESOLV) $(LIB_CRYPTO)
568 +
569 + ping: ping_common.o
570 +--
571 +1.8.0.2
572 +
573
574 diff --git a/net-misc/iputils/files/iputils-20121221-fix-init-elemnt.patch b/net-misc/iputils/files/iputils-20121221-fix-init-elemnt.patch
575 new file mode 100644
576 index 0000000..554ce9b
577 --- /dev/null
578 +++ b/net-misc/iputils/files/iputils-20121221-fix-init-elemnt.patch
579 @@ -0,0 +1,23 @@
580 +diff -Naur iputils-s20121221.orig/ping.c iputils-s20121221/ping.c
581 +--- iputils-s20121221.orig/ping.c 2014-01-24 15:05:02.082841335 +0000
582 ++++ iputils-s20121221/ping.c 2014-01-24 15:17:12.975882203 +0000
583 +@@ -774,9 +774,16 @@
584 +
585 + do {
586 + static struct iovec iov = {outpack, 0};
587 +- static struct msghdr m = { &whereto, sizeof(whereto),
588 +- &iov, 1, &cmsg, 0, 0 };
589 +- m.msg_controllen = cmsg_len;
590 ++ static struct msghdr m;
591 ++
592 ++ m.msg_name = &whereto;
593 ++ m.msg_namelen = sizeof(whereto);
594 ++ m.msg_iov = &iov;
595 ++ m.msg_iovlen = 1;
596 ++ m.msg_control = &cmsg;
597 ++ m.msg_controllen = sizeof(cmsg);
598 ++ m.msg_flags = 0;
599 ++
600 + iov.iov_len = cc;
601 +
602 + i = sendmsg(icmp_sock, &m, confirm);
603
604 diff --git a/net-misc/iputils/files/iputils-20121221-fix-musl-headers.patch b/net-misc/iputils/files/iputils-20121221-fix-musl-headers.patch
605 new file mode 100644
606 index 0000000..d12dd82
607 --- /dev/null
608 +++ b/net-misc/iputils/files/iputils-20121221-fix-musl-headers.patch
609 @@ -0,0 +1,89 @@
610 +diff -Naur iputils-s20121221.orig/arping.c iputils-s20121221/arping.c
611 +--- iputils-s20121221.orig/arping.c 2012-12-21 14:01:07.000000000 +0000
612 ++++ iputils-s20121221/arping.c 2014-01-23 21:19:57.091268011 +0000
613 +@@ -16,7 +16,7 @@
614 + #include <linux/sockios.h>
615 + #include <sys/file.h>
616 + #include <sys/time.h>
617 +-#include <sys/signal.h>
618 ++#include <signal.h>
619 + #include <sys/ioctl.h>
620 + #include <net/if.h>
621 + #include <linux/if_packet.h>
622 +--- iputils-s20121221.orig/clockdiff.c 2012-12-21 14:01:07.000000000 +0000
623 ++++ iputils-s20121221/clockdiff.c 2014-01-23 21:19:57.093268011 +0000
624 +@@ -14,7 +14,6 @@
625 + #include <netinet/ip.h>
626 + #include <netinet/ip_icmp.h>
627 + #define TSPTYPES
628 +-#include <protocols/timed.h>
629 + #include <fcntl.h>
630 + #include <netdb.h>
631 + #include <arpa/inet.h>
632 +diff -Naur iputils-s20121221.orig/ping_common.h iputils-s20121221/ping_common.h
633 +--- iputils-s20121221.orig/ping_common.h 2012-12-21 14:01:07.000000000 +0000
634 ++++ iputils-s20121221/ping_common.h 2014-01-23 21:27:07.677292088 +0000
635 +@@ -7,16 +7,17 @@
636 + #include <linux/sockios.h>
637 + #include <sys/file.h>
638 + #include <sys/time.h>
639 +-#include <sys/signal.h>
640 ++#include <signal.h>
641 + #include <sys/ioctl.h>
642 + #include <net/if.h>
643 + #include <sys/uio.h>
644 +-#include <sys/poll.h>
645 ++#include <poll.h>
646 + #include <ctype.h>
647 + #include <errno.h>
648 + #include <string.h>
649 + #include <netdb.h>
650 + #include <setjmp.h>
651 ++#include <asm-generic/param.h>
652 +
653 + #ifdef CAPABILITIES
654 + #include <sys/prctl.h>
655 +--- iputils-s20121221.orig/rarpd.c 2014-01-24 13:38:46.816551953 +0000
656 ++++ iputils-s20121221/rarpd.c 2014-01-24 13:36:51.833545524 +0000
657 +@@ -19,16 +19,17 @@
658 + #include <netdb.h>
659 + #include <arpa/inet.h>
660 + #include <sys/ioctl.h>
661 +-#include <sys/poll.h>
662 +-#include <sys/errno.h>
663 +-#include <sys/fcntl.h>
664 ++#include <poll.h>
665 ++#include <errno.h>
666 ++#include <fcntl.h>
667 + #include <sys/socket.h>
668 +-#include <sys/signal.h>
669 ++#include <signal.h>
670 + #include <linux/if.h>
671 + #include <linux/if_arp.h>
672 + #include <netinet/in.h>
673 + #include <linux/if_packet.h>
674 + #include <linux/filter.h>
675 ++#include <sys/types.h>
676 +
677 + int do_reload = 1;
678 +
679 +--- iputils-s20121221.orig/tracepath.c 2014-01-24 13:38:46.865551956 +0000
680 ++++ iputils-s20121221/tracepath.c 2014-01-23 21:19:57.109268012 +0000
681 +@@ -23,6 +23,7 @@
682 + #include <sys/time.h>
683 + #include <sys/uio.h>
684 + #include <arpa/inet.h>
685 ++#include <limits.h>
686 + #ifdef USE_IDN
687 + #include <idna.h>
688 + #include <locale.h>
689 +--- iputils-s20121221.orig/tracepath6.c 2014-01-24 13:38:46.865551956 +0000
690 ++++ iputils-s20121221/tracepath6.c 2014-01-23 21:20:40.316270428 +0000
691 +@@ -25,6 +25,7 @@
692 + #include <sys/time.h>
693 + #include <sys/uio.h>
694 + #include <arpa/inet.h>
695 ++#include <limits.h>
696 +
697 + #ifdef USE_IDN
698 + #include <idna.h>
699
700 diff --git a/net-misc/iputils/files/iputils-20121221-makefile.patch b/net-misc/iputils/files/iputils-20121221-makefile.patch
701 new file mode 100644
702 index 0000000..66424c8
703 --- /dev/null
704 +++ b/net-misc/iputils/files/iputils-20121221-makefile.patch
705 @@ -0,0 +1,61 @@
706 +From c66609d2c830d6fe06f48f5d38c54eb5cc6f2975 Mon Sep 17 00:00:00 2001
707 +From: Mike Frysinger <vapier@g.o>
708 +Date: Thu, 24 Jan 2013 23:36:16 -0500
709 +Subject: [PATCH [iputils]] fix handling of CFLAGS
710 +
711 +This defaults CFLAGS to -O3 without clobbering settings people have set
712 +up in the environment already.
713 +
714 +Signed-off-by: Mike Frysinger <vapier@g.o>
715 +---
716 + Makefile | 13 +++++--------
717 + 1 file changed, 5 insertions(+), 8 deletions(-)
718 +
719 +diff --git a/Makefile b/Makefile
720 +index 2c49940..ecabac3 100644
721 +--- a/Makefile
722 ++++ b/Makefile
723 +@@ -2,8 +2,6 @@
724 + # Configuration
725 + #
726 +
727 +-# CC
728 +-CC=gcc
729 + # Path to parent kernel include files directory
730 + LIBC_INCLUDE=/usr/include
731 + # Libraries
732 +@@ -48,11 +46,10 @@ ENABLE_RDISC_SERVER=no
733 +
734 + # -------------------------------------
735 + # What a pity, all new gccs are buggy and -Werror does not work. Sigh.
736 +-# CCOPT=-fno-strict-aliasing -Wstrict-prototypes -Wall -Werror -g
737 +-CCOPT=-fno-strict-aliasing -Wstrict-prototypes -Wall -g
738 +-CCOPTOPT=-O3
739 +-GLIBCFIX=-D_GNU_SOURCE
740 +-DEFINES=
741 ++# CFLAGS+=-fno-strict-aliasing -Wstrict-prototypes -Wall -Werror -g
742 ++CFLAGS?=-O3 -g
743 ++CFLAGS+=-fno-strict-aliasing -Wstrict-prototypes -Wall
744 ++CPPFLAGS+=-D_GNU_SOURCE
745 + LDLIB=
746 +
747 + FUNC_LIB = $(if $(filter static,$(1)),$(LDFLAG_STATIC) $(2) $(LDFLAG_DYNAMIC),$(2))
748 +@@ -113,7 +110,6 @@ IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
749 + IPV6_TARGETS=tracepath6 traceroute6 ping6
750 + TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
751 +
752 +-CFLAGS=$(CCOPTOPT) $(CCOPT) $(GLIBCFIX) $(DEFINES)
753 + LDLIBS=$(LDLIB) $(ADDLIB)
754 +
755 + UNAME_N:=$(shell uname -n)
756 +@@ -132,6 +128,7 @@ all: $(TARGETS)
757 + $(COMPILE.c) $< $(DEF_$(patsubst %.o,%,$@)) -S -o $@
758 + %.o: %.c
759 + $(COMPILE.c) $< $(DEF_$(patsubst %.o,%,$@)) -o $@
760 ++LINK.o += $(CFLAGS)
761 + $(TARGETS): %: %.o
762 + $(LINK.o) $^ $(LIB_$@) $(LDLIBS) -o $@
763 +
764 +--
765 +1.8.0.2
766 +
767
768 diff --git a/net-misc/iputils/files/iputils-20121221-openssl.patch b/net-misc/iputils/files/iputils-20121221-openssl.patch
769 new file mode 100644
770 index 0000000..1c6ba81
771 --- /dev/null
772 +++ b/net-misc/iputils/files/iputils-20121221-openssl.patch
773 @@ -0,0 +1,92 @@
774 +From b57d77dcfa5cb363b7eba5b331324669a8505ac4 Mon Sep 17 00:00:00 2001
775 +From: Mike Frysinger <vapier@g.o>
776 +Date: Thu, 24 Jan 2013 23:32:39 -0500
777 +Subject: [PATCH [iputils]] ping6: allow disabling of openssl support
778 +
779 +Signed-off-by: Mike Frysinger <vapier@g.o>
780 +---
781 + Makefile | 5 ++++-
782 + ping6.c | 14 +++++++++++++-
783 + 2 files changed, 17 insertions(+), 2 deletions(-)
784 +
785 +diff --git a/Makefile b/Makefile
786 +index 89249f5..2c49940 100644
787 +--- a/Makefile
788 ++++ b/Makefile
789 +@@ -36,7 +36,7 @@ ARPING_DEFAULT_DEVICE=
790 +
791 + # GNU TLS library for ping6 [yes|no|static]
792 + USE_GNUTLS=yes
793 +-# Crypto library for ping6 [shared|static]
794 ++# Crypto library for ping6 [shared|static|no]
795 + USE_CRYPTO=shared
796 + # Resolv library for ping6 [yes|static]
797 + USE_RESOLV=yes
798 +@@ -63,7 +63,10 @@ ifneq ($(USE_GNUTLS),no)
799 + LIB_CRYPTO = $(call FUNC_LIB,$(USE_GNUTLS),$(LDFLAG_GNUTLS))
800 + DEF_CRYPTO = -DUSE_GNUTLS
801 + else
802 ++ifneq ($(USE_CRYPTO),no)
803 + LIB_CRYPTO = $(call FUNC_LIB,$(USE_CRYPTO),$(LDFLAG_CRYPTO))
804 ++ DEF_CRYPTO = -DUSE_OPENSSL
805 ++endif
806 + endif
807 +
808 + # USE_RESOLV: LIB_RESOLV
809 +diff --git a/ping6.c b/ping6.c
810 +index c39864d..f2f90af 100644
811 +--- a/ping6.c
812 ++++ b/ping6.c
813 +@@ -168,8 +168,10 @@ static int icmp_sock;
814 +
815 + #ifdef USE_GNUTLS
816 + # include <gnutls/openssl.h>
817 +-#else
818 ++# define USE_CRYPTO
819 ++#elif defined USE_OPENSSL
820 + # include <openssl/md5.h>
821 ++# define USE_CRYPTO
822 + #endif
823 +
824 + /* Node Information query */
825 +@@ -326,6 +328,7 @@ static void niquery_init_nonce(void)
826 + #if !PING6_NONCE_MEMORY
827 + static int niquery_nonce(__u8 *nonce, int fill)
828 + {
829 ++# ifdef USE_CRYPTO
830 + static __u8 digest[MD5_DIGEST_LENGTH];
831 + static int seq = -1;
832 +
833 +@@ -348,6 +351,10 @@ static int niquery_nonce(__u8 *nonce, int fill)
834 + return -1;
835 + return ntohsp((__u16 *)nonce);
836 + }
837 ++# else
838 ++ fprintf(stderr, "ping6: function not available; crypto disabled\n");
839 ++ exit(3);
840 ++# endif
841 + }
842 + #endif
843 +
844 +@@ -502,6 +509,7 @@ static int niquery_option_subject_addr_handler(int index, const char *arg)
845 +
846 + static int niquery_option_subject_name_handler(int index, const char *arg)
847 + {
848 ++#ifdef USE_CRYPTO
849 + static char nigroup_buf[INET6_ADDRSTRLEN + 1 + IFNAMSIZ];
850 + unsigned char *dnptrs[2], **dpp, **lastdnptr;
851 + int n;
852 +@@ -627,6 +635,10 @@ errexit:
853 + free(idn);
854 + free(name);
855 + exit(1);
856 ++#else
857 ++ fprintf(stderr, "ping6: function not available; crypto disabled\n");
858 ++ exit(3);
859 ++#endif
860 + }
861 +
862 + int niquery_option_help_handler(int index, const char *arg)
863 +--
864 +1.8.0.2
865 +
866
867 diff --git a/net-misc/iputils/files/iputils-20121221-owl-pingsock.diff b/net-misc/iputils/files/iputils-20121221-owl-pingsock.diff
868 new file mode 100644
869 index 0000000..283aa98
870 --- /dev/null
871 +++ b/net-misc/iputils/files/iputils-20121221-owl-pingsock.diff
872 @@ -0,0 +1,224 @@
873 +http://openwall.info/wiki/people/segoon/ping
874 +
875 +--- iputils-s20101006/ping.c
876 ++++ iputils-s20101006/ping.c
877 +@@ -88,6 +88,7 @@ struct sockaddr_in whereto; /* who to pi
878 + int optlen = 0;
879 + int settos = 0; /* Set TOS, Precendence or other QOS options */
880 + int icmp_sock; /* socket file descriptor */
881 ++int using_ping_socket = 0;
882 + u_char outpack[0x10000];
883 + int maxpacket = sizeof(outpack);
884 +
885 +@@ -123,7 +124,11 @@ main(int argc, char **argv)
886 + char *target, hnamebuf[MAX_HOSTNAMELEN];
887 + char rspace[3 + 4 * NROUTES + 1]; /* record route space */
888 +
889 +- icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
890 ++ icmp_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
891 ++ if (icmp_sock != -1)
892 ++ using_ping_socket = 1;
893 ++ else
894 ++ icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
895 + socket_errno = errno;
896 +
897 + uid = getuid();
898 +@@ -377,13 +382,35 @@ main(int argc, char **argv)
899 + }
900 + }
901 +
902 +- if ((options&F_STRICTSOURCE) &&
903 +- bind(icmp_sock, (struct sockaddr*)&source, sizeof(source)) == -1) {
904 +- perror("bind");
905 +- exit(2);
906 ++ if (!using_ping_socket) {
907 ++ if ((options&F_STRICTSOURCE) &&
908 ++ bind(icmp_sock, (struct sockaddr*)&source, sizeof(source)) == -1) {
909 ++ perror("bind");
910 ++ exit(2);
911 ++ }
912 ++ } else {
913 ++ struct sockaddr_in sa;
914 ++ socklen_t sl;
915 ++
916 ++ sa.sin_family = AF_INET;
917 ++ sa.sin_port = 0;
918 ++ sa.sin_addr.s_addr = (options&F_STRICTSOURCE) ?
919 ++ source.sin_addr.s_addr : 0;
920 ++ sl = sizeof(sa);
921 ++
922 ++ if (bind(icmp_sock, (struct sockaddr *) &sa, sl) == -1) {
923 ++ perror("bind");
924 ++ exit(2);
925 ++ }
926 ++
927 ++ if (getsockname(icmp_sock, (struct sockaddr *) &sa, &sl) == -1) {
928 ++ perror("getsockname");
929 ++ exit(2);
930 ++ }
931 ++ ident = sa.sin_port;
932 + }
933 +
934 +- if (1) {
935 ++ if (!using_ping_socket) {
936 + struct icmp_filter filt;
937 + filt.data = ~((1<<ICMP_SOURCE_QUENCH)|
938 + (1<<ICMP_DEST_UNREACH)|
939 +@@ -398,6 +425,12 @@ main(int argc, char **argv)
940 + hold = 1;
941 + if (setsockopt(icmp_sock, SOL_IP, IP_RECVERR, (char *)&hold, sizeof(hold)))
942 + fprintf(stderr, "WARNING: your kernel is veeery old. No problems.\n");
943 ++ if (using_ping_socket) {
944 ++ if (setsockopt(icmp_sock, SOL_IP, IP_RECVTTL, (char *)&hold, sizeof(hold)))
945 ++ perror("WARNING: setsockopt(IP_RECVTTL)");
946 ++ if (setsockopt(icmp_sock, SOL_IP, IP_RETOPTS, (char *)&hold, sizeof(hold)))
947 ++ perror("WARNING: setsockopt(IP_RETOPTS)");
948 ++ }
949 +
950 + /* record route option */
951 + if (options & F_RROUTE) {
952 +@@ -566,6 +599,7 @@ int receive_error_msg()
953 + nerrors++;
954 + } else if (e->ee_origin == SO_EE_ORIGIN_ICMP) {
955 + struct sockaddr_in *sin = (struct sockaddr_in*)(e+1);
956 ++ int error_pkt;
957 +
958 + if (res < sizeof(icmph) ||
959 + target.sin_addr.s_addr != whereto.sin_addr.s_addr ||
960 +@@ -576,9 +610,18 @@ int receive_error_msg()
961 + goto out;
962 + }
963 +
964 +- acknowledge(ntohs(icmph.un.echo.sequence));
965 ++ error_pkt = (e->ee_type != ICMP_REDIRECT &&
966 ++ e->ee_type != ICMP_SOURCE_QUENCH);
967 ++ if (error_pkt) {
968 ++ acknowledge(ntohs(icmph.un.echo.sequence));
969 ++ net_errors++;
970 ++ nerrors++;
971 ++ }
972 ++ else {
973 ++ saved_errno = 0;
974 ++ }
975 +
976 +- if (!working_recverr) {
977 ++ if (!using_ping_socket && !working_recverr) {
978 + struct icmp_filter filt;
979 + working_recverr = 1;
980 + /* OK, it works. Add stronger filter. */
981 +@@ -589,15 +632,14 @@ int receive_error_msg()
982 + perror("\rWARNING: setsockopt(ICMP_FILTER)");
983 + }
984 +
985 +- net_errors++;
986 +- nerrors++;
987 + if (options & F_QUIET)
988 + goto out;
989 + if (options & F_FLOOD) {
990 +- write_stdout("\bE", 2);
991 ++ if (error_pkt)
992 ++ write_stdout("\bE", 2);
993 + } else {
994 + print_timestamp();
995 +- printf("From %s icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
996 ++ printf("From %s: icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
997 + pr_icmph(e->ee_type, e->ee_code, e->ee_info, NULL);
998 + fflush(stdout);
999 + }
1000 +@@ -695,15 +737,41 @@ parse_reply(struct msghdr *msg, int cc,
1001 + struct iphdr *ip;
1002 + int hlen;
1003 + int csfailed;
1004 ++ struct cmsghdr *cmsg;
1005 ++ int ttl;
1006 ++ __u8 *opts;
1007 ++ int optlen;
1008 +
1009 + /* Check the IP header */
1010 + ip = (struct iphdr *)buf;
1011 +- hlen = ip->ihl*4;
1012 +- if (cc < hlen + 8 || ip->ihl < 5) {
1013 +- if (options & F_VERBOSE)
1014 +- fprintf(stderr, "ping: packet too short (%d bytes) from %s\n", cc,
1015 +- pr_addr(from->sin_addr.s_addr));
1016 +- return 1;
1017 ++ if (!using_ping_socket) {
1018 ++ hlen = ip->ihl*4;
1019 ++ if (cc < hlen + 8 || ip->ihl < 5) {
1020 ++ if (options & F_VERBOSE)
1021 ++ fprintf(stderr, "ping: packet too short (%d bytes) from %s\n", cc,
1022 ++ pr_addr(from->sin_addr.s_addr));
1023 ++ return 1;
1024 ++ }
1025 ++ ttl = ip->ttl;
1026 ++ opts = buf + sizeof(struct iphdr);
1027 ++ optlen = hlen - sizeof(struct iphdr);
1028 ++ } else {
1029 ++ hlen = 0;
1030 ++ ttl = 0;
1031 ++ opts = buf;
1032 ++ optlen = 0;
1033 ++ for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
1034 ++ if (cmsg->cmsg_level != SOL_IP)
1035 ++ continue;
1036 ++ if (cmsg->cmsg_type == IP_TTL) {
1037 ++ if (cmsg->cmsg_len < sizeof(int))
1038 ++ continue;
1039 ++ ttl = *(int *) CMSG_DATA(cmsg);
1040 ++ } else if (cmsg->cmsg_type == IP_RETOPTS) {
1041 ++ opts = (__u8 *) CMSG_DATA(cmsg);
1042 ++ optlen = cmsg->cmsg_len;
1043 ++ }
1044 ++ }
1045 + }
1046 +
1047 + /* Now the ICMP part */
1048 +@@ -716,7 +784,7 @@ parse_reply(struct msghdr *msg, int cc,
1049 + return 1; /* 'Twas not our ECHO */
1050 + if (gather_statistics((__u8*)icp, sizeof(*icp), cc,
1051 + ntohs(icp->un.echo.sequence),
1052 +- ip->ttl, 0, tv, pr_addr(from->sin_addr.s_addr),
1053 ++ ttl, 0, tv, pr_addr(from->sin_addr.s_addr),
1054 + pr_echo_reply))
1055 + return 0;
1056 + } else {
1057 +@@ -807,7 +875,7 @@ parse_reply(struct msghdr *msg, int cc,
1058 + }
1059 +
1060 + if (!(options & F_FLOOD)) {
1061 +- pr_options(buf + sizeof(struct iphdr), hlen);
1062 ++ pr_options(opts, optlen + sizeof(struct iphdr));
1063 +
1064 + if (options & F_AUDIBLE)
1065 + putchar('\a');
1066 +@@ -916,8 +984,7 @@ void pr_icmph(__u8 type, __u8 code, __u3
1067 + printf("Redirect, Bad Code: %d", code);
1068 + break;
1069 + }
1070 +- if (icp)
1071 +- printf("(New nexthop: %s)\n", pr_addr(icp->un.gateway));
1072 ++ printf("(New nexthop: %s)\n", pr_addr(icp ? icp->un.gateway : info));
1073 + if (icp && (options & F_VERBOSE))
1074 + pr_iph((struct iphdr*)(icp + 1));
1075 + break;
1076 +@@ -1217,7 +1284,7 @@ void install_filter(void)
1077 + insns
1078 + };
1079 +
1080 +- if (once)
1081 ++ if (once || using_ping_socket)
1082 + return;
1083 + once = 1;
1084 +
1085 +--- iputils-s20101006/ping_common.c
1086 ++++ iputils-s20101006/ping_common.c
1087 +@@ -515,7 +515,8 @@ void setup(int icmp_sock)
1088 + *p++ = i;
1089 + }
1090 +
1091 +- ident = htons(getpid() & 0xFFFF);
1092 ++ if (!ident)
1093 ++ ident = htons(getpid() & 0xFFFF);
1094 +
1095 + set_signal(SIGINT, sigexit);
1096 + set_signal(SIGALRM, sigexit);
1097
1098 diff --git a/net-misc/iputils/files/iputils-20121221-printf-size.patch b/net-misc/iputils/files/iputils-20121221-printf-size.patch
1099 new file mode 100644
1100 index 0000000..6d6c3b7
1101 --- /dev/null
1102 +++ b/net-misc/iputils/files/iputils-20121221-printf-size.patch
1103 @@ -0,0 +1,64 @@
1104 +From 23fcb10ae15a96aa9e5a823cfe0b612d9522691c Mon Sep 17 00:00:00 2001
1105 +From: Mike Frysinger <vapier@g.o>
1106 +Date: Sat, 14 Aug 2010 01:16:42 -0400
1107 +Subject: [PATCH [iputils]] tracepath: re-use printf return in print_host
1108 +
1109 +Since the printf funcs already return the length of chars displayed,
1110 +use that value instead of re-calculating the length with strlen.
1111 +
1112 +This also fixes the handling of the strlen return -- it's a size_t,
1113 +not an int.
1114 +
1115 +Signed-off-by: Mike Frysinger <vapier@g.o>
1116 +---
1117 + tracepath.c | 11 ++++-------
1118 + tracepath6.c | 11 ++++-------
1119 + 2 files changed, 8 insertions(+), 14 deletions(-)
1120 +
1121 +diff --git a/tracepath.c b/tracepath.c
1122 +index 8a08f1d..f155816 100644
1123 +--- a/tracepath.c
1124 ++++ b/tracepath.c
1125 +@@ -73,13 +73,10 @@ void data_wait(int fd)
1126 +
1127 + void print_host(const char *a, const char *b, int both)
1128 + {
1129 +- int plen = 0;
1130 +- printf("%s", a);
1131 +- plen = strlen(a);
1132 +- if (both) {
1133 +- printf(" (%s)", b);
1134 +- plen += strlen(b) + 3;
1135 +- }
1136 ++ int plen;
1137 ++ plen = printf("%s", a);
1138 ++ if (both)
1139 ++ plen += printf(" (%s)", b);
1140 + if (plen >= HOST_COLUMN_SIZE)
1141 + plen = HOST_COLUMN_SIZE - 1;
1142 + printf("%*s", HOST_COLUMN_SIZE - plen, "");
1143 +diff --git a/tracepath6.c b/tracepath6.c
1144 +index 126fadf..bee95c3 100644
1145 +--- a/tracepath6.c
1146 ++++ b/tracepath6.c
1147 +@@ -86,13 +86,10 @@ void data_wait(int fd)
1148 +
1149 + void print_host(const char *a, const char *b, int both)
1150 + {
1151 +- int plen = 0;
1152 +- printf("%s", a);
1153 +- plen = strlen(a);
1154 +- if (both) {
1155 +- printf(" (%s)", b);
1156 +- plen += strlen(b) + 3;
1157 +- }
1158 ++ int plen;
1159 ++ plen = printf("%s", a);
1160 ++ if (both)
1161 ++ plen += printf(" (%s)", b);
1162 + if (plen >= HOST_COLUMN_SIZE)
1163 + plen = HOST_COLUMN_SIZE - 1;
1164 + printf("%*s", HOST_COLUMN_SIZE - plen, "");
1165 +--
1166 +1.8.0.2
1167 +
1168
1169 diff --git a/net-misc/iputils/files/iputils-20121221-remove-rdisc-glibc-assumption.patch b/net-misc/iputils/files/iputils-20121221-remove-rdisc-glibc-assumption.patch
1170 new file mode 100644
1171 index 0000000..08e764d
1172 --- /dev/null
1173 +++ b/net-misc/iputils/files/iputils-20121221-remove-rdisc-glibc-assumption.patch
1174 @@ -0,0 +1,30 @@
1175 +diff -Naur iputils-s20121221.orig/rdisc.c iputils-s20121221/rdisc.c
1176 +--- iputils-s20121221.orig/rdisc.c 2014-01-24 14:59:29.937822762 +0000
1177 ++++ iputils-s20121221/rdisc.c 2014-01-23 21:25:58.760288234 +0000
1178 +@@ -115,26 +114,7 @@
1179 +
1180 + #define MAXIFS 32
1181 +
1182 +-#if !defined(__GLIBC__) || __GLIBC__ < 2
1183 +-/* For router advertisement */
1184 +-struct icmp_ra
1185 +-{
1186 +- u_char icmp_type; /* type of message, see below */
1187 +- u_char icmp_code; /* type sub code */
1188 +- u_short icmp_cksum; /* ones complement cksum of struct */
1189 +- u_char icmp_num_addrs;
1190 +- u_char icmp_wpa; /* Words per address */
1191 +- short icmp_lifetime;
1192 +-};
1193 +-
1194 +-struct icmp_ra_addr
1195 +-{
1196 +- __u32 ira_addr;
1197 +- __u32 ira_preference;
1198 +-};
1199 +-#else
1200 + #define icmp_ra icmp
1201 +-#endif
1202 +
1203 + /* Router constants */
1204 + #define MAX_INITIAL_ADVERT_INTERVAL 16
1205
1206 diff --git a/net-misc/iputils/iputils-20121221-r99.ebuild b/net-misc/iputils/iputils-20121221-r99.ebuild
1207 new file mode 100644
1208 index 0000000..96dee02
1209 --- /dev/null
1210 +++ b/net-misc/iputils/iputils-20121221-r99.ebuild
1211 @@ -0,0 +1,103 @@
1212 +# Copyright 1999-2014 Gentoo Foundation
1213 +# Distributed under the terms of the GNU General Public License v2
1214 +# $Header: /var/cvsroot/gentoo-x86/net-misc/iputils/iputils-20121221.ebuild,v 1.16 2014/01/18 05:37:45 vapier Exp $
1215 +
1216 +# For released versions, we precompile the man/html pages and store
1217 +# them in a tarball on our mirrors. This avoids ugly issues while
1218 +# building stages, and when the jade/sgml packages are broken (which
1219 +# seems to be more common than would be nice).
1220 +
1221 +EAPI="4"
1222 +
1223 +inherit flag-o-matic eutils toolchain-funcs
1224 +if [[ ${PV} == "99999999" ]] ; then
1225 + EGIT_REPO_URI="git://www.linux-ipv6.org/gitroot/iputils"
1226 + inherit git-2
1227 +else
1228 + SRC_URI="http://www.skbuff.net/iputils/iputils-s${PV}.tar.bz2
1229 + mirror://gentoo/iputils-s${PV}-manpages.tar.bz2"
1230 + KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-linux ~x86-linux"
1231 +fi
1232 +
1233 +DESCRIPTION="Network monitoring tools including ping and ping6"
1234 +HOMEPAGE="http://www.linuxfoundation.org/collaborate/workgroups/networking/iputils"
1235 +
1236 +LICENSE="BSD-4"
1237 +SLOT="0"
1238 +IUSE="caps doc gnutls idn ipv6 SECURITY_HAZARD ssl static"
1239 +
1240 +LIB_DEPEND="caps? ( sys-libs/libcap[static-libs(+)] )
1241 + idn? ( net-dns/libidn[static-libs(+)] )
1242 + ipv6? (
1243 + gnutls? ( net-libs/gnutls[static-libs(+)] )
1244 + ssl? ( dev-libs/openssl:0[static-libs(+)] )
1245 + )"
1246 +RDEPEND="!net-misc/rarpd
1247 + !static? ( ${LIB_DEPEND//\[static-libs(+)]} )"
1248 +DEPEND="${RDEPEND}
1249 + static? ( ${LIB_DEPEND} )
1250 + virtual/os-headers"
1251 +if [[ ${PV} == "99999999" ]] ; then
1252 + DEPEND+="
1253 + app-text/openjade
1254 + dev-perl/SGMLSpm
1255 + app-text/docbook-sgml-dtd
1256 + app-text/docbook-sgml-utils
1257 + "
1258 +fi
1259 +
1260 +S=${WORKDIR}/${PN}-s${PV}
1261 +
1262 +src_prepare() {
1263 + epatch "${FILESDIR}"/021109-uclibc-no-ether_ntohost.patch
1264 + epatch "${FILESDIR}"/${PN}-20121221-openssl.patch #335436
1265 + epatch "${FILESDIR}"/${PN}-20121221-crypto-build.patch
1266 + epatch "${FILESDIR}"/${PN}-20100418-so_mark.patch #335347
1267 + epatch "${FILESDIR}"/${PN}-20121221-makefile.patch
1268 + epatch "${FILESDIR}"/${PN}-20121221-printf-size.patch
1269 + epatch "${FILESDIR}"/${PN}-20121221-owl-pingsock.diff
1270 + epatch "${FILESDIR}"/${PN}-20121221-fix-musl-headers.patch
1271 + epatch "${FILESDIR}"/${PN}-20121221-add-bits_types_h.patch
1272 + epatch "${FILESDIR}"/${PN}-20121221-remove-rdisc-glibc-assumption.patch
1273 + epatch "${FILESDIR}"/${PN}-20121221-fix-init-elemnt.patch
1274 + use SECURITY_HAZARD && epatch "${FILESDIR}"/${PN}-20071127-nonroot-floodping.patch
1275 + use static && append-ldflags -static
1276 +}
1277 +
1278 +src_compile() {
1279 + tc-export CC
1280 + append-cppflags -I.
1281 + emake -j1 \
1282 + USE_CAP=$(usex caps) \
1283 + USE_IDN=$(usex idn) \
1284 + USE_GNUTLS=$(usex gnutls) \
1285 + USE_CRYPTO=$(usex ssl) \
1286 + $(use ipv6 || echo IPV6_TARGETS=)
1287 +
1288 + if [[ ${PV} == "99999999" ]] ; then
1289 + emake -j1 html man
1290 + fi
1291 +}
1292 +
1293 +src_install() {
1294 + into /
1295 + dobin ping
1296 + use ipv6 && dobin ping6
1297 + dosbin arping
1298 + into /usr
1299 + dosbin tracepath
1300 + use ipv6 && dosbin trace{path,route}6
1301 + dosbin clockdiff rarpd rdisc ipg tftpd
1302 +
1303 + fperms 4711 /bin/ping
1304 + use ipv6 && fperms 4711 /bin/ping6 /usr/sbin/traceroute6
1305 +
1306 + dodoc INSTALL RELNOTES
1307 + use ipv6 \
1308 + && dosym ping.8 /usr/share/man/man8/ping6.8 \
1309 + || rm -f doc/*6.8
1310 + rm -f doc/setkey.8
1311 + doman doc/*.8
1312 +
1313 + use doc && dohtml doc/*.html
1314 +}
1315
1316 diff --git a/net-misc/iputils/metadata.xml b/net-misc/iputils/metadata.xml
1317 new file mode 100644
1318 index 0000000..5c2d8fe
1319 --- /dev/null
1320 +++ b/net-misc/iputils/metadata.xml
1321 @@ -0,0 +1,11 @@
1322 +<?xml version="1.0" encoding="UTF-8"?>
1323 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
1324 +<pkgmetadata>
1325 + <herd>base-system</herd>
1326 + <use>
1327 + <flag name="SECURITY_HAZARD">Allow non-root users to flood (ping -f). This is generally a very bad idea.</flag>
1328 + </use>
1329 + <upstream>
1330 + <remote-id type="cpe">cpe:/a:skbuff:iputils</remote-id>
1331 + </upstream>
1332 +</pkgmetadata>