]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.73 v0.73
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Mon, 7 Apr 2008 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:38 +0000 (20:45 +0000)
 - Some securty patches. Although MTR drops privileges as soon as
   possible after opening the sockets, it still had some sprintf
   calls, which have now been converted into snprintf.

source: ftp://ftp.bitwizard.nl/mtr/mtr-0.73.tar.gz

13 files changed:
NEWS
TODO
configure.in
curses.c
display.h
dns.c
gtk.c
hello.c [new file with mode: 0644]
mtr.8
mtr.c
mtr.h
net.c
split.c

diff --git a/NEWS b/NEWS
index 4b2967b434e45610ca417deed6a96f0bb396db43..faeeb60ed8a9f0c95cb92e822419888b7b0583f5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,8 @@
 WHAT'S NEW?
+  v0.72 Fix signed/unsigned bug in IPV6 part
+        improved random packet size behaviour. --REW
+  v0.71 Some IPV6 fixes, introduce packet size cmdline option. 
+        (was already present as a cmdline argument) 
   v0.70 Antinio submitted a cumulative patch containing some
         nice improvements. He also submitted an automake patch
         that causes mtr to no longer compile on my system. I 
diff --git a/TODO b/TODO
index 381e6f9f5e21ec08d544f91d3933a85c5672fc63..ffc0ca349058d0548dca85845ce40d9ede5168c0 100644 (file)
--- a/TODO
+++ b/TODO
@@ -61,8 +61,7 @@ Oh, Feel free to provide suggestions for this list.
   - Show state ("looking up host") while doing the DNS lookup for a new
     host.
 
-  - Read environment variable "MTR_DEFAULTS" as a commandline before
-    parsing the commandline.  -- DONE. (ok it's MTR_OPTIONS.)
+  - to have a choice of icmp, tcp, and udp pings. -- Matt Martini
 
   - Autoconf 2.13 has a neat function that can be used to find the 
     res_init function: 
@@ -86,6 +85,12 @@ Oh, Feel free to provide suggestions for this list.
     hops from the host I'm monitoring, MTR wastes a lot of screen real
     estate. -- Jacob Elder
 
+  - Colors in the curses version. -- Amix
+
+  - If we run a mtr to monitor a connection it would be nice if the time at
+    which mtr was started is print somewhere. -- Sebastian Ganschow
+
+
 
 ------------------------------------------------------------------------
 
@@ -109,3 +114,7 @@ Things that shouldn't be on the TODO list because they're done. ;-)
     slowly (relative to the RTT time to the end host), it can probe
     all hosts in the first "round". 
        -- DONE.
+
+  - Read environment variable "MTR_DEFAULTS" as a commandline before
+    parsing the commandline.  -- DONE. (ok it's MTR_OPTIONS.)
+
index 9e3bd52034b37ab0c0184c3381960930e26fef9e..2f89aa740bb4af761f18720d4f3baab028242154 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.72)
+AM_INIT_AUTOMAKE(mtr, 0.73)
 
 
 AC_SUBST(GTK_OBJ)
@@ -89,7 +89,11 @@ AC_CHECK_FUNC(res_mkquery, ,
   AC_CHECK_LIB(bind, res_mkquery, , 
    AC_CHECK_LIB(resolv, res_mkquery, ,
      AC_CHECK_LIB(resolv, __res_mkquery, , AC_MSG_ERROR(No resolver library found)))))
-LIBS="$LIBS -lresolv"
+# This next line would override the just detected-or-not -lresolv. 
+# This apparently hurts BSD. And it's bad practise. So it should go. 
+# However, it probably didn't get added for nothing..... Holler if
+# removing it hurts your OS.... -- REW
+#LIBS="$LIBS -lresolv"
 
 AC_CHECK_FUNC(herror, , AC_DEFINE(NO_HERROR))
 AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR))
@@ -99,6 +103,19 @@ AC_CHECK_FUNC(getaddrinfo,
        AC_DEFINE([ENABLE_IPV6], [], [Define to enable IPv6])
 fi])
 
+AC_CHECK_DECLS(errno, , , [[
+#include <errno.h>
+#include <sys/errno.h>
+]] )
+
+AC_CHECK_TYPE(socklen_t, AC_DEFINE([HAVE_SOCKLEN_T], [], [Define if your system has socklen_t]) , , [[
+#include <netinet/in.h>
+]])
+
+AC_CHECK_TYPE(struct in_addr, AC_DEFINE([HAVE_STRUCT_INADDR], [], [Define if you have struct in_addr]), , [[
+#include <netinet/in.h>
+]])
+
 dnl Add C flags to display more warnings
 AC_MSG_CHECKING(for C flags to get more warnings)
 ac_save_CFLAGS="$CFLAGS"
index 03157a2962c6948fcce5e6f21a3cf803967915b0..23c3b4ed9e581455860e5618247c5fb5ed87f2f3 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -19,6 +19,7 @@
 
 #include <config.h>
 #include <strings.h>
+#include <unistd.h>
 
 #ifndef NO_CURSES
 #include <ctype.h>
@@ -93,6 +94,7 @@ int mtr_curses_keyaction(void)
 {
   int c = getch();
   int i=0;
+  float f = 0.0;
   char buf[MAXFLD+1];
 
   if(c == 'q')
@@ -169,10 +171,13 @@ int mtr_curses_keyaction(void)
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
-    i = atoi( buf );
 
-    if ( i < 1 ) return ActionNone;
-    WaitTime = (float) i;
+    f = atof( buf );
+
+    if (f <= 0.0) return ActionNone;
+    if (getuid() != 0 && f < 1.0)
+      return ActionNone;
+    WaitTime = f;
 
     return ActionNone;
   }
index d75c27b6601787c28abb63f6cd069587c7e777b7..2c9617141f3fe84d645cb4e54c8c4ab973cbfb5c 100644 (file)
--- a/display.h
+++ b/display.h
 
 #include <netinet/in.h>
 
+/* Don't put a trailing comma in enumeration lists. Some compilers 
+   (notably the one on Irix 5.2) do not like that. -- REW */ 
 enum { ActionNone,  ActionQuit,  ActionReset,  ActionDisplay, 
        ActionClear, ActionPause, ActionResume, ActionDNS, 
-       ActionScrollDown, ActionScrollUp,  };
+       ActionScrollDown, ActionScrollUp  };
 enum { DisplayReport, DisplayCurses, DisplayGTK, DisplaySplit, 
        DisplayRaw,    DisplayXML,    DisplayCSV, DisplayTXT};
 
diff --git a/dns.c b/dns.c
index ef3e518a34ad4ac8430022c8eac852f63f2b5f86..9c48b45c1eb7b6cbda416e4f307c076c9f4b34e2 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -32,6 +32,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#define BIND_8_COMPAT
 #include <arpa/nameser.h>
 #include <netdb.h>
 #include <resolv.h>
@@ -54,8 +55,10 @@ extern char *sys_errlist[];
 #define strerror(errno) (((errno) >= 0 && (errno) < sys_nerr) ? sys_errlist[errno] : "unlisted error")
 #endif
 
+#if !HAVE_DECL_ERRNO
 /*  Hmm, it seems Irix requires this  */
 extern int errno;
+#endif
 
 extern int af;
 
@@ -160,12 +163,15 @@ char *rrtypes[] = {
    "Resource reference",
 };
 
+
+/* Please don't use a trailing comma in enumerations: It doesn't
+   work on all compilers -- REW */
 enum {
    RR_UNKNOWN,
    RR_QUERY,
    RR_ANSWER,
    RR_AUTHORITY,
-   RR_RESOURCE,
+   RR_RESOURCE
 };
 
 typedef struct {
@@ -230,7 +236,7 @@ enum {
    STATE_FAILED,
    STATE_PTRREQ1,
    STATE_PTRREQ2,
-   STATE_PTRREQ3,
+   STATE_PTRREQ3
 };
 
 #define Is_PTR(x) ((x->state == STATE_PTRREQ1) || (x->state == STATE_PTRREQ2) || (x->state == STATE_PTRREQ3))
diff --git a/gtk.c b/gtk.c
index 63e43e583e447bcd305cbac15529fef4baafbf8e..356a271f7fe69b1ca4c2b8763c79c38beb81cf73 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -306,8 +306,8 @@ void gtk_set_field(GtkCList *List, int row, int ix, char *str) {
 }
 
 
-//void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, int num) {
-// changed int to dobule byMin
+/*   void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, int num) {
+             changed int to dobule byMin */
 void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, double num) 
 {
   char str[32];
@@ -363,12 +363,12 @@ void gtk_update_row(GtkCList *List, int row)
 
 void gtk_redraw(void)
 {
-  int at  = net_min(); // changed from 0 to net_min for TTL stuff byMin
+  int at  = net_min(); /* changed from 0 to net_min for TTL stuff byMin */
   int max = net_max();
 
   gtk_clist_freeze(GTK_CLIST(ReportBody));
 
-  while(GTK_CLIST(ReportBody)->rows < max -at) {       // byMin
+  while(GTK_CLIST(ReportBody)->rows < max -at) {       /* byMin */
     gtk_clist_append(GTK_CLIST(ReportBody), Report_Text);
   }
 
@@ -376,7 +376,7 @@ void gtk_redraw(void)
     gtk_clist_remove(GTK_CLIST(ReportBody), GTK_CLIST(ReportBody)->rows - 1);
   }
 
-  // for(at=0; at < max; at++) {       // replaced byMin
+  /* for(at=0; at < max; at++) {        replaced byMin */
   for(; at < max; at++) {
     gtk_update_row(GTK_CLIST(ReportBody), at);
   }
diff --git a/hello.c b/hello.c
new file mode 100644 (file)
index 0000000..5336875
--- /dev/null
+++ b/hello.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+typedef int socklen_t; 
+
+socklen_t main (int argc, char **argv)
+{
+  printf ("hello world. \n"); 
+  return 2;
+}
diff --git a/mtr.8 b/mtr.8
index d7b297d3c0b59bb62940795ca3a1346a64805db3..c1c0918aee45e7b8dc46f38393ff27584f7911a1 100644 (file)
--- a/mtr.8
+++ b/mtr.8
@@ -155,6 +155,16 @@ Use this option to force
 to display numeric IP numbers and not try to resolve the
 host names. 
 
+.TP
+.B \-o\ fields\ order
+.TP
+.B \-\-order\ fields\ order
+.br
+Use this option to specify the fields and their order when loading mtr.
+.br
+Example:
+-o "LSD NBAW"
+
 .TP
 .B \-g
 .TP
diff --git a/mtr.c b/mtr.c
index 40ae11bf6f3d5aa93054167cc4e5cbf39e51b304..eb2abcacd8f3f5a4c0413d070ce6123a01507e34 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -68,7 +68,7 @@ int af = DEFAULT_AF;
 
                                 /* begin ttl windows addByMin */
 int  fstTTL = 1;                /* default start at first hop */
-//int maxTTL = MaxHost-1;       /* max you can go is 255 hops */
+/*int maxTTL = MaxHost-1;  */     /* max you can go is 255 hops */
 int   maxTTL = 30;              /* inline with traceroute */
                                 /* end ttl window stuff. */
 
@@ -330,13 +330,13 @@ int main(int argc, char **argv)
   }
 
   /*  Now drop to user permissions  */
-  if (setuid(getuid())) {
+  if (setgid(getgid()) || setuid(getuid())) {
     fprintf (stderr, "mtr: Unable to drop permissions.\n");
     exit(1);
   }
 
   /*  Double check, just in case  */
-  if (geteuid() != getuid()) {
+  if ((geteuid() != getuid()) || (getegid() != getgid())) {
     fprintf (stderr, "mtr: Unable to drop permissions.\n");
     exit(1);
   }
diff --git a/mtr.h b/mtr.h
index 5fecd2f323d63369a23c71d1d9f3b9947907a718..31ebc76a01aee804e96eaf3cabc56466fa50cb43 100644 (file)
--- a/mtr.h
+++ b/mtr.h
@@ -39,3 +39,6 @@ extern int use_dns;
 #define UNUSED
 #endif
 
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t; 
+#endif
diff --git a/net.c b/net.c
index 327f35d58b564391e4887ce94a8b94d428b0d002..8f32aeaef02d38a250bc074b079b49c07b74d751 100644 (file)
--- a/net.c
+++ b/net.c
@@ -96,7 +96,7 @@ struct nethost {
   int avg;     /* average:  addByMin */
   int gmean;   /* geometirc mean: addByMin */
   int jitter;  /* current jitter, defined as t1-t0 addByMin */
-//int jbest;   /* min jitter, of cause it is 0, not needed */
+/*int jbest;*/ /* min jitter, of cause it is 0, not needed */
   int javg;    /* avg jitter */
   int jworst;  /* max jitter */
   int jinta;   /* estimated variance,? rfc1889's "Interarrival Jitter" */
@@ -359,7 +359,7 @@ void net_process_ping(int seq, void * addr, struct timeval now)
 
   if ( addrcmp( (void *) &(host[index].addr),
                (void *) &unspec_addr, af ) == 0 ) {
-    // should be out of if as addr can change
+    /* should be out of if as addr can change */
     addrcpy( (void *) &(host[index].addr), addrcopy, af );
     display_rawhost(index, (void *) &(host[index].addr));
 
@@ -627,8 +627,8 @@ int net_max(void)
   int max;
 
   max = 0;
-  // replacedByMin
-  // for(at = 0; at < MaxHost-2; at++) {
+  /* replacedByMin
+     for(at = 0; at < MaxHost-2; at++) { */
   for(at = 0; at < maxTTL-1; at++) {
     if ( addrcmp( (void *) &(host[at].addr),
                   (void *) remoteaddress, af ) == 0 ) {
@@ -736,12 +736,12 @@ int net_send_batch(void)
       n_unknown = MaxHost; /* Make sure we drop into "we should restart" */
   }
 
-  if ( // success in reaching target
+  if ( /* success in reaching target */
      ( addrcmp( (void *) &(host[batch_at].addr),
                 (void *) remoteaddress, af ) == 0 ) ||
-      // fail in consecuitive MAX_UNKNOWN_HOSTS (firewall?)
+      /* fail in consecuitive MAX_UNKNOWN_HOSTS (firewall?) */
       (n_unknown > MAX_UNKNOWN_HOSTS) ||
-      // or reach limit 
+      /* or reach limit  */
       (batch_at >= maxTTL-1)) {
     numhosts = batch_at+1;
     batch_at = fstTTL - 1;
diff --git a/split.c b/split.c
index e49bc6b58321930e82129143bea6b28bc503bceb..01ceaa9311c43fa64d5893ef44c7483ebe6ca073 100644 (file)
--- a/split.c
+++ b/split.c
@@ -103,13 +103,13 @@ void split_redraw(void)
       name = dns_lookup(addr);
       if(name != NULL) {
        /* May be we should test name's length */
-       sprintf(newLine, "%s %d %d %d %d %d %d", name,
+       snprintf(newLine, sizeof(newLine), "%s %d %d %d %d %d %d", name,
                net_loss(at),
                net_returned(at), net_xmit(at),
                net_best(at) /1000, net_avg(at)/1000, 
                net_worst(at)/1000);
       } else {
-       sprintf(newLine, "%s %d %d %d %d %d %d", 
+       snprintf(newLine, sizeof(newLine), "%s %d %d %d %d %d %d", 
                strlongip( addr ),
                net_loss(at),
                net_returned(at), net_xmit(at),