net-tools/net-tools-1.60-upstream.patch

517 lines
17 KiB
Diff

diff -up net-tools-1.60/arp.c.upstream net-tools-1.60/arp.c
--- net-tools-1.60/arp.c.upstream 2011-10-19 18:38:24.995394688 +0200
+++ net-tools-1.60/arp.c 2011-10-19 18:38:25.023394339 +0200
@@ -557,7 +557,7 @@ static int arp_show(char *name)
/* Read the ARP cache entries. */
for (num = 0; num < entries; num++) {
fgets(line, sizeof(line), fp);
- if (sscanf(line, "%s 0x%x 0x%x %100s %100s %100s\n",
+ if (sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n",
ip, &type, &flags, hwa, mask, dev) < 4)
break;
diff -up net-tools-1.60/ifconfig.c.upstream net-tools-1.60/ifconfig.c
--- net-tools-1.60/ifconfig.c.upstream 2011-10-19 18:38:25.000000000 +0200
+++ net-tools-1.60/ifconfig.c 2011-10-19 18:50:49.327089262 +0200
@@ -51,7 +51,7 @@
#include <asm/types.h>
-#ifdef HAVE_HWSLIP
+#if HAVE_HWSLIP
#include <linux/if_slip.h>
#endif
@@ -784,7 +784,7 @@ int main(int argc, char **argv)
continue;
}
#endif
-#ifdef HAVE_AFINET
+#if HAVE_AFINET
{ /* ipv4 address a.b.c.d */
unsigned long ip, nm, bc;
safe_strncpy(host, *spp, (sizeof host));
@@ -875,7 +875,7 @@ int main(int argc, char **argv)
continue;
}
#endif
-#ifdef HAVE_AFINET
+#if HAVE_AFINET
{
/* ipv4 address a.b.c.d */
unsigned long ip, nm, bc;
diff -up net-tools-1.60/lib/inet6_gr.c.upstream net-tools-1.60/lib/inet6_gr.c
--- net-tools-1.60/lib/inet6_gr.c.upstream 2011-10-19 18:38:24.788397275 +0200
+++ net-tools-1.60/lib/inet6_gr.c 2011-10-19 18:38:25.023394339 +0200
@@ -78,7 +78,7 @@ int rprint_fib6(int ext, int numeric)
"Flags Metric Ref Use Iface\n"));
while (fgets(buff, 1023, fp)) {
- num = sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %4s%4s%4s%4s%4s%4s%4s%4s %02x %4s%4s%4s%4s%4s%4s%4s%4s %08x %08x %08x %08x %s\n",
+ num = sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %4s%4s%4s%4s%4s%4s%4s%4s %02x %4s%4s%4s%4s%4s%4s%4s%4s %08x %08x %08x %08x %15s\n",
addr6p[0], addr6p[1], addr6p[2], addr6p[3],
addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&prefix_len,
diff -up net-tools-1.60/lib/inet_gr.c.upstream net-tools-1.60/lib/inet_gr.c
--- net-tools-1.60/lib/inet_gr.c.upstream 2000-10-28 12:59:42.000000000 +0200
+++ net-tools-1.60/lib/inet_gr.c 2011-10-19 18:38:25.024394326 +0200
@@ -68,19 +68,19 @@ int rprint_fib(int ext, int numeric)
mss = 0;
fmt = proc_gen_fmt(_PATH_PROCNET_ROUTE, 0, fp,
- "Iface", "%16s",
- "Destination", "%128s",
- "Gateway", "%128s",
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
"Flags", "%X",
"RefCnt", "%d",
"Use", "%d",
"Metric", "%d",
- "Mask", "%128s",
+ "Mask", "%127s",
"MTU", "%d",
"Window", "%d",
"IRTT", "%d",
NULL);
- /* "%16s %128s %128s %X %d %d %d %128s %d %d %d\n" */
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d\n" */
if (!fmt)
return 1;
@@ -268,21 +268,21 @@ int rprint_cache(int ext, int numeric)
"MSS Window irtt HH Arp\n"));
fmt = proc_gen_fmt(_PATH_PROCNET_RTCACHE, 0, fp,
- "Iface", "%16s",
- "Destination", "%128s",
- "Gateway", "%128s",
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
"Flags", "%X",
"RefCnt", "%d",
"Use", "%d",
"Metric", "%d",
- "Source", "%128s",
+ "Source", "%127s",
"MTU", "%d",
"Window", "%d",
"IRTT", "%d",
"HH", "%d",
"ARP", "%d",
NULL);
- /* "%16s %128s %128s %X %d %d %d %128s %d %d %d %d %d\n" */
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d %d %d\n" */
}
if (format == 2) {
@@ -291,23 +291,23 @@ int rprint_cache(int ext, int numeric)
"Flags Metric Ref Use Iface "
"MSS Window irtt TOS HHRef HHUptod SpecDst\n"));
fmt = proc_gen_fmt(_PATH_PROCNET_RTCACHE, 0, fp,
- "Iface", "%16s",
- "Destination", "%128s",
- "Gateway", "%128s",
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
"Flags", "%X",
"RefCnt", "%d",
"Use", "%d",
"Metric", "%d",
- "Source", "%128s",
+ "Source", "%127s",
"MTU", "%d",
"Window", "%d",
"IRTT", "%d",
"TOS", "%d",
"HHRef", "%d",
"HHUptod", "%d",
- "SpecDst", "%128s",
+ "SpecDst", "%127s",
NULL);
- /* "%16s %128s %128s %X %d %d %d %128s %d %d %d %d %d %128s\n" */
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d %d %d %127s\n" */
}
diff -up net-tools-1.60/lib/interface.c.upstream net-tools-1.60/lib/interface.c
--- net-tools-1.60/lib/interface.c.upstream 2011-10-19 18:38:24.982394852 +0200
+++ net-tools-1.60/lib/interface.c 2011-10-19 18:50:49.328089249 +0200
@@ -36,7 +36,7 @@
#include <neteconet/ec.h>
#endif
-#ifdef HAVE_HWSLIP
+#if HAVE_HWSLIP
#include <linux/if_slip.h>
#include <net/if_arp.h>
#endif
@@ -482,7 +482,7 @@ int if_fetch(struct interface *ife)
else
ife->mtu = ifr.ifr_mtu;
-#ifdef HAVE_HWSLIP
+#if HAVE_HWSLIP
if (ife->type == ARPHRD_SLIP || ife->type == ARPHRD_CSLIP ||
ife->type == ARPHRD_SLIP6 || ife->type == ARPHRD_CSLIP6 ||
ife->type == ARPHRD_ADAPT) {
@@ -491,14 +491,14 @@ int if_fetch(struct interface *ife)
if (ioctl(skfd, SIOCGOUTFILL, &ifr) < 0)
ife->outfill = 0;
else
- ife->outfill = (unsigned int) ifr.ifr_data;
+ ife->outfill = (unsigned long) ifr.ifr_data;
#endif
#ifdef SIOCGKEEPALIVE
strcpy(ifr.ifr_name, ifname);
if (ioctl(skfd, SIOCGKEEPALIVE, &ifr) < 0)
ife->keepalive = 0;
else
- ife->keepalive = (unsigned int) ifr.ifr_data;
+ ife->keepalive = (unsigned long) ifr.ifr_data;
#endif
}
#endif
@@ -713,7 +713,7 @@ void ife_print_long(struct interface *pt
#endif
#if HAVE_AFINET6
FILE *f;
- char addr6[40], devname[20];
+ char addr6[40], devname[21];
struct sockaddr_in6 sap;
int plen, scope, dad_status, if_idx;
extern struct aftype inet6_aftype;
@@ -726,8 +726,10 @@ void ife_print_long(struct interface *pt
hf = ptr->type;
+#if HAVE_HWSLIP
if (hf == ARPHRD_CSLIP || hf == ARPHRD_CSLIP6)
can_compress = 1;
+#endif
hw = get_hwntype(hf);
if (hw == NULL)
@@ -766,7 +768,7 @@ void ife_print_long(struct interface *pt
/* FIXME: should be integrated into interface.c. */
if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {
- while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n",
+ while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
addr6p[0], addr6p[1], addr6p[2], addr6p[3],
addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&if_idx, &plen, &scope, &dad_status, devname) != EOF) {
diff -up net-tools-1.60/lib/Makefile.upstream net-tools-1.60/lib/Makefile
--- net-tools-1.60/lib/Makefile.upstream 2011-10-19 18:38:24.864396327 +0200
+++ net-tools-1.60/lib/Makefile 2011-10-19 18:44:50.511575073 +0200
@@ -36,7 +36,7 @@ OBJS = $(sort $(VARIA) $(AFOBJS) $(HWOBJ
# This can be overwritten by the TOPLEVEL Makefile
TOPDIR=..
-CFLAGS += -I$(TOPDIR) -idirafter $(TOPDIR)/include # -fPIC
+CFLAGS += -I$(TOPDIR) -I$(TOPDIR)/include # -fPIC
SONAME=libnet-tools.so.0
.SUFFIXES: .a .so
diff -up net-tools-1.60/lib/masq_info.c.upstream net-tools-1.60/lib/masq_info.c
--- net-tools-1.60/lib/masq_info.c.upstream 2000-10-28 12:59:42.000000000 +0200
+++ net-tools-1.60/lib/masq_info.c 2011-10-19 18:42:06.663623453 +0200
@@ -119,7 +119,9 @@ static int read_masqinfo(FILE * f, struc
ms->src.sin_family = AF_INET;
ms->dst.sin_family = AF_INET;
- if (strcmp("TCP", buf) == 0)
+ if (strcmp("IP", buf) == 0)
+ ms->proto = "ip";
+ else if (strcmp("TCP", buf) == 0)
ms->proto = "tcp";
else if (strcmp("UDP", buf) == 0)
ms->proto = "udp";
diff -up net-tools-1.60/lib/net-support.h.upstream net-tools-1.60/lib/net-support.h
--- net-tools-1.60/lib/net-support.h.upstream 2000-10-28 12:59:42.000000000 +0200
+++ net-tools-1.60/lib/net-support.h 2011-10-19 18:50:49.422088074 +0200
@@ -234,7 +234,7 @@ extern char afname[];
/* this is a 2.0.36 flag from /usr/src/linux/include/linux/route.h */
#define RTF_NOTCACHED 0x0400 /* this route isn't cached */
-#ifdef HAVE_AFECONET
+#if HAVE_AFECONET
#ifndef AF_ECONET
#define AF_ECONET 19 /* Acorn Econet */
#endif
diff -up net-tools-1.60/lib/rose.c.upstream net-tools-1.60/lib/rose.c
--- net-tools-1.60/lib/rose.c.upstream 2000-03-05 12:26:03.000000000 +0100
+++ net-tools-1.60/lib/rose.c 2011-10-19 18:40:22.871921029 +0200
@@ -86,7 +86,7 @@ static int ROSE_input(int type, char *bu
if (strlen(bufp) != 10) {
strcpy(ROSE_errmsg, _("Node address must be ten digits"));
#ifdef DEBUG
- fprintf(stderr, "rose_input(%s): %s !\n", ROSE_errmsg, orig);
+ fprintf(stderr, "rose_input(%s): %s !\n", bufp, ROSE_errmsg);
#endif
errno = EINVAL;
return (-1);
@@ -99,7 +99,7 @@ static int ROSE_input(int type, char *bu
/* All done. */
#ifdef DEBUG
- fprintf(stderr, "rose_input(%s): ", orig);
+ fprintf(stderr, "rose_input(%s): ", bufp);
for (i = 0; i < sizeof(rose_address); i++)
fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
fprintf(stderr, "\n");
diff -up net-tools-1.60/lib/x25.c.upstream net-tools-1.60/lib/x25.c
--- net-tools-1.60/lib/x25.c.upstream 2000-05-20 20:53:25.000000000 +0200
+++ net-tools-1.60/lib/x25.c 2011-10-19 18:40:22.871921029 +0200
@@ -81,6 +81,7 @@ X25_input(int type, char *bufp, struct s
unsigned char *ptr;
char *p;
unsigned int sigdigits;
+ int i;
sap->sa_family = x25_aftype.af;
ptr = ((struct sockaddr_x25 *)sap)->sx25_addr.x25_addr;
@@ -90,7 +91,7 @@ X25_input(int type, char *bufp, struct s
if (strlen(bufp)>18) {
strcpy(X25_errmsg, _("Address can't exceed eighteen digits with sigdigits"));
#ifdef DEBUG
- fprintf(stderr, "x25_input(%s): %s !\n", X25_errmsg, orig);
+ fprintf(stderr, "x25_input(%s): %s !\n", bufp, X25_errmsg);
#endif
errno = EINVAL;
return(-1);
@@ -108,7 +109,7 @@ X25_input(int type, char *bufp, struct s
*p = '/';
strcpy(X25_errmsg, _("Invalid address"));
#ifdef DEBUG
- fprintf(stderr, "x25_input(%s): %s !\n", X25_errmsg, orig);
+ fprintf(stderr, "x25_input(%s): %s !\n", bufp, X25_errmsg);
#endif
errno = EINVAL;
return(-1);
@@ -118,8 +119,8 @@ X25_input(int type, char *bufp, struct s
/* All done. */
#ifdef DEBUG
- fprintf(stderr, "x25_input(%s): ", orig);
- for (i = 0; i < sizeof(x25_address); i++)
+ fprintf(stderr, "x25_input(%s): ", bufp);
+ for (i = 0; i < sizeof(sap->sa_data); i++)
fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
fprintf(stderr, "\n");
#endif
diff -up net-tools-1.60/Makefile.upstream net-tools-1.60/Makefile
--- net-tools-1.60/Makefile.upstream 2011-10-19 18:38:24.895395939 +0200
+++ net-tools-1.60/Makefile 2011-10-19 18:44:50.512575060 +0200
@@ -88,10 +88,9 @@ endif
# Compiler and Linker Options
# You may need to uncomment and edit these if you are using libc5 and IPv6.
-COPTS = -D_GNU_SOURCE -O2 -Wall -g # -I/usr/inet6/include
-ifeq ($(origin LOPTS), undefined)
-LOPTS =
-endif
+CFLAGS ?= -O2 -g
+CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
+CPPFLAGS += -D_GNU_SOURCE
RESLIB = # -L/usr/inet6/lib -linet6
ifeq ($(HAVE_AFDECnet),1)
@@ -119,8 +118,9 @@ CFLAGS += -DHAVE_SELINUX
else
endif
-CFLAGS += $(COPTS) -I. -idirafter ./include/ -I$(NET_LIB_PATH)
-LDFLAGS += $(LOPTS) -L$(NET_LIB_PATH)
+CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
+LDFLAGS += -L$(NET_LIB_PATH)
+
SUBDIRS = man/ $(NET_LIB_PATH)/
@@ -131,8 +131,6 @@ LD = $(CC)
NLIB = -l$(NET_LIB_NAME)
-MDEFINES = COPTS='$(COPTS)' LOPTS='$(LOPTS)' TOPDIR='$(TOPDIR)'
-
%.o: %.c config.h version.h intl.h net-features.h $<
$(CC) $(CFLAGS) -c $<
@@ -181,14 +179,15 @@ $(NET_LIB): config.h version.h intl.h li
i18n.h: i18ndir
-libdir:
- @$(MAKE) -C $(NET_LIB_PATH) $(MDEFINES)
+libdir: version.h
+ @$(MAKE) -C $(NET_LIB_PATH)
i18ndir:
@$(MAKE) -C po
subdirs:
- @for i in $(SUBDIRS); do $(MAKE) -C $$i $(MDEFINES) ; done
+ @for i in $(SUBDIRS); do $(MAKE) -C $$i || exit $$? ; done
+
ifconfig: $(NET_LIB) ifconfig.o
$(CC) $(LDFLAGS) -o ifconfig ifconfig.o $(NLIB) $(RESLIB)
diff -up net-tools-1.60/netstat.c.upstream net-tools-1.60/netstat.c
--- net-tools-1.60/netstat.c.upstream 2011-10-19 18:38:25.021394364 +0200
+++ net-tools-1.60/netstat.c 2011-10-19 18:52:06.264127416 +0200
@@ -357,6 +357,12 @@ static void prg_cache_clear(void)
prg_cache_loaded=0;
}
+static void wait_continous(const int reptimer)
+{
+ fflush(stdout);
+ sleep(reptimer);
+}
+
static void extract_type_1_socket_inode(const char lname[], unsigned long * inode_p, int * status) {
/* If lname is of the form "socket:[12345]", extract the "12345"
@@ -407,7 +413,7 @@ static void prg_cache_load(void)
{
char line[LINE_MAX],eacces=0;
int procfdlen,fd,cmdllen,lnamelen;
- char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH];
+ char lname[30],cmdlbuf[512],finbuf[PROGNAME_WIDTH],*cmdlpend;
unsigned long inode;
const char *cs,*cmdlp;
DIR *dirproc=NULL,*dirfd=NULL;
@@ -478,10 +484,12 @@ static void prg_cache_load(void)
continue;
if (cmdllen < sizeof(cmdlbuf) - 1)
cmdlbuf[cmdllen]='\0';
- if ((cmdlp = strrchr(cmdlbuf, '/')))
+ if (cmdlbuf[0] == '/' && (cmdlp = strrchr(cmdlbuf, '/')))
cmdlp++;
else
cmdlp = cmdlbuf;
+ if ((cmdlpend = strrchr(cmdlp, ':')) != NULL)
+ *cmdlpend = '\0';
}
snprintf(finbuf, sizeof(finbuf), "%s/%s", direproc->d_name, cmdlp);
@@ -961,6 +969,10 @@ static void tcp_do_one(int lnr, const ch
&d, local_addr, &local_port, rem_addr, &rem_port, &state,
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
+ if (!flag_all &&
+ ((flag_lst && rem_port) || (!flag_lst && !rem_port)))
+ return;
+
if (strlen(local_addr) > 8) {
#if HAVE_AFINET6
/* Demangle what the kernel gives us */
@@ -1014,7 +1026,7 @@ static void tcp_do_one(int lnr, const ch
flag_not & FLAG_NUM_HOST), sizeof(local_addr));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr, flag_not & FLAG_NUM_HOST),
sizeof(rem_addr));
- if (flag_all || (flag_lst && !rem_port) || (!flag_lst && rem_port)) {
+
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(local_port), "tcp",
flag_not & FLAG_NUM_PORT));
@@ -1073,7 +1085,6 @@ static void tcp_do_one(int lnr, const ch
rxq, txq, local_addr, rem_addr, _(tcp_state[state]));
finish_this_one(uid,inode,timers);
- }
}
static int tcp_info(void)
@@ -1103,7 +1114,7 @@ static void udp_do_one(int lnr, const ch
more[0] = '\0';
num = sscanf(line,
- "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
+ "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %511s\n",
&d, local_addr, &local_port,
rem_addr, &rem_port, &state,
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
@@ -1540,7 +1551,7 @@ static void raw_do_one(int lnr, const ch
more[0] = '\0';
num = sscanf(line,
- "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %512s\n",
+ "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %511s\n",
&d, local_addr, &local_port, rem_addr, &rem_port, &state,
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
@@ -2288,7 +2299,7 @@ int main
flag_not & FLAG_NUM_PORT, flag_exp);
if (i || !flag_cnt)
break;
- sleep(reptimer);
+ wait_continous(reptimer);
}
#else
ENOSUPP("netstat.c", "FW_MASQUERADE");
@@ -2304,7 +2315,7 @@ int main
if(i || !flag_cnt)
break;
- sleep(reptimer);
+ wait_continous(reptimer);
}
return(i);
}
@@ -2328,7 +2339,7 @@ int main
i = route_info(afname, options);
if (i || !flag_cnt)
break;
- sleep(reptimer);
+ wait_continous(reptimer);
}
return (i);
}
@@ -2337,7 +2348,7 @@ int main
i = iface_info();
if (!flag_cnt || i)
break;
- sleep(reptimer);
+ wait_continous(reptimer);
}
return (i);
}
@@ -2469,7 +2480,7 @@ int main
}
if (!flag_cnt || i)
break;
- sleep(reptimer);
+ wait_continous(reptimer);
prg_cache_clear();
tcp_node_hash_clear();
}
diff -up net-tools-1.60/slattach.c.upstream net-tools-1.60/slattach.c
--- net-tools-1.60/slattach.c.upstream 2000-10-28 12:59:41.000000000 +0200
+++ net-tools-1.60/slattach.c 2011-10-19 18:45:41.367939279 +0200
@@ -195,15 +195,17 @@ tty_lock(char *path, int mode)
return(-1);
}
- (void) close(fd);
-
/* Make sure UUCP owns the lockfile. Required by some packages. */
if ((pw = getpwnam(_UID_UUCP)) == NULL) {
if (opt_q == 0) fprintf(stderr, _("slattach: tty_lock: UUCP user %s unknown!\n"),
_UID_UUCP);
+ (void) close(fd);
return(0); /* keep the lock anyway */
}
- (void) chown(saved_path, pw->pw_uid, pw->pw_gid);
+ (void) fchown(fd, pw->pw_uid, pw->pw_gid);
+
+ (void) close(fd);
+
saved_lock = 1;
} else { /* unlock */
if (saved_lock != 1) return(0);