PSARC 2008/161 MTR - My Traceroute s11-update
authorDanek Duvall <danek.duvall@oracle.com>
Tue, 31 Mar 2015 13:48:00 -0700
branchs11-update
changeset 4058 2c35b27b5cde
parent 4033 f7924751c494
child 4067 4be1f488dda8
PSARC 2008/161 MTR - My Traceroute 18997106 mtr 0.86
components/mtr/Makefile
components/mtr/exec_attr.txt
components/mtr/mtr.p5m
components/mtr/patches/FINBIO.patch
components/mtr/patches/ncurses.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/mtr/Makefile	Tue Mar 31 13:48:00 2015 -0700
@@ -0,0 +1,63 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../make-rules/shared-macros.mk
+
+COMPONENT_NAME=		mtr
+COMPONENT_VERSION=	0.86
+COMPONENT_PROJECT_URL=	http://www.bitwizard.nl/mtr/
+COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
+COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.gz
+COMPONENT_ARCHIVE_HASH=	\
+    sha256:7912f049f9506748913e2866068b7f95b11a4e0a855322120b456c46ac9eb763
+COMPONENT_ARCHIVE_URL=	https://github.com/traviscross/mtr/archive/v$(COMPONENT_VERSION).tar.gz
+COMPONENT_BUGDB=	utility/mtr
+
+TPNO=			18130
+
+include ../../make-rules/prep.mk
+include ../../make-rules/configure.mk
+include ../../make-rules/ips.mk
+
+CONFIGURE_SBINDIR.64 =		$(CONFIGURE_PREFIX)/bin
+CONFIGURE_OPTIONS  +=		--without-gtk
+CONFIGURE_OPTIONS  +=		--without-ipinfo
+CONFIGURE_OPTIONS  +=		CFLAGS="$(CFLAGS)"
+CONFIGURE_OPTIONS  +=		LDFLAGS="$(LDFLAGS) $(CC_BITS)"
+
+COMPONENT_PRE_CONFIGURE_ACTION += (cd $(SOURCE_DIR); ./bootstrap.sh)
+
+ASLR_MODE = $(ASLR_ENABLE)
+
+# common targets
+build:		$(BUILD_64)
+
+install:	$(INSTALL_64)
+
+test:		$(NO_TESTS)
+
+REQUIRED_PACKAGES += library/ncurses
+REQUIRED_PACKAGES += system/library
+REQUIRED_PACKAGES += system/library/math
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/mtr/exec_attr.txt	Tue Mar 31 13:48:00 2015 -0700
@@ -0,0 +1,1 @@
+Forced Privilege:solaris:cmd:RO::/usr/bin/mtr:privs=net_icmpaccess,net_rawaccess
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/mtr/mtr.p5m	Tue Mar 31 13:48:00 2015 -0700
@@ -0,0 +1,45 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+#
+
+<transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
+set name=pkg.fmri \
+    value=pkg:/network/[email protected]$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary value="graphical ping/traceroute tool"
+set name=pkg.description \
+    value="MTR combines the functionality of the 'traceroute' and 'ping' programs in a single network diagnostic tool."
+set name=com.oracle.info.description value="the MTR network diagnostic tool"
+set name=com.oracle.info.tpno value=$(TPNO)
+set name=info.classification \
+    value="org.opensolaris.category.2008:Applications/System Utilities"
+set name=info.source-url value=$(COMPONENT_ARCHIVE_URL)
+set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
+set name=org.opensolaris.arc-caseid value=PSARC/2008/161
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+#
+file exec_attr.txt path=etc/security/exec_attr.d/network:mtr
+file path=usr/bin/mtr mode=4555
+file usr/share/man/man8/mtr.8 path=usr/share/man/man1m/mtr.1m
+#
+license COPYING license=GPLv2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/mtr/patches/FINBIO.patch	Tue Mar 31 13:48:00 2015 -0700
@@ -0,0 +1,33 @@
+This fixes an upstream bug:
+
+    https://github.com/traviscross/mtr/issues/35
+
+The patch is from
+
+    https://bugs.launchpad.net/mtr/+bug/1273486/comments/5
+
+--- mtr-0.86/net.c	2014-12-09 03:20:57.000000000 -0800
++++ mtr-0.86/net.c	2015-03-20 09:43:55.576572132 -0700
[email protected]@ -301,7 +301,7 @@ void net_send_tcp(int index)
+ void net_send_tcp(int index)
+ {
+   int ttl, s;
+-  int opt = 1;
++  int flags;
+   int port;
+   struct sockaddr_storage local;
+   struct sockaddr_storage remote;
[email protected]@ -354,10 +354,10 @@ void net_send_tcp(int index)
+     exit(EXIT_FAILURE);
+   }
+ 
+-  opt = 1;
+-  if (ioctl(s, FIONBIO, &opt)) {
++  flags = fcntl(s, F_GETFL, 0);
++  if (fcntl(s, F_SETFL, flags | O_NONBLOCK) == -1) {
+     display_clear();
+-    perror("ioctl FIONBIO");
++    perror("fcntl F_SETFL(O_NONBLOCK)");
+     exit(EXIT_FAILURE);
+   }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/mtr/patches/ncurses.patch	Tue Mar 31 13:48:00 2015 -0700
@@ -0,0 +1,80 @@
+This has been filed upstream at:
+
+    https://github.com/traviscross/mtr/issues/76
+
+and fixed in
+
+    https://github.com/traviscross/mtr/commit/effef18b359c78a968de28cb1090866e974bd34f
+    https://github.com/traviscross/mtr/commit/0b782f6a31d999694554b670009698499e2c98cc
+
+These changes should be available in mtr 0.87.
+
+--- mtr-0.86/configure.ac	Tue Dec  9 03:20:57 2014
++++ mtr-0.86/configure.ac	Tue Mar 24 15:03:00 2015
[email protected]@ -20,20 +20,11 @@
+ AC_CHECK_HEADERS(ncurses.h ncurses/curses.h curses.h cursesX.h sys/types.h fcntl.h)
+ AC_CHECK_HEADERS(socket.h sys/socket.h sys/xti.h arpa/nameser_compat.h)
+ 
+-# We don't refer to any symbols in termcap, but -lcurses on SunOS does.
+-# We have to trust the linker not to mess things up... (It should not
+-# pull in anything if we don't refer to anything in the lib). 
+-AC_CHECK_LIB(termcap, tgetent)
+-AC_CHECK_LIB(tinfo, tgetent)
++AC_SEARCH_LIBS(initscr, [ncurses curses cursesX], ,
++  AC_MSG_WARN(Building without curses display support)
++  AC_DEFINE(NO_CURSES, 1, [Define if you don't have the curses libraries available.])
++  CURSES_OBJ=)
+ 
+-AC_CHECK_FUNC(initscr, , 
+-  AC_CHECK_LIB(ncurses, initscr, , 
+-    AC_CHECK_LIB(curses, initscr, , 
+-      AC_CHECK_LIB(cursesX, initscr, , 
+-	AC_MSG_WARN(Building without curses display support)
+-	AC_DEFINE(NO_CURSES, 1, Define if you don't have the curses libraries available.)
+-	CURSES_OBJ=))))
+-
+ AC_CHECK_FUNCS(attron fcntl)
+ 
+ AC_CHECK_LIB(m, floor, , AC_MSG_ERROR(No math library found))
+--- mtr-0.86/mtr.c	Tue Dec  9 03:20:57 2014
++++ mtr-0.86/mtr.c	Fri Mar 20 09:43:55 2015
[email protected]@ -89,7 +89,7 @@
+ int   maxTTL = 30;              /* inline with traceroute */
+                                 /* end ttl window stuff. */
+ int remoteport = 80;            /* for TCP tracing */
+-int timeout = 10 * 1000000;     /* for TCP tracing */
++int tcp_timeout = 10 * 1000000; /* for TCP tracing */
+ 
+ 
+ /* default display field(defined by key in net.h) and order */
[email protected]@ -454,8 +454,8 @@
+       }
+       break;
+     case 'Z':
+-      timeout = atoi(optarg);
+-      timeout *= 1000000;
++      tcp_timeout = atoi(optarg);
++      tcp_timeout *= 1000000;
+       break;
+     case '4':
+       af = AF_INET;
+--- mtr-0.86/net.c	Fri Mar 20 09:43:55 2015
++++ mtr-0.86/net.c	Fri Mar 20 09:43:55 2015
[email protected]@ -209,7 +209,7 @@
+ extern int af;			/* address family of remote target */
+ extern int mtrtype;		/* type of query packet used */
+ extern int remoteport;          /* target port for TCP tracing */
+-extern int timeout;             /* timeout for TCP connections */
++extern int tcp_timeout;		/* timeout for TCP connections */
+ #ifdef SO_MARK
+ extern int mark;		/* SO_MARK to set for ping packet*/
+ #endif
[email protected]@ -1559,7 +1559,7 @@
+     }
+     if (fd > 0) {
+       utime = sequence[at].time.tv_sec * 1000000L + sequence[at].time.tv_usec;
+-      if (unow - utime > timeout) {
++      if (unow - utime > tcp_timeout) {
+         close(fd);
+         sequence[at].socket = 0;
+       }