diff options
Diffstat (limited to 'main/busybox/0006-ping-make-ping-work-without-root-privileges.patch')
-rw-r--r-- | main/busybox/0006-ping-make-ping-work-without-root-privileges.patch | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/main/busybox/0006-ping-make-ping-work-without-root-privileges.patch b/main/busybox/0006-ping-make-ping-work-without-root-privileges.patch index 630619b4a87..9bdeb7208de 100644 --- a/main/busybox/0006-ping-make-ping-work-without-root-privileges.patch +++ b/main/busybox/0006-ping-make-ping-work-without-root-privileges.patch @@ -1,17 +1,17 @@ -From 21d74f2989d0046e5b7c586f5a052643d5da8dcc Mon Sep 17 00:00:00 2001 +From 9513a2daae84660f2ddd7d60d39bb49cd678adbe Mon Sep 17 00:00:00 2001 From: Natanael Copa <ncopa@alpinelinux.org> Date: Tue, 29 Mar 2016 18:59:22 +0200 -Subject: [PATCH 06/16] ping: make ping work without root privileges +Subject: [PATCH] ping: make ping work without root privileges --- - networking/ping.c | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- + networking/ping.c | 103 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 16 deletions(-) diff --git a/networking/ping.c b/networking/ping.c -index d1d59d545..c0ebc0f9a 100644 +index 8f85d3ec2..dc3f50968 100644 --- a/networking/ping.c +++ b/networking/ping.c -@@ -163,6 +163,7 @@ enum { +@@ -165,6 +165,7 @@ enum { pingsock = 0, }; @@ -19,7 +19,7 @@ index d1d59d545..c0ebc0f9a 100644 static void #if ENABLE_PING6 create_icmp_socket(len_and_sockaddr *lsa) -@@ -179,9 +180,23 @@ create_icmp_socket(void) +@@ -181,9 +182,23 @@ create_icmp_socket(void) #endif sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */ if (sock < 0) { @@ -46,7 +46,7 @@ index d1d59d545..c0ebc0f9a 100644 } xmove_fd(sock, pingsock); -@@ -234,10 +249,12 @@ static void ping4(len_and_sockaddr *lsa) +@@ -236,10 +251,12 @@ static void ping4(len_and_sockaddr *lsa) bb_perror_msg("recvfrom"); continue; } @@ -62,9 +62,9 @@ index d1d59d545..c0ebc0f9a 100644 if (pkt->icmp_id != G.myid) continue; /* not our ping */ if (pkt->icmp_type == ICMP_ECHOREPLY) -@@ -634,19 +651,21 @@ static void unpack_tail(int sz, uint32_t *tp, +@@ -636,19 +653,21 @@ static void unpack_tail(int sz, uint32_t *tp, } - static void unpack4(char *buf, int sz, struct sockaddr_in *from) + static int unpack4(char *buf, int sz, struct sockaddr_in *from) { - struct icmp *icmppkt; struct iphdr *iphdr; @@ -73,7 +73,7 @@ index d1d59d545..c0ebc0f9a 100644 /* discard if too short */ if (sz < (datalen + ICMP_MINLEN)) - return; + return 0; + if(!using_dgram) { + /* check IP header */ + iphdr = (struct iphdr *) buf; @@ -88,18 +88,18 @@ index d1d59d545..c0ebc0f9a 100644 - sz -= hlen; - icmppkt = (struct icmp *) (buf + hlen); if (icmppkt->icmp_id != myid) - return; /* not our ping */ + return 0; /* not our ping */ -@@ -658,7 +677,7 @@ static void unpack4(char *buf, int sz, struct sockaddr_in *from) +@@ -660,7 +679,7 @@ static int unpack4(char *buf, int sz, struct sockaddr_in *from) tp = (uint32_t *) icmppkt->icmp_data; unpack_tail(sz, tp, inet_ntoa(*(struct in_addr *) &from->sin_addr.s_addr), - recv_seq, iphdr->ttl); + recv_seq, using_dgram ? 42 : iphdr->ttl); - } else if (icmppkt->icmp_type != ICMP_ECHO) { - bb_error_msg("warning: got ICMP %d (%s)", - icmppkt->icmp_type, -@@ -702,11 +721,31 @@ static void ping4(len_and_sockaddr *lsa) + return 1; + } + if (icmppkt->icmp_type != ICMP_ECHO) { +@@ -710,11 +729,31 @@ static void ping4(len_and_sockaddr *lsa) int sockopt; pingaddr.sin = lsa->u.sin; @@ -132,7 +132,7 @@ index d1d59d545..c0ebc0f9a 100644 } /* enable broadcast pings */ -@@ -723,6 +762,15 @@ static void ping4(len_and_sockaddr *lsa) +@@ -731,6 +770,15 @@ static void ping4(len_and_sockaddr *lsa) setsockopt_int(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, opt_ttl); } @@ -148,7 +148,7 @@ index d1d59d545..c0ebc0f9a 100644 signal(SIGINT, print_stats_and_exit); /* start the ping's going ... */ -@@ -756,10 +804,33 @@ static void ping6(len_and_sockaddr *lsa) +@@ -768,10 +816,33 @@ static void ping6(len_and_sockaddr *lsa) char control_buf[CMSG_SPACE(36)]; pingaddr.sin6 = lsa->u.sin6; @@ -183,15 +183,12 @@ index d1d59d545..c0ebc0f9a 100644 { struct icmp6_filter filt; if (!(option_mask32 & OPT_VERBOSE)) { -@@ -890,7 +961,7 @@ static int common_ping_main(int opt, char **argv) - if (opt & OPT_p) - G.pattern = xstrtou_range(str_p, 16, 0, 255); +@@ -911,7 +982,7 @@ static int common_ping_main(int opt, char **argv) + G.deadline_us = 1 | ((d * 1000000) + monotonic_us()); + } - myid = (uint16_t) getpid(); + if (!using_dgram) myid = (uint16_t) getpid(); hostname = argv[optind]; #if ENABLE_PING6 { --- -2.16.2 - |