- removed a dependency on libsysfs library in arping
This commit is contained in:
parent
3717a59938
commit
921578f7dc
@ -1,27 +1,7 @@
|
||||
diff -up iputils-s20070202/Makefile.infiniband iputils-s20070202/Makefile
|
||||
--- iputils-s20070202/Makefile.infiniband 2008-02-18 16:47:39.000000000 +0100
|
||||
+++ iputils-s20070202/Makefile 2008-02-18 16:47:39.000000000 +0100
|
||||
@@ -37,6 +37,8 @@ rdisc_srv: rdisc_srv.o
|
||||
rdisc_srv.o: rdisc.c
|
||||
$(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
|
||||
|
||||
+arping: arping.o
|
||||
+ $(CC) $(LDFLAGS) arping.o $(LOADLIBES) $(LDLIBS) -lsysfs -o arping
|
||||
|
||||
check-kernel:
|
||||
ifeq ($(KERNEL_INCLUDE),)
|
||||
diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
--- iputils-s20070202/arping.c.infiniband 2008-02-18 16:47:39.000000000 +0100
|
||||
+++ iputils-s20070202/arping.c 2008-02-18 16:50:44.000000000 +0100
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
+#include <sysfs/libsysfs.h>
|
||||
|
||||
#include "SNAPSHOT.h"
|
||||
|
||||
@@ -50,8 +51,13 @@ int unicasting;
|
||||
diff -up iputils-s20071127/arping.c.infiniband iputils-s20071127/arping.c
|
||||
--- iputils-s20071127/arping.c.infiniband 2007-11-27 01:57:27.000000000 +0100
|
||||
+++ iputils-s20071127/arping.c 2008-08-08 10:05:04.000000000 +0200
|
||||
@@ -50,14 +50,26 @@ int unicasting;
|
||||
int s;
|
||||
int broadcast_only;
|
||||
|
||||
@ -37,7 +17,20 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
|
||||
struct timeval start, last;
|
||||
|
||||
@@ -124,7 +130,8 @@ int send_pack(int s, struct in_addr src,
|
||||
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 MS_TDIFF(tv1,tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
|
||||
((tv1).tv_usec-(tv2).tv_usec)/1000 )
|
||||
|
||||
@@ -124,7 +136,8 @@ int send_pack(int s, struct in_addr src,
|
||||
p+=4;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
@ -47,7 +40,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
if (err == p-buf) {
|
||||
last = now;
|
||||
sent++;
|
||||
@@ -172,7 +179,7 @@ void catcher(void)
|
||||
@@ -172,7 +185,7 @@ void catcher(void)
|
||||
finish();
|
||||
|
||||
if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
|
||||
@ -56,7 +49,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
if (count == 0 && unsolicited)
|
||||
finish();
|
||||
}
|
||||
@@ -219,7 +226,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
@@ -219,7 +232,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
return 0;
|
||||
if (ah->ar_pln != 4)
|
||||
return 0;
|
||||
@ -65,7 +58,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
return 0;
|
||||
if (len < sizeof(*ah) + 2*(4 + ah->ar_hln))
|
||||
return 0;
|
||||
@@ -230,7 +237,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
@@ -230,7 +243,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
return 0;
|
||||
if (src.s_addr != dst_ip.s_addr)
|
||||
return 0;
|
||||
@ -74,7 +67,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
return 0;
|
||||
} else {
|
||||
/* DAD packet was:
|
||||
@@ -248,7 +255,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
@@ -248,7 +261,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
*/
|
||||
if (src_ip.s_addr != dst.s_addr)
|
||||
return 0;
|
||||
@ -83,7 +76,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
return 0;
|
||||
if (src.s_addr && src.s_addr != dst_ip.s_addr)
|
||||
return 0;
|
||||
@@ -264,7 +271,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
@@ -264,7 +277,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
printf("for %s ", inet_ntoa(dst_ip));
|
||||
s_printed = 1;
|
||||
}
|
||||
@ -92,7 +85,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
if (!s_printed)
|
||||
printf("for ");
|
||||
printf("[");
|
||||
@@ -290,7 +297,7 @@ int recv_pack(unsigned char *buf, int le
|
||||
@@ -290,12 +303,69 @@ int recv_pack(unsigned char *buf, int le
|
||||
if (quit_on_reply)
|
||||
finish();
|
||||
if(!broadcast_only) {
|
||||
@ -101,7 +94,69 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
unicasting=1;
|
||||
}
|
||||
return 1;
|
||||
@@ -459,9 +466,9 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
+int get_sysfs_mnt_path(char *mnt_path, size_t len)
|
||||
+{
|
||||
+ const char *sysfs_path_env;
|
||||
+ int pth_len=0;
|
||||
+
|
||||
+ if (len == 0 || mnt_path == NULL)
|
||||
+ return -1;
|
||||
+
|
||||
+ /* 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 ((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;
|
||||
+
|
||||
+ snprintf(broadcast_path, len,
|
||||
+ "%s/" SYSFS_CLASS "/" SYSFS_NET "/%s/" SYSFS_BROADCAST,
|
||||
+ mnt_path, device);
|
||||
+
|
||||
+ 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
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -459,9 +529,9 @@ main(int argc, char **argv)
|
||||
close(probe_fd);
|
||||
};
|
||||
|
||||
@ -114,7 +169,7 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
if (bind(s, (struct sockaddr*)&me, sizeof(me)) == -1) {
|
||||
perror("bind");
|
||||
exit(2);
|
||||
@@ -474,14 +481,37 @@ main(int argc, char **argv)
|
||||
@@ -474,14 +544,33 @@ main(int argc, char **argv)
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@ -124,39 +179,34 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
printf("Interface \"%s\" is not ARPable (no ll address)\n", device);
|
||||
exit(dad?0:2);
|
||||
}
|
||||
-
|
||||
- he = me;
|
||||
- memset(he.sll_addr, -1, he.sll_halen);
|
||||
+ he[0] = me[0];
|
||||
+ he[1] = me[1];
|
||||
+ {
|
||||
+ struct sysfs_class_device *dev;
|
||||
+ struct sysfs_attribute *brdcast;
|
||||
+ char *next_ch;
|
||||
+ char brdcast_path[SYSFS_PATH_LEN];
|
||||
+ char *brdcast_val;
|
||||
+ char *next_ch;
|
||||
+
|
||||
+ dev = sysfs_open_class_device("net", device);
|
||||
+ if (!dev) {
|
||||
+ perror("sysfs class device");
|
||||
+ exit(2);
|
||||
+ }
|
||||
+ brdcast = sysfs_get_classdev_attr(dev, "broadcast");
|
||||
+ if (!brdcast) {
|
||||
+ perror("sysfs attribute broadcast");
|
||||
+ exit(2);
|
||||
+ }
|
||||
+ if (sysfs_read_attribute(brdcast)) {
|
||||
+ perror("sysfs read brdcast");
|
||||
+ exit(2);
|
||||
+ }
|
||||
+ for (ch=0; ch<he[0].sll_halen; ch++) {
|
||||
+ he[0].sll_addr[ch] = strtol(brdcast->value + (ch*3),
|
||||
+ &next_ch, 16);
|
||||
+ }
|
||||
+ 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[0].sll_halen; ch++) {
|
||||
+ he[0].sll_addr[ch] = strtol(brdcast_val + (ch*3), &next_ch, 16);
|
||||
+ }
|
||||
|
||||
- he = me;
|
||||
- memset(he.sll_addr, -1, he.sll_halen);
|
||||
+ free(brdcast_val);
|
||||
+ }
|
||||
|
||||
if (!quiet) {
|
||||
printf("ARPING %s ", inet_ntoa(dst));
|
||||
@@ -501,7 +531,7 @@ main(int argc, char **argv)
|
||||
@@ -501,12 +590,12 @@ main(int argc, char **argv)
|
||||
while(1) {
|
||||
sigset_t sset, osset;
|
||||
unsigned char packet[4096];
|
||||
@ -165,7 +215,13 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
socklen_t alen = sizeof(from);
|
||||
int cc;
|
||||
|
||||
@@ -514,7 +544,7 @@ main(int argc, char **argv)
|
||||
if ((cc = recvfrom(s, packet, sizeof(packet), 0,
|
||||
- (struct sockaddr *)&from, &alen)) < 0) {
|
||||
+ (struct sockaddr *)&from[0], &alen)) < 0) {
|
||||
perror("arping: recvfrom");
|
||||
continue;
|
||||
}
|
||||
@@ -514,7 +603,7 @@ main(int argc, char **argv)
|
||||
sigaddset(&sset, SIGALRM);
|
||||
sigaddset(&sset, SIGINT);
|
||||
sigprocmask(SIG_BLOCK, &sset, &osset);
|
||||
@ -174,3 +230,15 @@ diff -up iputils-s20070202/arping.c.infiniband iputils-s20070202/arping.c
|
||||
sigprocmask(SIG_SETMASK, &osset, NULL);
|
||||
}
|
||||
}
|
||||
diff -up iputils-s20071127/Makefile.infiniband iputils-s20071127/Makefile
|
||||
--- iputils-s20071127/Makefile.infiniband 2008-08-08 09:17:35.000000000 +0200
|
||||
+++ iputils-s20071127/Makefile 2008-08-08 10:02:10.000000000 +0200
|
||||
@@ -37,6 +37,8 @@ rdisc_srv: rdisc_srv.o
|
||||
rdisc_srv.o: rdisc.c
|
||||
$(CC) $(CFLAGS) -DRDISC_SERVER -o rdisc_srv.o rdisc.c
|
||||
|
||||
+arping: arping.o
|
||||
+ $(CC) $(LDFLAGS) arping.o $(LOADLIBES) $(LDLIBS) -o arping
|
||||
|
||||
check-kernel:
|
||||
ifeq ($(KERNEL_INCLUDE),)
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: Network monitoring tools including ping
|
||||
Name: iputils
|
||||
Version: 20071127
|
||||
Release: 4%{?dist}
|
||||
Release: 5%{?dist}
|
||||
License: BSD
|
||||
URL: http://www.skbuff.net/iputils
|
||||
Group: System Environment/Daemons
|
||||
@ -29,7 +29,6 @@ Patch14: iputils-20071127-typing_bug.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: docbook-utils perl-SGMLSpm
|
||||
BuildRequires: glibc-kernheaders >= 2.4-8.19
|
||||
BuildRequires: libsysfs-devel
|
||||
BuildRequires: libidn-devel
|
||||
Requires(post): /sbin/chkconfig
|
||||
Requires(post): /usr/sbin/setcap
|
||||
@ -112,6 +111,7 @@ mv -f RELNOTES.tmp RELNOTES
|
||||
|
||||
%post
|
||||
/sbin/chkconfig --add rdisc
|
||||
|
||||
/usr/sbin/setcap cap_net_raw=ep /bin/ping
|
||||
/usr/sbin/setcap cap_net_raw=ep /bin/ping6
|
||||
|
||||
@ -152,6 +152,9 @@ rm -rf ${RPM_BUILD_ROOT}
|
||||
%{_sysconfdir}/rc.d/init.d/rdisc
|
||||
|
||||
%changelog
|
||||
* Fri Aug 15 2008 Jiri Skala <jskala@redhat.com> - 20071127-5
|
||||
- removed a dependency on libsysfs library in arping
|
||||
|
||||
* Wed Aug 06 2008 Jiri Skala <jskala@redhat.com> - 20071127-4
|
||||
- Resolves: #455713 remove suid from ping
|
||||
- corrected typing error in man
|
||||
|
Loading…
Reference in New Issue
Block a user