iputils: update to 20121011.

This commit is contained in:
Juan RP 2012-10-17 16:56:58 +02:00
parent a6dee4dbb0
commit ab2c6e4408
11 changed files with 7 additions and 798 deletions

View file

@ -2,12 +2,8 @@ case ${ACTION} in
post)
# Set required capability to ping{,6}.
for f in ping ping6; do
set +e
setcap cap_net_raw=ep sbin/${f}
if [ $? -ne 0 ]; then
echo "Failed to set cap_net_raw capability on sbin/${f}."
exit 0
fi
setcap cap_net_raw=ep usr/sbin/${f} 2>/dev/null || \
chmod +s usr/sbin/${f}
done
;;
esac

View file

@ -1,5 +1,5 @@
libc.so.6
libresolv.so.2
libcrypto.so.1
libidn.so.11
libcap.so.2
libsysfs.so.2

View file

@ -1,98 +0,0 @@
diff -up iputils-s20100418/Makefile.idn iputils-s20100418/Makefile
--- iputils-s20100418/Makefile.idn 2010-04-20 16:07:59.018479157 +0200
+++ iputils-s20100418/Makefile 2010-04-20 16:10:06.389481427 +0200
@@ -28,8 +28,13 @@ all: $(TARGETS)
tftpd: tftpd.o tftpsubs.o
-arping: arping.o -lsysfs
+arping: arping.o
+
ping: ping.o ping_common.o
-ping6: ping6.o ping_common.o -lresolv -lcrypto
+ $(CC) $(CFLAGS) $(LDFLAGS) ping.o ping_common.o -lidn -o ping
+
+ping6: ping6.o ping_common.o
+ $(CC) $(CFLAGS) $(LDFLAGS) ping6.o ping_common.o -lresolv -lcrypto -o ping6
+
ping.o ping6.o ping_common.o: ping_common.h
tftpd.o tftpsubs.o: tftp.h
diff -up iputils-s20100418/ping.c.idn iputils-s20100418/ping.c
--- iputils-s20100418/ping.c.idn 2010-04-20 16:07:59.038484302 +0200
+++ iputils-s20100418/ping.c 2010-04-20 16:07:59.077485007 +0200
@@ -58,6 +58,9 @@ char copyright[] =
* This program has to run SUID to ROOT to access the ICMP socket.
*/
+#include <idna.h>
+#include <locale.h>
+
#include "ping_common.h"
#include <netinet/ip.h>
@@ -123,6 +126,10 @@ main(int argc, char **argv)
char *target, hnamebuf[MAX_HOSTNAMELEN];
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
+ char *idn;
+ int rc = 0;
+ setlocale(LC_ALL, "");
+
icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
socket_errno = errno;
@@ -250,13 +257,27 @@ main(int argc, char **argv)
if (argc == 1)
options |= F_NUMERIC;
} else {
- hp = gethostbyname(target);
+ rc = idna_to_ascii_lz (target, &idn, 0);
+ if (rc == IDNA_SUCCESS)
+ hp = gethostbyname (idn);
+ else {
+ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
+ exit(2);
+ }
+ free(idn);
if (!hp) {
fprintf(stderr, "ping: unknown host %s\n", target);
exit(2);
}
memcpy(&whereto.sin_addr, hp->h_addr, 4);
- strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
+ rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
+ if (rc == IDNA_SUCCESS)
+ strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
+ else {
+ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
+ exit(2);
+ }
+ free(idn);
hnamebuf[sizeof(hnamebuf) - 1] = 0;
hostname = hnamebuf;
}
diff -up iputils-s20100418/ping_common.c.idn iputils-s20100418/ping_common.c
--- iputils-s20100418/ping_common.c.idn 2010-04-20 16:07:59.039478452 +0200
+++ iputils-s20100418/ping_common.c 2010-04-20 16:07:59.069478660 +0200
@@ -1,3 +1,5 @@
+#include <locale.h>
+
#include "ping_common.h"
#include <ctype.h>
#include <sched.h>
@@ -98,6 +100,7 @@ static void fill(char *patp)
void common_options(int ch)
{
+ setlocale(LC_ALL, "C");
switch(ch) {
case 'a':
options |= F_AUDIBLE;
@@ -242,6 +245,7 @@ void common_options(int ch)
default:
abort();
}
+ setlocale(LC_ALL, "");
}

View file

@ -1,88 +0,0 @@
diff -up iputils-s20100418/ping6.c.corr_type iputils-s20100418/ping6.c
--- iputils-s20100418/ping6.c.corr_type 2010-04-20 15:42:39.181245576 +0200
+++ iputils-s20100418/ping6.c 2010-04-20 15:42:39.198230879 +0200
@@ -1335,7 +1335,7 @@ parse_reply(struct msghdr *msg, int cc,
#endif
if (c->cmsg_len < CMSG_LEN(sizeof(int)))
continue;
- hops = *(int*)CMSG_DATA(c);
+ memcpy(&hops, CMSG_DATA(c), sizeof (int));
}
}
diff -up iputils-s20100418/ping.c.corr_type iputils-s20100418/ping.c
--- iputils-s20100418/ping.c.corr_type 2010-04-20 15:42:39.193242030 +0200
+++ iputils-s20100418/ping.c 2010-04-20 15:42:39.199231317 +0200
@@ -1211,18 +1211,20 @@ pr_addr(__u32 addr)
struct hostent *hp;
static char buf[4096];
static __u32 addr_cache = 0;
+ struct in_addr tmp_addr;
if ( addr == addr_cache )
return buf;
addr_cache = addr;
+ tmp_addr.s_addr = addr;
if ((options & F_NUMERIC) ||
!(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
- sprintf(buf, "%s", inet_ntoa(*(struct in_addr *)&addr));
+ sprintf(buf, "%s", inet_ntoa(tmp_addr));
else
snprintf(buf, sizeof(buf), "%s (%s)", hp->h_name,
- inet_ntoa(*(struct in_addr *)&addr));
+ inet_ntoa(tmp_addr));
return(buf);
}
diff -up iputils-s20100418/rdisc.c.corr_type iputils-s20100418/rdisc.c
--- iputils-s20100418/rdisc.c.corr_type 2010-04-18 06:45:45.000000000 +0200
+++ iputils-s20100418/rdisc.c 2010-04-20 15:42:39.201230377 +0200
@@ -1487,14 +1487,19 @@ rtioctl(struct in_addr addr, int op)
{
int sock;
struct rtentry rt;
- struct sockaddr_in *sin;
+ union {
+ struct sockaddr *sa;
+ struct sockaddr_in *sin;
+ } conv;
memset((char *)&rt, 0, sizeof(struct rtentry));
rt.rt_dst.sa_family = AF_INET;
rt.rt_gateway.sa_family = AF_INET;
rt.rt_genmask.sa_family = AF_INET;
- sin = (struct sockaddr_in *)ALLIGN(&rt.rt_gateway);
- sin->sin_addr = addr;
+ // gcc4.4 hack
+ conv.sa = ALLIGN(&rt.rt_gateway);
+ memcpy(&conv.sin->sin_addr, &addr, sizeof(struct in_addr));
+ // -----------
rt.rt_flags = RTF_UP | RTF_GATEWAY;
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
diff -up iputils-s20100418/tracepath6.c.corr_type iputils-s20100418/tracepath6.c
--- iputils-s20100418/tracepath6.c.corr_type 2010-04-18 06:45:45.000000000 +0200
+++ iputils-s20100418/tracepath6.c 2010-04-20 15:44:15.129480911 +0200
@@ -173,7 +173,7 @@ restart:
#ifdef IPV6_2292HOPLIMIT
case IPV6_2292HOPLIMIT:
#endif
- rethops = *(int*)CMSG_DATA(cmsg);
+ memcpy(&rethops, CMSG_DATA(cmsg), sizeof (int));
break;
default:
printf("cmsg6:%d\n ", cmsg->cmsg_type);
diff -up iputils-s20100418/tracepath.c.corr_type iputils-s20100418/tracepath.c
--- iputils-s20100418/tracepath.c.corr_type 2010-04-18 06:45:45.000000000 +0200
+++ iputils-s20100418/tracepath.c 2010-04-20 15:42:39.203240403 +0200
@@ -145,7 +145,7 @@ restart:
if (cmsg->cmsg_type == IP_RECVERR) {
e = (struct sock_extended_err *) CMSG_DATA(cmsg);
} else if (cmsg->cmsg_type == IP_TTL) {
- rethops = *(int*)CMSG_DATA(cmsg);
+ memcpy(&rethops, CMSG_DATA(cmsg), sizeof(int));
} else {
printf("cmsg:%d\n ", cmsg->cmsg_type);
}

View file

@ -1,266 +0,0 @@
diff -up iputils-s20101006/arping.c.infiniband iputils-s20101006/arping.c
--- iputils-s20101006/arping.c.infiniband 2010-10-11 09:17:57.440390823 +0200
+++ iputils-s20101006/arping.c 2010-10-11 09:23:36.147402252 +0200
@@ -32,8 +32,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <sysfs/libsysfs.h>
-
#include "SNAPSHOT.h"
static void usage(void) __attribute__((noreturn));
@@ -52,14 +50,22 @@ int unicasting;
int s;
int broadcast_only;
-struct sockaddr_storage me;
-struct sockaddr_storage he;
+struct sockaddr_ll *me=NULL;
+struct sockaddr_ll *he=NULL;
struct timeval start, last;
int sent, brd_sent;
int received, brd_recv, req_recv;
+#define SYSFS_MNT_PATH "/sys"
+#define SYSFS_CLASS "class"
+#define SYSFS_NET "net"
+#define SYSFS_BROADCAST "broadcast"
+#define SYSFS_PATH_ENV "SYSFS_PATH"
+#define SYSFS_PATH_LEN 256
+#define SOCKADDR_LEN (2 * sizeof(struct sockaddr_ll))
+
#define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
((tv1).tv_usec-(tv2).tv_usec)/1000 )
@@ -166,6 +172,10 @@ void finish(void)
printf("\n");
fflush(stdout);
}
+
+ free(me);
+ free(he);
+
if (dad)
exit(!!received);
if (unsolicited)
@@ -186,8 +196,7 @@ void catcher(void)
finish();
if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
- send_pack(s, src, dst,
- (struct sockaddr_ll *)&me, (struct sockaddr_ll *)&he);
+ send_pack(s, src, dst, me, he);
if (count == 0 && unsolicited)
finish();
}
@@ -234,7 +243,7 @@ int recv_pack(unsigned char *buf, int le
return 0;
if (ah->ar_pln != 4)
return 0;
- if (ah->ar_hln != ((struct sockaddr_ll *)&me)->sll_halen)
+ if (ah->ar_hln != me->sll_halen)
return 0;
if (len < sizeof(*ah) + 2*(4 + ah->ar_hln))
return 0;
@@ -245,7 +254,7 @@ int recv_pack(unsigned char *buf, int le
return 0;
if (src.s_addr != dst_ip.s_addr)
return 0;
- if (memcmp(p+ah->ar_hln+4, ((struct sockaddr_ll *)&me)->sll_addr, ah->ar_hln))
+ if (memcmp(p+ah->ar_hln+4, me->sll_addr, ah->ar_hln))
return 0;
} else {
/* DAD packet was:
@@ -263,7 +272,7 @@ int recv_pack(unsigned char *buf, int le
*/
if (src_ip.s_addr != dst.s_addr)
return 0;
- if (memcmp(p, ((struct sockaddr_ll *)&me)->sll_addr, ((struct sockaddr_ll *)&me)->sll_halen) == 0)
+ if (memcmp(p, me->sll_addr, me->sll_halen) == 0)
return 0;
if (src.s_addr && src.s_addr != dst_ip.s_addr)
return 0;
@@ -279,7 +288,7 @@ int recv_pack(unsigned char *buf, int le
printf("for %s ", inet_ntoa(dst_ip));
s_printed = 1;
}
- if (memcmp(p+ah->ar_hln+4, ((struct sockaddr_ll *)&me)->sll_addr, ah->ar_hln)) {
+ if (memcmp(p+ah->ar_hln+4, me->sll_addr, ah->ar_hln)) {
if (!s_printed)
printf("for ");
printf("[");
@@ -305,40 +314,67 @@ int recv_pack(unsigned char *buf, int le
if (quit_on_reply)
finish();
if(!broadcast_only) {
- memcpy(((struct sockaddr_ll *)&he)->sll_addr, p, ((struct sockaddr_ll *)&me)->sll_halen);
+ memcpy(he->sll_addr, p, me->sll_halen);
unicasting=1;
}
return 1;
}
-void set_device_broadcast(char *device, unsigned char *ba, size_t balen)
+int get_sysfs_mnt_path(char *mnt_path, size_t len)
{
- struct sysfs_class_device *dev;
- struct sysfs_attribute *brdcast;
- unsigned char *p;
- int ch;
+ const char *sysfs_path_env;
+ int pth_len=0;
- dev = sysfs_open_class_device("net", device);
- if (!dev) {
- perror("sysfs_open_class_device(net)");
- exit(2);
- }
+ if (len == 0 || mnt_path == NULL)
+ return -1;
- brdcast = sysfs_get_classdev_attr(dev, "broadcast");
- if (!brdcast) {
- perror("sysfs_get_classdev_attr(broadcast)");
- exit(2);
- }
+ /* possible overrride of real mount path */
+ sysfs_path_env = getenv(SYSFS_PATH_ENV);
+ memset(mnt_path, 0, len);
+ strncpy(mnt_path,
+ sysfs_path_env != NULL ? sysfs_path_env : SYSFS_MNT_PATH,
+ len-1);
- if (sysfs_read_attribute(brdcast)) {
- perror("sysfs_read_attribute");
- exit(2);
- }
+ if ((pth_len = strlen(mnt_path)) > 0 && mnt_path[pth_len-1] == '/')
+ mnt_path[pth_len-1] = '\0';
+
+ return 0;
+}
+
+int make_sysfs_broadcast_path(char *broadcast_path, size_t len)
+{
+ char mnt_path[SYSFS_PATH_LEN];
+
+ if (get_sysfs_mnt_path(mnt_path, len) != 0)
+ return -1;
- for (p = ba, ch = 0; p < ba + balen; p++, ch += 3)
- *p = strtoul(brdcast->value + ch, NULL, 16);
+ snprintf(broadcast_path, len,
+ "%s/" SYSFS_CLASS "/" SYSFS_NET "/%s/" SYSFS_BROADCAST,
+ mnt_path, device);
- return;
+ return 0;
+}
+
+char * read_sysfs_broadcast(char *brdcast_path)
+{
+ int fd;
+ int len_to_read;
+ char *brdcast = NULL;
+
+ if ((fd = open(brdcast_path, O_RDONLY)) > -1) {
+ len_to_read = lseek(fd, 0L, SEEK_END);
+ if ((brdcast = malloc(len_to_read+1)) != NULL) {
+ lseek(fd, 0L, SEEK_SET);
+ memset(brdcast, 0, len_to_read+1);
+ if (read(fd, brdcast, len_to_read) == -1) {
+ free(brdcast);
+ brdcast = NULL;
+ }
+ }
+ close(fd);
+ }
+
+ return brdcast;
}
int
@@ -356,6 +392,17 @@ main(int argc, char **argv)
exit(-1);
}
+ me = malloc(SOCKADDR_LEN);
+ if (!me) {
+ fprintf(stderr, "arping: could not allocate memory\n");
+ exit(1);
+ }
+ he = malloc(SOCKADDR_LEN);
+ if (!he) {
+ fprintf(stderr, "arping: could not allocate memory\n");
+ exit(1);
+ }
+
while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) {
switch(ch) {
case 'b':
@@ -504,34 +551,51 @@ main(int argc, char **argv)
close(probe_fd);
};
- ((struct sockaddr_ll *)&me)->sll_family = AF_PACKET;
- ((struct sockaddr_ll *)&me)->sll_ifindex = ifindex;
- ((struct sockaddr_ll *)&me)->sll_protocol = htons(ETH_P_ARP);
- if (bind(s, (struct sockaddr*)&me, sizeof(me)) == -1) {
+ me->sll_family = AF_PACKET;
+ me->sll_ifindex = ifindex;
+ me->sll_protocol = htons(ETH_P_ARP);
+ if (bind(s, (struct sockaddr*)me, SOCKADDR_LEN) == -1) {
perror("bind");
exit(2);
}
if (1) {
- socklen_t alen = sizeof(me);
- if (getsockname(s, (struct sockaddr*)&me, &alen) == -1) {
+ socklen_t alen = SOCKADDR_LEN;
+ if (getsockname(s, (struct sockaddr*)me, &alen) == -1) {
perror("getsockname");
exit(2);
}
}
- if (((struct sockaddr_ll *)&me)->sll_halen == 0) {
+ if (me->sll_halen == 0) {
if (!quiet)
printf("Interface \"%s\" is not ARPable (no ll address)\n", device);
exit(dad?0:2);
}
- he = me;
+ memcpy(he, me, SOCKADDR_LEN);
#if 1
- set_device_broadcast(device, ((struct sockaddr_ll *)&he)->sll_addr,
- ((struct sockaddr_ll *)&he)->sll_halen);
+ char brdcast_path[SYSFS_PATH_LEN];
+ char *brdcast_val=NULL;
+ char *next_ch;
+
+ if (make_sysfs_broadcast_path(brdcast_path, sizeof brdcast_path) != 0) {
+ perror("sysfs attribute broadcast");
+ exit(2);
+ }
+
+ if ((brdcast_val = read_sysfs_broadcast(brdcast_path)) == NULL) {
+ perror("sysfs read broadcast value");
+ exit(2);
+ }
+
+ for (ch=0; ch<he->sll_halen; ch++) {
+ he->sll_addr[ch] = strtol(brdcast_val + (ch*3), &next_ch, 16);
+ }
+
+ free(brdcast_val);
#else
- memset(((struct sockaddr_ll *)&he)->sll_addr, -1, ((struct sockaddr_ll *)&he)->sll_halen);
+ memset(he->sll_addr, -1, he->sll_halen);
#endif
if (!quiet) {

View file

@ -1,126 +0,0 @@
diff -up iputils-s20071127/ping_common.c.warnings iputils-s20071127/ping_common.c
--- iputils-s20071127/ping_common.c.warnings 2008-06-02 13:29:27.000000000 +0200
+++ iputils-s20071127/ping_common.c 2008-06-02 13:29:27.000000000 +0200
@@ -338,7 +338,7 @@ resend:
* high preload or pipe size is very confusing. */
if ((preload < screen_width && pipesize < screen_width) ||
in_flight() < screen_width)
- write(STDOUT_FILENO, ".", 1);
+ printf(".");
}
return interval - tokens;
}
@@ -391,7 +391,7 @@ resend:
if (i == 0 && !(options & F_QUIET)) {
if (options & F_FLOOD)
- write(STDOUT_FILENO, "E", 1);
+ printf("E");
else
perror("ping: sendmsg");
}
@@ -717,9 +717,9 @@ restamp:
if (options & F_FLOOD) {
if (!csfailed)
- write(STDOUT_FILENO, "\b \b", 3);
+ printf("\b \b");
else
- write(STDOUT_FILENO, "\bC", 1);
+ printf("\bC");
} else {
int i;
__u8 *cp, *dp;
diff -up iputils-s20071127/clockdiff.c.warnings iputils-s20071127/clockdiff.c
--- iputils-s20071127/clockdiff.c.warnings 2007-11-27 01:57:27.000000000 +0100
+++ iputils-s20071127/clockdiff.c 2008-06-02 13:29:27.000000000 +0200
@@ -628,8 +628,6 @@ main(int argc, char *argv[])
}
}
- nice(-16);
-
if ((measure_status = (ip_opt_len ? measure_opt : measure)(&server)) < 0) {
if (errno)
perror("measure");
diff -up iputils-s20071127/ping6.c.warnings iputils-s20071127/ping6.c
--- iputils-s20071127/ping6.c.warnings 2008-06-02 13:30:06.000000000 +0200
+++ iputils-s20071127/ping6.c 2008-06-02 13:31:14.000000000 +0200
@@ -1037,7 +1037,7 @@ int receive_error_msg()
if (options & F_QUIET)
goto out;
if (options & F_FLOOD)
- write(STDOUT_FILENO, "E", 1);
+ printf("E");
else if (e->ee_errno != EMSGSIZE)
fprintf(stderr, "ping: local error: %s\n", strerror(e->ee_errno));
else
@@ -1060,7 +1060,7 @@ int receive_error_msg()
if (options & F_QUIET)
goto out;
if (options & F_FLOOD) {
- write(STDOUT_FILENO, "\bE", 2);
+ printf("\bE");
} else {
print_timestamp();
printf("From %s icmp_seq=%u ", pr_addr(&sin6->sin6_addr), ntohs(icmph.icmp6_seq));
@@ -1400,7 +1400,7 @@ parse_reply(struct msghdr *msg, int cc,
return 0;
nerrors++;
if (options & F_FLOOD) {
- write(STDOUT_FILENO, "\bE", 2);
+ printf("\bE");
return 0;
}
print_timestamp();
diff -up iputils-s20071127/ping.c.warnings iputils-s20071127/ping.c
--- iputils-s20071127/ping.c.warnings 2008-06-02 13:29:27.000000000 +0200
+++ iputils-s20071127/ping.c 2008-06-02 13:29:27.000000000 +0200
@@ -367,7 +367,7 @@ main(int argc, char **argv)
}
source.sin_port = 0;
close(probe_fd);
- } while (0);
+ }
if (whereto.sin_addr.s_addr == 0)
whereto.sin_addr.s_addr = source.sin_addr.s_addr;
@@ -594,7 +594,7 @@ int receive_error_msg()
if (options & F_QUIET)
goto out;
if (options & F_FLOOD)
- write(STDOUT_FILENO, "E", 1);
+ printf("E");
else if (e->ee_errno != EMSGSIZE)
fprintf(stderr, "ping: local error: %s\n", strerror(e->ee_errno));
else
@@ -630,7 +630,7 @@ int receive_error_msg()
if (options & F_QUIET)
goto out;
if (options & F_FLOOD) {
- write(STDOUT_FILENO, "\bE", 2);
+ printf("\bE");
} else {
print_timestamp();
printf("From %s icmp_seq=%u ", pr_addr(sin->sin_addr.s_addr), ntohs(icmph.un.echo.sequence));
@@ -795,7 +795,7 @@ parse_reply(struct msghdr *msg, int cc,
return !error_pkt;
if (options & F_FLOOD) {
if (error_pkt)
- write(STDOUT_FILENO, "\bE", 2);
+ printf("\bE");
return !error_pkt;
}
print_timestamp();
@@ -812,9 +812,9 @@ parse_reply(struct msghdr *msg, int cc,
}
if ((options & F_FLOOD) && !(options & (F_VERBOSE|F_QUIET))) {
if (!csfailed)
- write(STDOUT_FILENO, "!E", 2);
+ printf("!E");
else
- write(STDOUT_FILENO, "!EC", 3);
+ printf("!EC");
return 0;
}
if (!(options & F_VERBOSE) || uid)

View file

@ -1,107 +0,0 @@
diff -up iputils-s20101006/Makefile.drop_caps iputils-s20101006/Makefile
--- iputils-s20101006/Makefile 2010-11-08 14:49:53.334577997 +0100
+++ iputils-s20101006/Makefile 2010-11-08 14:49:53.342599113 +0100
@@ -13,7 +13,7 @@ ADDLIB=
CC=gcc
# What a pity, all new gccs are buggy and -Werror does not work. Sigh.
CCOPT=-Wstrict-prototypes -fno-strict-aliasing -Werror
-DEFINES += -D_GNU_SOURCE
+DEFINES += -D_GNU_SOURCE -DHAVE_CAPABILITIES
CFLAGS += $(RPM_OPT_FLAGS) $(CCOPT) $(GLIBCFIX) $(DEFINES)
IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
@@ -30,10 +30,10 @@ tftpd: tftpd.o tftpsubs.o
arping: arping.o
ping: ping.o ping_common.o
- $(CC) $(CFLAGS) $(LDFLAGS) ping.o ping_common.o -lidn -o ping
+ $(CC) $(CFLAGS) $(LDFLAGS) ping.o ping_common.o -lidn -lcap -o ping
ping6: ping6.o ping_common.o
- $(CC) $(CFLAGS) $(LDFLAGS) ping6.o ping_common.o -lresolv -lcrypto -o ping6
+ $(CC) $(CFLAGS) $(LDFLAGS) ping6.o ping_common.o -lresolv -lcrypto -lcap -o ping6
ping.o ping6.o ping_common.o: ping_common.h in6_flowlabel.h
tftpd.o tftpsubs.o: tftp.h
diff -up iputils-s20101006/ping6.c.drop_caps iputils-s20101006/ping6.c
--- iputils-s20101006/ping6.c.drop_caps 2010-11-08 14:49:53.338587611 +0100
+++ iputils-s20101006/ping6.c 2010-12-15 16:06:16.949794002 +0100
@@ -73,6 +73,10 @@ char copyright[] =
#include <netinet/icmp6.h>
#include <resolv.h>
+#ifdef HAVE_CAPABILITIES
+#include <sys/capability.h>
+#endif
+
#include "ping6_niquery.h"
#include "in6_flowlabel.h"
@@ -533,6 +537,9 @@ int main(int argc, char *argv[])
int csum_offset, sz_opt;
#endif
static uint32_t scope_id = 0;
+#ifdef HAVE_CAPABILITIES
+ cap_t caps;
+#endif
icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
socket_errno = errno;
@@ -543,6 +550,16 @@ int main(int argc, char *argv[])
exit(-1);
}
+#ifdef HAVE_CAPABILITIES
+ /* drop all capabilities unconditionally so even root isn't special anymore */
+ caps = cap_init();
+ if (cap_set_proc(caps) < 0) {
+ perror("ping: cap_set_proc");
+ exit(-1);
+ }
+ cap_free(caps);
+#endif
+
source.sin6_family = AF_INET6;
memset(&firsthop, 0, sizeof(firsthop));
firsthop.sin6_family = AF_INET6;
diff -up iputils-s20101006/ping.c.drop_caps iputils-s20101006/ping.c
--- iputils-s20101006/ping.c.drop_caps 2010-11-08 14:49:53.314577272 +0100
+++ iputils-s20101006/ping.c 2010-12-15 16:05:52.113794002 +0100
@@ -66,6 +66,10 @@ char copyright[] =
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
+#ifdef HAVE_CAPABILITIES
+#include <sys/capability.h>
+#endif
+
#ifndef ICMP_FILTER
#define ICMP_FILTER 1
struct icmp_filter {
@@ -125,6 +129,9 @@ main(int argc, char **argv)
u_char *packet;
char *target, hnamebuf[MAX_HOSTNAMELEN];
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
+#ifdef HAVE_CAPABILITIES
+ cap_t caps;
+#endif
char *idn;
int rc = 0;
@@ -139,6 +146,16 @@ main(int argc, char **argv)
exit(-1);
}
+#ifdef HAVE_CAPABILITIES
+ /* drop all capabilities unconditionally so even root isn't special anymore */
+ caps = cap_init();
+ if (cap_set_proc(caps) < 0) {
+ perror("ping: cap_set_proc");
+ exit(-1);
+ }
+ cap_free(caps);
+#endif
+
source.sin_family = AF_INET;
preload = 1;

View file

@ -1,45 +0,0 @@
diff -up iputils-s20101006/clockdiff.c.unused iputils-s20101006/clockdiff.c
--- iputils-s20101006/clockdiff.c.unused 2011-02-09 16:17:33.988298995 +0100
+++ iputils-s20101006/clockdiff.c 2011-02-09 16:17:52.192299138 +0100
@@ -126,7 +126,7 @@ measure(struct sockaddr_in * addr)
int msgcount;
int cc, count;
fd_set ready;
- long sendtime, recvtime, histime, histime1;
+ long sendtime, recvtime, histime;
long min1, min2, diff;
long delta1, delta2;
struct timeval tv1, tout;
@@ -240,7 +240,6 @@ empty:
rtt_sigma = (rtt_sigma *3 + abs(diff-rtt))/4;
msgcount++;
histime = ntohl(((__u32*)(icp+1))[1]);
- histime1 = ntohl(((__u32*)(icp+1))[2]);
/*
* a hosts using a time format different from
* ms. since midnight UT (as per RFC792) should
diff -up iputils-s20101006/ping6.c.unused iputils-s20101006/ping6.c
--- iputils-s20101006/ping6.c.unused 2011-02-09 16:14:11.413299738 +0100
+++ iputils-s20101006/ping6.c 2011-02-09 16:46:39.158299066 +0100
@@ -1215,7 +1215,7 @@ void pr_niquery_reply_name(struct ni_hdr
}
while (p < end) {
int fqdn = 1;
- int len;
+ int buf_len;
int i;
memset(buf, 0xff, sizeof(buf));
@@ -1230,10 +1230,10 @@ void pr_niquery_reply_name(struct ni_hdr
}
if (p + ret < end && *(p + ret) == '\0')
fqdn = 0;
- len = strlen(buf);
+ buf_len = strlen(buf);
putchar(' ');
- for (i = 0; i < strlen(buf); i++)
+ for (i = 0; i < buf_len; i++)
putchar_safe(buf[i]);
if (fqdn)
putchar('.');

View file

@ -1,50 +0,0 @@
--- iputils/ping.c.OLD 2006-02-06 10:34:35.000000000 +0100
+++ iputils/ping.c 2006-02-06 10:34:35.000000000 +0100
@@ -855,9 +855,36 @@
case ICMP_SR_FAILED:
printf("Source Route Failed\n");
break;
+ case ICMP_NET_UNKNOWN:
+ printf("Destination Net Unknown\n");
+ break;
+ case ICMP_HOST_UNKNOWN:
+ printf("Destination Host Unknown\n");
+ break;
+ case ICMP_HOST_ISOLATED:
+ printf("Source Host Isolated\n");
+ break;
+ case ICMP_NET_ANO:
+ printf("Destination Net Prohibited\n");
+ break;
+ case ICMP_HOST_ANO:
+ printf("Destination Host Prohibited\n");
+ break;
+ case ICMP_NET_UNR_TOS:
+ printf("Destination Net Unreachable for Type of Service\n");
+ break;
+ case ICMP_HOST_UNR_TOS:
+ printf("Destination Host Unreachable for Type of Service\n");
+ break;
case ICMP_PKT_FILTERED:
printf("Packet filtered\n");
break;
+ case ICMP_PREC_VIOLATION:
+ printf("Precedence Violation\n");
+ break;
+ case ICMP_PREC_CUTOFF:
+ printf("Precedence Cutoff\n");
+ break;
default:
printf("Dest Unreachable, Bad Code: %d\n", code);
break;
--- iputils/ping_common.c.OLD 2006-02-06 10:34:35.000000000 +0100
+++ iputils/ping_common.c 2006-02-06 10:34:35.000000000 +0100
@@ -819,7 +819,7 @@
printf("%spipe %d", comma, pipesize);
comma = ", ";
}
- if (ntransmitted > 1 && (!interval || (options&(F_FLOOD|F_ADAPTIVE)))) {
+ if (ntransmitted > 1 && nreceived && (!interval || (options&(F_FLOOD|F_ADAPTIVE)))) {
int ipg = (1000000*(long long)tv.tv_sec+tv.tv_usec)/(ntransmitted-1);
printf("%sipg/ewma %d.%03d/%d.%03d ms",
comma, ipg/1000, ipg%1000, rtt/8000, (rtt/8)%1000);

View file

@ -2,16 +2,9 @@ iputils-20020927-rh.patch
iputils-20020124-countermeasures.patch
iputils-20020927-addrcache.patch
iputils-20020927-ping-subint.patch
iputils-ping_cleanup.patch
iputils-20070202-idn.patch
iputils-20070202-traffic_class.patch
iputils-20070202-ia64_align.patch
iputils-20071127-warnings.patch
iputils-20071127-corr_type.patch
iputils-20071127-infiniband.patch
iputils-20100418-convtoint.patch
iputils-20101006-drop_caps.patch
iputils-20101006-unused.patch
iputils-20101006-man.patch
iputils-20101006-eth.patch
iputils-20101006-rr.patch

View file

@ -1,17 +1,17 @@
# Template file for 'iputils'
pkgname=iputils
version=20101006
revision=4
version=20121011
revision=1
patch_args="-Np1"
wrksrc="${pkgname}-s${version}"
homepage="http://www.skbuff.net/iputils"
distfiles="http://www.skbuff.net/iputils/${pkgname}-s${version}.tar.bz2"
makedepends="openssl-devel libcap-devel libidn-devel"
makedepends="openssl-devel libcap-devel libidn-devel libsysfs-devel"
fulldepends="libcap-progs"
short_desc="IP Configuration Utilities (and ping)"
maintainer="Juan RP <xtraeme@gmail.com>"
license="BSD"
checksum=fd3af46c80ebb99607c2ca1f2a3608b6fe828e25bbec6e54f2afd25f6ddb6ee7
checksum=018a4300a4b40698a3b0801c79de9aea39a281a080acceaacd676fe18827cb72
long_desc="
The iputils package is set of small useful utilities for Linux networking.
It was originally maintained by Alexey Kuznetsov."