From: R.E. Wolff Date: Sun, 18 Jun 2017 10:45:16 +0000 (+0200) Subject: fix #204 : added exec of mtr-packet in the place where mtr was started from. Quick... X-Git-Tag: v0.93~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=860a39cdf5a8ffe4afddc057dbe7b3ec7aaacb7b;p=thirdparty%2Fmtr.git fix #204 : added exec of mtr-packet in the place where mtr was started from. Quick and dirty, There is probably a better place to declare variables. --- diff --git a/ui/cmdpipe.c b/ui/cmdpipe.c index c7120e2..a90fa4f 100644 --- a/ui/cmdpipe.c +++ b/ui/cmdpipe.c @@ -204,6 +204,7 @@ int check_packet_features( } +extern char *myname; /* Execute mtr-packet, allowing the MTR_PACKET evironment to override the PATH when locating the executable. @@ -212,6 +213,7 @@ static void execute_packet_child( void) { + char buf[256]; /* Allow the MTR_PACKET environment variable to override the path to the mtr-packet executable. This is necessary @@ -228,6 +230,14 @@ void execute_packet_child( */ execlp(mtr_packet_path, "mtr-packet", (char *) NULL); + /* + Then try to find it where WE were executed from. + */ + strncpy (buf, myname, 240); + strcat (buf, "-packet"); + mtr_packet_path = buf; + execl(mtr_packet_path, "mtr-packet", (char *) NULL); + /* If mtr-packet is not found, try to use mtr-packet from current directory */ diff --git a/ui/mtr.c b/ui/mtr.c index 70ae5c4..1f4afd6 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -70,6 +70,8 @@ #endif +char *myname; + const struct fields data_fields[MAXFLD] = { /* key, Remark, Header, Format, Width, CallBackFunc */ {' ', ": Space between fields", " ", " ", 1, &net_drop}, @@ -697,6 +699,7 @@ int main( names_t *names_head = NULL; names_t *names_walk; + myname = argv[0]; struct mtr_ctl ctl; memset(&ctl, 0, sizeof(ctl)); /* initialize non-null values */