diff --git a/srcpkgs/iputils/INSTALL b/srcpkgs/iputils/INSTALL new file mode 100644 index 00000000000..e3f0d04a200 --- /dev/null +++ b/srcpkgs/iputils/INSTALL @@ -0,0 +1,13 @@ +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 + done + ;; +esac diff --git a/srcpkgs/iputils/iputils.rshlibs b/srcpkgs/iputils/iputils.rshlibs index 03ed47023c2..ae7eca24556 100644 --- a/srcpkgs/iputils/iputils.rshlibs +++ b/srcpkgs/iputils/iputils.rshlibs @@ -1,4 +1,5 @@ libc.so.6 libresolv.so.2 libcrypto.so.1 -libsysfs.so.2 +libidn.so.11 +libcap.so.2 diff --git a/srcpkgs/iputils/patches/fix_install.diff b/srcpkgs/iputils/patches/fix_install.diff deleted file mode 100644 index 2becc24407b..00000000000 --- a/srcpkgs/iputils/patches/fix_install.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- a/Makefile.orig 2010-10-06 13:59:20.000000000 +0200 -+++ b/Makefile 2011-02-01 01:58:43.338899085 +0100 -@@ -25,6 +25,15 @@ TAG:=`date +s%Y%m%d` - - all: $(TARGETS) - -+install: -+ for f in $(TARGETS); do \ -+ if [ "$$f" = "ping" -o "$$f" = "ping6" ]; then \ -+ install -D -m4755 $$f $(DESTDIR)/sbin/$$f; \ -+ else \ -+ install -D -m755 $$f $(DESTDIR)/sbin/$$f; \ -+ fi; \ -+ \ -+ done - - tftpd: tftpd.o tftpsubs.o - arping: arping.o -lsysfs diff --git a/srcpkgs/iputils/patches/iputils-20020124-countermeasures.patch b/srcpkgs/iputils/patches/iputils-20020124-countermeasures.patch new file mode 100644 index 00000000000..5e6f4bcde34 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20020124-countermeasures.patch @@ -0,0 +1,12 @@ +--- iputils/ping_common.c.countermeasures Tue May 21 10:06:05 2002 ++++ iputils/ping_common.c Tue May 21 10:12:42 2002 +@@ -628,7 +628,8 @@ + tvsub(tv, &tmp_tv); + triptime = tv->tv_sec * 1000000 + tv->tv_usec; + if (triptime < 0) { +- fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime); ++ if (options & F_VERBOSE) ++ fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures.\n", triptime); + triptime = 0; + if (!(options & F_LATENCY)) { + gettimeofday(tv, NULL); diff --git a/srcpkgs/iputils/patches/iputils-20020927-addrcache.patch b/srcpkgs/iputils/patches/iputils-20020927-addrcache.patch new file mode 100644 index 00000000000..188dbcaccd1 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20020927-addrcache.patch @@ -0,0 +1,31 @@ +--- iputils/ping.c.addrcache 2002-09-20 17:08:11.000000000 +0200 ++++ iputils/ping.c 2003-05-15 16:41:19.000000000 +0200 +@@ -1124,6 +1124,12 @@ + { + struct hostent *hp; + static char buf[4096]; ++ static __u32 addr_cache = 0; ++ ++ if ( addr == addr_cache ) ++ return buf; ++ ++ addr_cache = addr; + + if ((options & F_NUMERIC) || + !(hp = gethostbyaddr((char *)&addr, 4, AF_INET))) +--- iputils/ping6.c.addrcache 2002-09-20 17:08:11.000000000 +0200 ++++ iputils/ping6.c 2003-05-15 16:41:19.000000000 +0200 +@@ -893,7 +893,12 @@ + */ + char * pr_addr(struct in6_addr *addr) + { +- struct hostent *hp = NULL; ++ static struct hostent *hp; ++ static struct in6_addr addr_cache; ++ ++ if (memcmp(addr, &addr_cache, sizeof(addr_cache)) == 0) ++ return hp ? hp->h_name : pr_addr_n(addr); ++ memcpy(&addr_cache, addr, sizeof(addr_cache)); + + if (!(options&F_NUMERIC)) + hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6); diff --git a/srcpkgs/iputils/patches/iputils-20020927-ping-subint.patch b/srcpkgs/iputils/patches/iputils-20020927-ping-subint.patch new file mode 100644 index 00000000000..e19e724ffa7 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20020927-ping-subint.patch @@ -0,0 +1,12 @@ +--- iputils-ss021109-vanilla/ping.c Thu Nov 7 23:53:21 2002 ++++ iputils/ping.c Sun Jan 12 03:39:24 2003 +@@ -285,6 +285,9 @@ + perror("ping: IP_MULTICAST_IF"); + exit(2); + } ++ } else if (icmp_sock >= 0) { ++ /* We possible tried to SO_BINDTODEVICE() a subinterface like 'eth0:1' */ ++ perror("Warning: cannot bind to specified iface, falling back"); + } + } + } diff --git a/srcpkgs/iputils/patches/iputils-20020927-rh.patch b/srcpkgs/iputils/patches/iputils-20020927-rh.patch new file mode 100644 index 00000000000..0c83bc55718 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20020927-rh.patch @@ -0,0 +1,15 @@ +--- iputils/Makefile.rh7 2002-09-20 20:23:55.000000000 +0200 ++++ iputils/Makefile 2004-05-12 15:08:25.638310270 +0200 +@@ -12,9 +12,9 @@ ADDLIB= + + CC=gcc + # What a pity, all new gccs are buggy and -Werror does not work. Sigh. +-#CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g -Werror +-CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g +-CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES) ++CCOPT=-Wstrict-prototypes -fno-strict-aliasing -Werror ++DEFINES += -D_GNU_SOURCE ++CFLAGS += $(RPM_OPT_FLAGS) $(CCOPT) $(GLIBCFIX) $(DEFINES) + + IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd + IPV6_TARGETS=tracepath6 traceroute6 ping6 diff --git a/srcpkgs/iputils/patches/iputils-20070202-ia64_align.patch b/srcpkgs/iputils/patches/iputils-20070202-ia64_align.patch new file mode 100644 index 00000000000..f438a29a945 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20070202-ia64_align.patch @@ -0,0 +1,43 @@ +diff -up iputils-s20071127/ping.c.ia64_align iputils-s20071127/ping.c +--- iputils-s20071127/ping.c.ia64_align 2008-06-02 08:56:32.000000000 +0200 ++++ iputils-s20071127/ping.c 2008-06-02 08:56:32.000000000 +0200 +@@ -200,13 +200,13 @@ main(int argc, char **argv) + ptr[3] = i4; + options |= F_STRICTSOURCE; + } else { +- device = optarg; ++ device = strdup(optarg); + } + #else + if (inet_pton(AF_INET, optarg, &source.sin_addr) > 0) + options |= F_STRICTSOURCE; + else +- device = optarg; ++ device = strdup(optarg); + #endif + break; + } +diff -up iputils-s20071127/arping.c.ia64_align iputils-s20071127/arping.c +--- iputils-s20071127/arping.c.ia64_align 2008-06-02 08:56:32.000000000 +0200 ++++ iputils-s20071127/arping.c 2008-06-02 08:56:32.000000000 +0200 +@@ -351,7 +351,7 @@ main(int argc, char **argv) + timeout = atoi(optarg); + break; + case 'I': +- device = optarg; ++ device = strdup(optarg); + break; + case 'f': + quit_on_reply=1; +diff -up iputils-s20071127/ping6.c.ia64_align iputils-s20071127/ping6.c +--- iputils-s20071127/ping6.c.ia64_align 2008-06-02 08:56:32.000000000 +0200 ++++ iputils-s20071127/ping6.c 2008-06-02 08:56:32.000000000 +0200 +@@ -581,7 +581,7 @@ int main(int argc, char *argv[]) + + free(addr); + } else { +- device = optarg; ++ device = strdup(optarg); + } + break; + case 'M': diff --git a/srcpkgs/iputils/patches/iputils-20070202-idn.patch b/srcpkgs/iputils/patches/iputils-20070202-idn.patch new file mode 100644 index 00000000000..50347d32da3 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20070202-idn.patch @@ -0,0 +1,98 @@ +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 ++#include ++ + #include "ping_common.h" + + #include +@@ -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 ++ + #include "ping_common.h" + #include + #include +@@ -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, ""); + } + + diff --git a/srcpkgs/iputils/patches/iputils-20070202-traffic_class.patch b/srcpkgs/iputils/patches/iputils-20070202-traffic_class.patch new file mode 100644 index 00000000000..8a4ddf0f42a --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20070202-traffic_class.patch @@ -0,0 +1,14 @@ +diff -up iputils-s20070202/ping6.c.flowlabel iputils-s20070202/ping6.c +--- iputils-s20070202/ping6.c.flowlabel 2008-02-01 11:10:53.000000000 +0100 ++++ iputils-s20070202/ping6.c 2008-02-01 11:16:47.000000000 +0100 +@@ -86,6 +86,10 @@ char copyright[] = + #define SOL_ICMPV6 IPPROTO_ICMPV6 + #endif + ++#ifndef IVP6_FLOWINFO_SEND ++#define IPV6_FLOWINFO_SEND 33 ++#endif ++ + /* RFC3542 */ + #ifndef ICMP6_DST_UNREACH_BEYONDSCOPE + #define ICMP6_DST_UNREACH_BEYONDSCOPE ICMP6_DST_UNREACH_NOTNEIGHBOR diff --git a/srcpkgs/iputils/patches/iputils-20071127-corr_type.patch b/srcpkgs/iputils/patches/iputils-20071127-corr_type.patch new file mode 100644 index 00000000000..f7df5a63275 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20071127-corr_type.patch @@ -0,0 +1,88 @@ +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); + } diff --git a/srcpkgs/iputils/patches/iputils-20071127-infiniband.patch b/srcpkgs/iputils/patches/iputils-20071127-infiniband.patch new file mode 100644 index 00000000000..0d1a544d93b --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20071127-infiniband.patch @@ -0,0 +1,266 @@ +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 + #include + +-#include +- + #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; chsll_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) { diff --git a/srcpkgs/iputils/patches/iputils-20071127-warnings.patch b/srcpkgs/iputils/patches/iputils-20071127-warnings.patch new file mode 100644 index 00000000000..fd954fc25d7 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20071127-warnings.patch @@ -0,0 +1,126 @@ +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) diff --git a/srcpkgs/iputils/patches/iputils-20100418-convtoint.patch b/srcpkgs/iputils/patches/iputils-20100418-convtoint.patch new file mode 100644 index 00000000000..77c2256c509 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20100418-convtoint.patch @@ -0,0 +1,24 @@ +diff -up iputils-s20100418/tracepath6.c.convtoint iputils-s20100418/tracepath6.c +--- iputils-s20100418/tracepath6.c.convtoint 2010-04-23 11:28:15.294593391 +0200 ++++ iputils-s20100418/tracepath6.c 2010-04-23 11:28:23.544605551 +0200 +@@ -89,7 +89,7 @@ void print_host(const char *a, const cha + } + if (plen >= HOST_COLUMN_SIZE) + plen = HOST_COLUMN_SIZE - 1; +- printf("%*s", HOST_COLUMN_SIZE - plen, ""); ++ printf("%*s", HOST_COLUMN_SIZE - (int)plen, ""); + } + + int recverr(int fd, int ttl) +diff -up iputils-s20100418/tracepath.c.convtoint iputils-s20100418/tracepath.c +--- iputils-s20100418/tracepath.c.convtoint 2010-04-23 11:26:20.273555629 +0200 ++++ iputils-s20100418/tracepath.c 2010-04-23 11:26:20.281562493 +0200 +@@ -77,7 +77,7 @@ void print_host(const char *a, const cha + } + if (plen >= HOST_COLUMN_SIZE) + plen = HOST_COLUMN_SIZE - 1; +- printf("%*s", HOST_COLUMN_SIZE - plen, ""); ++ printf("%*s", HOST_COLUMN_SIZE - (int)plen, ""); + } + + int recverr(int fd, int ttl) diff --git a/srcpkgs/iputils/patches/iputils-20101006-drop_caps.patch b/srcpkgs/iputils/patches/iputils-20101006-drop_caps.patch new file mode 100644 index 00000000000..48b9bd21fd3 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20101006-drop_caps.patch @@ -0,0 +1,107 @@ +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 + #include + ++#ifdef HAVE_CAPABILITIES ++#include ++#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 + #include + ++#ifdef HAVE_CAPABILITIES ++#include ++#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; diff --git a/srcpkgs/iputils/patches/iputils-20101006-eth.patch b/srcpkgs/iputils/patches/iputils-20101006-eth.patch new file mode 100644 index 00000000000..edffddae635 --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20101006-eth.patch @@ -0,0 +1,91 @@ +diff -up iputils-s20101006/arping.c.eth iputils-s20101006/arping.c +--- iputils-s20101006/arping.c.eth 2011-11-10 09:06:08.101748109 +0100 ++++ iputils-s20101006/arping.c 2011-11-10 09:34:09.880501394 +0100 +@@ -37,7 +37,7 @@ + static void usage(void) __attribute__((noreturn)); + + int quit_on_reply=0; +-char *device="eth0"; ++char *device=NULL; + int ifindex; + char *source; + struct in_addr src, dst; +@@ -66,6 +66,11 @@ int received, brd_recv, req_recv; + #define SYSFS_PATH_LEN 256 + #define SOCKADDR_LEN (2 * sizeof(struct sockaddr_ll)) + ++#define PREF_ETH "eth" ++#define PREF_EM "em" ++ ++static char *dev_file = "/proc/self/net/dev"; ++ + #define MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \ + ((tv1).tv_usec-(tv2).tv_usec)/1000 ) + +@@ -377,6 +382,46 @@ char * read_sysfs_broadcast(char *brdcas + return brdcast; + } + ++/* ++ * get_first_ethernet - return the name of the first ethernet-style ++ * interface on this system. ++ */ ++char * get_first_ethernet(void) ++{ ++ FILE *f; ++ char buf[255], *dv, *smc; ++ char pci[16]; ++ ++ memset(pci, 0, sizeof(pci)); ++ if ((f = fopen(dev_file, "r")) != NULL) ++ { ++ // go through network dev file ++ while (fgets (buf, sizeof(buf), f) != NULL) ++ { ++ // the line describes interface ++ if ((smc = strchr(buf, ':')) != NULL) ++ { ++ // trim white characters ++ for (dv=buf, *smc=0; *dv <= ' '; dv++) ; ++ // is "eth" (originial ethernet name) or "em" (ethernet on board) ++ if (!strncmp(dv, PREF_ETH, strlen(PREF_ETH)) || ++ !strncmp(dv, PREF_EM, strlen(PREF_EM))) ++ { ++ return strdup(dv); ++ } ++ // remember the first pci NIC-card ++ if (strlen(pci) == 0 && dv[0] == 'p' && isdigit(dv[1])) ++ { ++ strcpy(pci, dv); ++ } ++ } ++ } ++ fclose(f); ++ } ++ // return pci NIC-card or nil if no if name ++ return strlen(pci) > 0 ? strdup(pci) : 0L; ++} ++ + int + main(int argc, char **argv) + { +@@ -403,6 +448,8 @@ main(int argc, char **argv) + exit(1); + } + ++ device = get_first_ethernet(); ++ + while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) { + switch(ch) { + case 'b': +@@ -429,6 +476,10 @@ main(int argc, char **argv) + timeout = atoi(optarg); + break; + case 'I': ++ if (device) { ++ free(device); ++ device = NULL; ++ } + device = strdup(optarg); + break; + case 'f': diff --git a/srcpkgs/iputils/patches/iputils-20101006-man.patch b/srcpkgs/iputils/patches/iputils-20101006-man.patch new file mode 100644 index 00000000000..9e2464975ea --- /dev/null +++ b/srcpkgs/iputils/patches/iputils-20101006-man.patch @@ -0,0 +1,53 @@ +diff -up iputils-s20101006/doc/ping.sgml.man iputils-s20101006/doc/ping.sgml +--- iputils-s20101006/doc/ping.sgml.man 2011-03-29 08:53:09.362500777 +0200 ++++ iputils-s20101006/doc/ping.sgml 2011-03-29 08:58:03.196423782 +0200 +@@ -62,8 +62,8 @@ Audible ping. +