142 lines
3.4 KiB
Plaintext
142 lines
3.4 KiB
Plaintext
--- Makefile
|
|
+++ Makefile 2000/02/02 16:03:05
|
|
@@ -1,8 +1,8 @@
|
|
#
|
|
# Makefile,v 1.4 1995/07/21 00:03:30 pb Exp
|
|
#
|
|
-MANDIR=/usr/local/man
|
|
-BINDIR=/usr/local/bin
|
|
+MANDIR=/usr/man
|
|
+BINDIR=/usr/bin
|
|
INSTALL=install -c
|
|
GROFF=groff
|
|
NROFF=nroff
|
|
@@ -28,5 +28,5 @@
|
|
$(RM) -f bing bing.ps bing.0
|
|
|
|
install: bing bing.8
|
|
- $(INSTALL) -m 644 -o man -g man bing.8 $(MANDIR)/man8
|
|
- $(INSTALL) -m 4555 -o root -g staff bing $(BINDIR)
|
|
+ $(INSTALL) -m 644 bing.8 $(MANDIR)/man8
|
|
+ $(INSTALL) -m 4555 -o root -g root bing $(BINDIR)
|
|
--- bing.c
|
|
+++ bing.c 2000/02/02 16:03:23
|
|
@@ -171,6 +171,8 @@
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
+#include <pwd.h>
|
|
+#include <grp.h>
|
|
|
|
#include "sysdep.h"
|
|
|
|
@@ -527,7 +529,7 @@
|
|
(void)printf(" %1x %04x", ((ip->ip_off) & 0xe000) >> 13,
|
|
(ip->ip_off) & 0x1fff);
|
|
(void)printf(" %02x %02x %04x", ip->ip_ttl, ip->ip_p, ip->ip_sum);
|
|
-#ifdef linux
|
|
+#if defined linux && !defined __NETINET_IP_ICMP_H
|
|
(void)printf(" %s ", inet_ntoa(ip->ip_src));
|
|
(void)printf(" %s ", inet_ntoa(ip->ip_dst));
|
|
#else
|
|
@@ -641,7 +643,7 @@
|
|
(void)printf("Redirect, Bad Code: %d", icp->icmp_code);
|
|
break;
|
|
}
|
|
-#ifdef linux
|
|
+#if defined linux && !defined __NETINET_IP_ICMP_H
|
|
(void)printf("(New addr: 0x%08lx)\n", icp->icmp_gwaddr);
|
|
#else
|
|
(void)printf("(New addr: 0x%08lx)\n", icp->icmp_gwaddr.s_addr);
|
|
@@ -668,7 +670,7 @@
|
|
pr_retip((struct ip *)ICMP_TO_DATA(icp));
|
|
break;
|
|
case ICMP_PARAMPROB:
|
|
-#ifdef linux
|
|
+#if defined linux && !defined __NETINET_IP_ICMP_H
|
|
(void)printf("Parameter problem: pointer = 0x%02x\n",
|
|
icp->un.gateway);
|
|
#else
|
|
@@ -1226,6 +1228,7 @@
|
|
struct protoent *proto;
|
|
struct in_addr ifaddr;
|
|
struct hoststats *hs1, *hs2;
|
|
+ struct passwd *pwd;
|
|
int ntrans, nloops, bits;
|
|
int i;
|
|
int ch, hold, recv_packlen, preload;
|
|
@@ -1403,6 +1406,21 @@
|
|
perror("bing: socket");
|
|
exit(1);
|
|
}
|
|
+
|
|
+ // drop root privs
|
|
+ if((pwd = getpwuid(getuid())) == NULL)
|
|
+ {
|
|
+ perror("bing: getpwuid()");
|
|
+ exit(1);
|
|
+ }
|
|
+ if(initgroups(pwd->pw_name, pwd->pw_gid) < 0)
|
|
+ {
|
|
+ perror("bing: initgroups()");
|
|
+ exit(1);
|
|
+ }
|
|
+ setgid(getgid());
|
|
+ setuid(getuid());
|
|
+
|
|
hold = 1;
|
|
if (options & F_SO_DEBUG)
|
|
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
|
|
--- sysdep.h
|
|
+++ sysdep.h 2000/02/02 16:03:05
|
|
@@ -46,7 +46,7 @@
|
|
#ifndef _SYSDEP_H_
|
|
#define _SYSDEP_H_
|
|
|
|
-#ifdef linux
|
|
+#if defined linux && !defined __NETINET_IP_ICMP_H
|
|
#define icmp icmphdr
|
|
#define ip iphdr
|
|
#define icmp_type type
|
|
@@ -66,7 +66,9 @@
|
|
#define ip_sum check
|
|
#define ip_src saddr
|
|
#define ip_dst daddr
|
|
+#ifndef MAX_IPOPTLEN
|
|
#define MAX_IPOPTLEN 4096
|
|
+#endif
|
|
#define ICMP_MINLEN 16
|
|
|
|
#define IPOPT_MINOFF 4
|
|
--- bing.c.xx 2005-01-26 12:50:36.266794880 +0100
|
|
+++ bing.c 2005-01-26 12:52:08.935169111 +0100
|
|
@@ -168,6 +168,7 @@
|
|
#include <netdb.h>
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
+#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
@@ -1234,7 +1235,7 @@
|
|
int i;
|
|
int ch, hold, recv_packlen, preload;
|
|
u_char *datap, *recv_packet;
|
|
- char *target1, *target2, *malloc();
|
|
+ char *target1, *target2;
|
|
u_char ttl, loop;
|
|
#ifdef IP_OPTIONS
|
|
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
|
|
@@ -1349,9 +1350,10 @@
|
|
moptions |= MULTICAST_IF;
|
|
{
|
|
int i1, i2, i3, i4;
|
|
+ char dummy;
|
|
|
|
if (sscanf(optarg, "%u.%u.%u.%u%c",
|
|
- &i1, &i2, &i3, &i4, &i) != 4) {
|
|
+ &i1, &i2, &i3, &i4, &dummy) != 4) {
|
|
printf("bad interface address '%s'\n",
|
|
optarg);
|
|
exit(1);
|