From MAILER-DAEMON Tue May 08 13:33:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SRoHc-0007rn-HC
	for mharc-commit-inetutils@gnu.org; Tue, 08 May 2012 13:33:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53448)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SRoHS-0007rL-Q7
	for commit-inetutils@gnu.org; Tue, 08 May 2012 13:33:06 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SRoHK-00020p-SK
	for commit-inetutils@gnu.org; Tue, 08 May 2012 13:32:58 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44310)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SRoHK-00020f-NX
	for commit-inetutils@gnu.org; Tue, 08 May 2012 13:32:50 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SRoHJ-0007BR-A0
	for commit-inetutils@gnu.org; Tue, 08 May 2012 17:32:50 +0000
Date: Tue, 08 May 2012 17:32:49 +0000
Message-Id: <E1SRoHJ-0007BR-A0@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-86-g24f0cb0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 153434103dc0b365bd1d187a2c72d2e4a62a27a8
X-Git-Newrev: 24f0cb0538cef541153a999aee72867794abba14
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 May 2012 17:33:06 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  24f0cb0538cef541153a999aee72867794abba14 (commit)
       via  b1410c18b8f692c1d1aeff0b305c6ebc466c5ccc (commit)
       via  cd091aa41b1de362e074a58a638636454c6a0f34 (commit)
       via  1dc2e02ed08308ab0eb48460dcfc98fdfcc64d4e (commit)
      from  153434103dc0b365bd1d187a2c72d2e4a62a27a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=24f0cb0538cef541153a999aee72867794abba14


commit 24f0cb0538cef541153a999aee72867794abba14
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue May 8 18:56:38 2012 +0200

    ping, ping6: Critical sizing errors.

diff --git a/ChangeLog b/ChangeLog
index bc672df..739dfb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Critical package errors in size and allocation.
+
+	* ping/ping.c (send_echo): Replace macro PING_HEADER_LEN by
+	calculated value OFF, i.e., the number of consumed bytes.
+	* ping/ping6.c (send_echo): Likewise.
+	(ping_init): Initialise `p->ping_datalen' as the size of
+	`struct timeval', a possible payload.
+	* ping/ping_common.h (PING_HEADER_LEN): Use correct size as
+	`sizeof(struct icmp6_hdr)' and ICMP_MINLEN, respectively.
+	(PING_TIMING): Compare with `sizeof(struct timeval)'.
+	(_PING_BUFLEN) <IPv4 case>: Add contribution MAXIPLEN, and
+	increase ICMP contribution to ICMP_TSLEN, the maximal length.
+	* ping/ping_echo.c (ping_echo) [options & OPT_RROUTE && IP_OPTIONS]:
+	Remove call (a recent regression) to ping_set_packetsize().
+
+2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	Incomplete endianness conversions.
 
 	* libicmp/icmp_echo.c (icmp_generic_encode): Apply htons() to
diff --git a/ping/ping.c b/ping/ping.c
index a9b2ad6..b82f557 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -443,8 +443,8 @@ send_echo (PING * ping)
     }
   if (data_buffer)
     ping_set_data (ping, data_buffer, off,
-		   data_length > PING_HEADER_LEN ?
-		   data_length - PING_HEADER_LEN : data_length, USE_IPV6);
+		   data_length > off ? data_length - off : data_length,
+		   USE_IPV6);
   return ping_xmit (ping);
 }
 
diff --git a/ping/ping6.c b/ping/ping6.c
index 54aaac9..4f7d041 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -400,8 +400,8 @@ send_echo (PING * ping)
     }
   if (data_buffer)
     ping_set_data (ping, data_buffer, off,
-		   data_length > PING_HEADER_LEN ?
-		   data_length - PING_HEADER_LEN : data_length, USE_IPV6);
+		   data_length > off ? data_length - off : data_length,
+		   USE_IPV6);
   return ping_xmit (ping);
 }
 
@@ -761,7 +761,7 @@ ping_init (int type, int ident)
   p->ping_fd = fd;
   p->ping_count = DEFAULT_PING_COUNT;
   p->ping_interval = PING_DEFAULT_INTERVAL;
-  p->ping_datalen = sizeof (struct icmp6_hdr);
+  p->ping_datalen = sizeof (struct timeval);
   /* Make sure we use only 16 bits in this field, id for icmp is a unsigned short.  */
   p->ping_ident = ident & 0xFFFF;
   p->ping_cktab_size = PING_CKTABSIZE;
diff --git a/ping/ping_common.h b/ping/ping_common.h
index 6bb7d15..2c8c796 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -54,8 +54,8 @@ struct ping_stat
    want to follow the traditional behaviour of ping.  */
 #define DEFAULT_PING_COUNT 0
 
-#define PING_TIMING(s) (s >= PING_HEADER_LEN)
-#define PING_HEADER_LEN sizeof (struct timeval)
+#define PING_HEADER_LEN (USE_IPV6 ? sizeof (struct icmp6_hdr) : ICMP_MINLEN)
+#define PING_TIMING(s)  ((s) >= sizeof (struct timeval))
 #define PING_DATALEN    (64 - PING_HEADER_LEN)  /* default data length */
 
 #define PING_DEFAULT_INTERVAL 1000      /* Milliseconds */
@@ -66,9 +66,9 @@ struct ping_stat
   (t).tv_usec = ((i)%PING_PRECISION)*(1000000/PING_PRECISION) ;\
 } while (0)
 
-/* Not sure about this step*/
+/* FIXME: Adjust IPv6 case for options and their consumption.  */
 #define _PING_BUFLEN(p, USE_IPV6) ((USE_IPV6)? ((p)->ping_datalen + sizeof (struct icmp6_hdr)) : \
-				   ((p)->ping_datalen + sizeof (icmphdr_t)))
+				   (MAXIPLEN + (p)->ping_datalen + ICMP_TSLEN))
 
 typedef int (*ping_efp6) (int code, void *closure, struct sockaddr_in6 * dest,
 			  struct sockaddr_in6 * from, struct icmp6_hdr * icmp,
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index b218e35..870d685 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -95,8 +95,6 @@ ping_echo (char *hostname)
       if (setsockopt (ping->ping_fd, IPPROTO_IP,
 		      IP_OPTIONS, rspace, sizeof (rspace)) < 0)
         error (EXIT_FAILURE, errno, "setsockopt");
-      /* The encapsulating IP header is now augmented with options.  */
-      ping_set_packetsize (ping, data_length + sizeof (rspace));
 #else
       error (EXIT_FAILURE, 0, "record route not available in this "
              "implementation.");

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=b1410c18b8f692c1d1aeff0b305c6ebc466c5ccc


commit b1410c18b8f692c1d1aeff0b305c6ebc466c5ccc
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue May 8 18:54:08 2012 +0200

    libicmp, ping, ping6: Endianness conversions.

diff --git a/ChangeLog b/ChangeLog
index 5851215..bc672df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Incomplete endianness conversions.
+
+	* libicmp/icmp_echo.c (icmp_generic_encode): Apply htons() to
+	SEQNO and IDENT.
+	* ping/libping.c (my_echo_reply, ping_recv): Apply ntohs() to
+	`orig_icmp->icmp_id' and `orig->icmp_seq'.
+	* ping/ping6.c (print_echo): Likwise for `icmp6->icmp6_seq'.
+	* ping/ping_address.c (print_address): Apply ntohs() to
+	`icmp->icmp_seq'.
+	* ping/ping_echo.c (print_echo): Likewise.
+	(print_ip_header): Apply ntohs() to `ip->ip_len', `ip->ip_id',
+	`ip->ip_off', and to `ip->ip_sum'.
+	* ping/ping_timestamp.c (print_timestamp): Apply ntohs() to
+	`icmp->icmp_seq'.
+
+2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	Use symbolic size names in all harmless cases.
 
 	* libicmp/icmp.h (ICMP_TSLEN): Use size of `n_time'.
diff --git a/libicmp/icmp_echo.c b/libicmp/icmp_echo.c
index 30f8c5d..5eb3230 100644
--- a/libicmp/icmp_echo.c
+++ b/libicmp/icmp_echo.c
@@ -42,8 +42,8 @@ icmp_generic_encode (unsigned char * buffer, size_t bufsize, int type, int ident
   icmp->icmp_type = type;
   icmp->icmp_code = 0;
   icmp->icmp_cksum = 0;
-  icmp->icmp_seq = seqno;
-  icmp->icmp_id = ident;
+  icmp->icmp_seq = htons (seqno);
+  icmp->icmp_id = htons (ident);
 
   icmp->icmp_cksum = icmp_cksum (buffer, bufsize);
   return 0;
diff --git a/ping/libping.c b/ping/libping.c
index 80c85fa..b847958 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -169,7 +169,7 @@ my_echo_reply (PING * p, icmphdr_t * icmp)
   return (orig_ip->ip_dst.s_addr == p->ping_dest.ping_sockaddr.sin_addr.s_addr
 	  && orig_ip->ip_p == IPPROTO_ICMP
 	  && orig_icmp->icmp_type == ICMP_ECHO
-	  && orig_icmp->icmp_id == p->ping_ident);
+	  && ntohs (orig_icmp->icmp_id) == p->ping_ident);
 }
 
 int
@@ -203,7 +203,7 @@ ping_recv (PING * p)
     case ICMP_ADDRESSREPLY:
       /*    case ICMP_ROUTERADV: */
 
-      if (icmp->icmp_id != p->ping_ident)
+      if (ntohs (icmp->icmp_id) != p->ping_ident)
 	return -1;
 
       if (rc)
@@ -211,7 +211,7 @@ ping_recv (PING * p)
 		 inet_ntoa (p->ping_from.ping_sockaddr.sin_addr));
 
       p->ping_num_recv++;
-      if (_PING_TST (p, icmp->icmp_seq))
+      if (_PING_TST (p, ntohs (icmp->icmp_seq)))
 	{
 	  p->ping_num_rept++;
 	  p->ping_num_recv--;
@@ -219,7 +219,7 @@ ping_recv (PING * p)
 	}
       else
 	{
-	  _PING_SET (p, icmp->icmp_seq);
+	  _PING_SET (p, ntohs (icmp->icmp_seq));
 	  dupflag = 0;
 	}
 
diff --git a/ping/ping6.c b/ping/ping6.c
index 3fa2e28..54aaac9 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -548,7 +548,7 @@ print_echo (int dupflag, int hops, struct ping_stat *ping_stat,
     }
 
   printf ("%d bytes from %s: icmp_seq=%u", datalen, buf,
-	  htons (icmp6->icmp6_seq));
+	  ntohs (icmp6->icmp6_seq));
   if (hops >= 0)
     printf (" ttl=%d", hops);
   if (timing)
@@ -792,7 +792,8 @@ ping_xmit (PING * p)
   icmp6->icmp6_seq = htons (p->ping_num_xmit);
 
   i = sendto (p->ping_fd, (char *) p->ping_buffer, buflen, 0,
-	      (struct sockaddr *) &p->ping_dest.ping_sockaddr6, sizeof (p->ping_dest.ping_sockaddr6));
+	      (struct sockaddr *) &p->ping_dest.ping_sockaddr6,
+	      sizeof (p->ping_dest.ping_sockaddr6));
   if (i < 0)
     perror ("ping: sendto");
   else
diff --git a/ping/ping_address.c b/ping/ping_address.c
index e9914f2..fcc0c60 100644
--- a/ping/ping_address.c
+++ b/ping/ping_address.c
@@ -97,7 +97,7 @@ print_address (int dupflag, void *closure,
 
   printf ("%d bytes from %s: icmp_seq=%u", datalen,
 	  inet_ntoa (*(struct in_addr *) &from->sin_addr.s_addr),
-	  icmp->icmp_seq);
+	  ntohs (icmp->icmp_seq));
   if (dupflag)
     printf (" (DUP!)");
   printf ("\n");
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index 5671335..b218e35 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -181,7 +181,7 @@ print_echo (int dupflag, struct ping_stat *ping_stat,
 
   printf ("%d bytes from %s: icmp_seq=%u", datalen,
 	  inet_ntoa (*(struct in_addr *) &from->sin_addr.s_addr),
-	  icmp->icmp_seq);
+	  ntohs (icmp->icmp_seq));
   printf (" ttl=%d", ip->ip_ttl);
   if (timing)
     printf (" time=%.3f ms", triptime);
@@ -296,10 +296,10 @@ print_ip_header (struct ip *ip)
   printf
     ("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src\tDst\tData\n");
   printf (" %1x  %1x  %02x %04x %04x", ip->ip_v, ip->ip_hl, ip->ip_tos,
-	  ip->ip_len, ip->ip_id);
-  printf ("   %1x %04x", ((ip->ip_off) & 0xe000) >> 13,
-	  (ip->ip_off) & 0x1fff);
-  printf ("  %02x  %02x %04x", ip->ip_ttl, ip->ip_p, ip->ip_sum);
+	  ntohs (ip->ip_len), ntohs (ip->ip_id));
+  printf ("   %1x %04x", (ntohs (ip->ip_off) & 0xe000) >> 13,
+	  ntohs (ip->ip_off) & 0x1fff);
+  printf ("  %02x  %02x %04x", ip->ip_ttl, ip->ip_p, ntohs (ip->ip_sum));
   printf (" %s ", inet_ntoa (*((struct in_addr *) &ip->ip_src)));
   printf (" %s ", inet_ntoa (*((struct in_addr *) &ip->ip_dst)));
   while (hlen-- > sizeof (*ip))
diff --git a/ping/ping_timestamp.c b/ping/ping_timestamp.c
index 555d13a..2c50192 100644
--- a/ping/ping_timestamp.c
+++ b/ping/ping_timestamp.c
@@ -95,7 +95,7 @@ print_timestamp (int dupflag, void *closure,
 {
   printf ("%d bytes from %s: icmp_seq=%u", datalen,
 	  inet_ntoa (*(struct in_addr *) &from->sin_addr.s_addr),
-	  icmp->icmp_seq);
+	  ntohs (icmp->icmp_seq));
   if (dupflag)
     printf (" (DUP!)");
   printf ("\n");

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=cd091aa41b1de362e074a58a638636454c6a0f34


commit cd091aa41b1de362e074a58a638636454c6a0f34
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue May 8 18:51:35 2012 +0200

    libicmp, ping: Symbolic sizes. Better diagnostics.

diff --git a/ChangeLog b/ChangeLog
index 32c7712..5851215 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Use symbolic size names in all harmless cases.
+
+	* libicmp/icmp.h (ICMP_TSLEN): Use size of `n_time'.
+	* libicmp/icmp_address.c (icmp_address_encode): Use ICMP_MASKLEN.
+	* libicmp/icmp_echo.c (icmp_generic_encode): Use ICMP_MINLEN.
+	* libicmp/icmp_timestamp.c (icmp_timestamp_encode): Use ICMP_TSLEN.
+	* ping/libping.c (_ping_packetsize): Use ICMP_TSLEN.  Add cases
+	for ICMP_ADDRESS and ICMP_ADDRESSREPLY.  Use PING_HEADER_LEN in
+	default case.
+	(ping_set_dest) [HAVE_STRUCT_SOCKADDR_SA_LEN]: Set `s_in->sin_len'.
+	* ping/ping_address.c (ping_address): Use ICMP_MASKLEN.
+	* ping/ping_common.h (_ping_setbuf, ping_set_data): Use `use_ipv6'
+	as parameter, not the macro name USE_IPV6.
+	* ping/ping_echo.c (print_echo): Use PING_HEADER_LEN.
+	(print_ip_header): Use `sizeof(*ip)' for IP header size.
+	Use tabs at end of printed header.
+	(print_ip_data): Use IPPROTO_TCP and IPPROTO_UDP.  Add case
+	for IPPROTO_ICMP.
+	* ping/ping_timestamp.c (ping_timestamp): Use ICMP_TSLEN.
+
+	Determine correct and relevant diagnostic messages.
+
+	* ping/ping_echo.c (struct icmp_code_descr): Add field `int type'.
+	(icmp_code_descr): Prepend every member with a type value for
+	correct discrimination.
+	(print_icmp_code): New signature `(int, int, char *)'.  Test `type'
+	as well as `code' when matching.
+	(print_icmp): Update call to print_icmp_code().
+	(icmp_diag): New members ICMP_ROUTERADV and ICMP_ROUTERDISCOVERY.
+	New members ICMP_INFO_REPLY and ICMP_ADDRESS.  Replace incorrect
+	ICMP_MASKREPLY with ICMP_ADDRESSREPLY.
+	(print_ip_opt) <IPOPT_SSRR>: New case.  Code shared with IPOPT_LSRR.
+	<IPOPT_LSRR, IPOPT_RR>: Replace call to ntohl() by correct htonl().
+
 2012-05-07  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Portability issue for setting timeval manually.
diff --git a/libicmp/icmp.h b/libicmp/icmp.h
index 83a1e70..67ce1f0 100644
--- a/libicmp/icmp.h
+++ b/libicmp/icmp.h
@@ -67,7 +67,7 @@ struct icmp_header
 
   union
   {
-    struct id_ts		/* ICMP_TIMESTAMP, ICMP_TIMESTAMP_REPLY */
+    struct id_ts		/* ICMP_TIMESTAMP, ICMP_TIMESTAMPREPLY */
     {
       n_time its_otime;		/* Originate timestamp */
       n_time its_rtime;		/* Recieve timestamp */
@@ -140,7 +140,7 @@ struct icmp_header
 #define MAXIPLEN	60
 #define MAXICMPLEN	76
 #define ICMP_MINLEN	8	/* abs minimum */
-#define ICMP_TSLEN	(8 + 3 * sizeof (unsigned long))	/* timestamp */
+#define ICMP_TSLEN	(8 + 3 * sizeof (n_time))	/* timestamp */
 #define ICMP_MASKLEN	12	/* address mask */
 #define ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
 #define ICMP_ADVLEN(p)	(8 + ((p)->icmp_ip.ip_hl << 2) + 8)
diff --git a/libicmp/icmp_address.c b/libicmp/icmp_address.c
index b02ad15..ef19490 100644
--- a/libicmp/icmp_address.c
+++ b/libicmp/icmp_address.c
@@ -35,7 +35,7 @@ icmp_address_encode (unsigned char * buffer, size_t bufsize, int ident, int seqn
 {
   icmphdr_t *icmp;
 
-  if (bufsize < 12)
+  if (bufsize < ICMP_MASKLEN)
     return -1;
 
   icmp = (icmphdr_t *) buffer;
diff --git a/libicmp/icmp_echo.c b/libicmp/icmp_echo.c
index 3a0f108..30f8c5d 100644
--- a/libicmp/icmp_echo.c
+++ b/libicmp/icmp_echo.c
@@ -36,7 +36,7 @@ icmp_generic_encode (unsigned char * buffer, size_t bufsize, int type, int ident
 {
   icmphdr_t *icmp;
 
-  if (bufsize < 8)
+  if (bufsize < ICMP_MINLEN)
     return -1;
   icmp = (icmphdr_t *) buffer;
   icmp->icmp_type = type;
diff --git a/libicmp/icmp_timestamp.c b/libicmp/icmp_timestamp.c
index 1857252..caa71fb 100644
--- a/libicmp/icmp_timestamp.c
+++ b/libicmp/icmp_timestamp.c
@@ -39,7 +39,7 @@ icmp_timestamp_encode (unsigned char * buffer, size_t bufsize, int ident, int se
   struct timeval tv;
   unsigned long v;
 
-  if (bufsize < 20)
+  if (bufsize < ICMP_TSLEN)
     return -1;
 
   gettimeofday (&tv, NULL);
diff --git a/ping/libping.c b/ping/libping.c
index fcb9e22..80c85fa 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -42,8 +42,12 @@ size_t
 _ping_packetsize (PING * p)
 {
   if (p->ping_type == ICMP_TIMESTAMP || p->ping_type == ICMP_TIMESTAMPREPLY)
-    return 20;
-  return 8 + p->ping_datalen;
+    return ICMP_TSLEN;
+
+  if (p->ping_type == ICMP_ADDRESS || p->ping_type == ICMP_ADDRESSREPLY)
+    return ICMP_MASKLEN;
+
+  return PING_HEADER_LEN + p->ping_datalen;
 }
 
 PING *
@@ -262,6 +266,9 @@ ping_set_dest (PING * ping, char *host)
 {
   struct sockaddr_in *s_in = &ping->ping_dest.ping_sockaddr;
   s_in->sin_family = AF_INET;
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+  s_in->sin_len = sizeof (*s_in);
+#endif
   if (inet_aton (host, &s_in->sin_addr))
     ping->ping_hostname = strdup (host);
   else
diff --git a/ping/ping_address.c b/ping/ping_address.c
index fedc82f..e9914f2 100644
--- a/ping/ping_address.c
+++ b/ping/ping_address.c
@@ -57,7 +57,7 @@ ping_address (char *hostname)
 {
   ping_set_type (ping, ICMP_ADDRESS);
   ping_set_event_handler (ping, recv_address, NULL);
-  ping_set_packetsize (ping, 12);	/* FIXME: constant */
+  ping_set_packetsize (ping, ICMP_MASKLEN);
   ping_set_count (ping, 1);
 
   if (ping_set_dest (ping, hostname))
diff --git a/ping/ping_common.h b/ping/ping_common.h
index 136c2f1..6bb7d15 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -151,8 +151,8 @@ void init_data_buffer (unsigned char *pat, int len);
 
 void decode_pattern (const char *text, int *pattern_len,
 		     unsigned char *pattern_data);
-int _ping_setbuf (PING * p, bool USE_IPV6);
-int ping_set_data (PING *p, void *data, size_t off, size_t len, bool USE_IPV6);
+int _ping_setbuf (PING * p, bool use_ipv6);
+int ping_set_data (PING *p, void *data, size_t off, size_t len, bool use_ipv6);
 void ping_set_count (PING * ping, size_t count);
 void ping_set_sockopt (PING * ping, int opt, void *val, int valsize);
 void ping_set_interval (PING * ping, size_t interval);
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index f62582b..5671335 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -150,7 +150,7 @@ print_echo (int dupflag, struct ping_stat *ping_stat,
   datalen -= hlen;
 
   /* Do timing */
-  if (PING_TIMING (datalen - 8))
+  if (PING_TIMING (datalen - PING_HEADER_LEN))
     {
       struct timeval tv1, *tp;
 
@@ -235,46 +235,47 @@ struct icmp_diag
 
 struct icmp_code_descr
 {
+  int type;
   int code;
   char *diag;
 } icmp_code_descr[] =
   {
-    {ICMP_NET_UNREACH, "Destination Net Unreachable"},
-    {ICMP_HOST_UNREACH, "Destination Host Unreachable"},
-    {ICMP_PROT_UNREACH, "Destination Protocol Unreachable"},
-    {ICMP_PORT_UNREACH, "Destination Port Unreachable"},
-    {ICMP_FRAG_NEEDED, "Fragmentation needed and DF set"},
-    {ICMP_SR_FAILED, "Source Route Failed"},
-    {ICMP_NET_UNKNOWN, "Network Unknown"},
-    {ICMP_HOST_UNKNOWN, "Host Unknown"},
-    {ICMP_HOST_ISOLATED, "Host Isolated"},
-    {ICMP_NET_UNR_TOS, "Destination Network Unreachable At This TOS"},
-    {ICMP_HOST_UNR_TOS, "Destination Host Unreachable At This TOS"},
+    {ICMP_DEST_UNREACH, ICMP_NET_UNREACH, "Destination Net Unreachable"},
+    {ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, "Destination Host Unreachable"},
+    {ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, "Destination Protocol Unreachable"},
+    {ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, "Destination Port Unreachable"},
+    {ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, "Fragmentation needed and DF set"},
+    {ICMP_DEST_UNREACH, ICMP_SR_FAILED, "Source Route Failed"},
+    {ICMP_DEST_UNREACH, ICMP_NET_UNKNOWN, "Network Unknown"},
+    {ICMP_DEST_UNREACH, ICMP_HOST_UNKNOWN, "Host Unknown"},
+    {ICMP_DEST_UNREACH, ICMP_HOST_ISOLATED, "Host Isolated"},
+    {ICMP_DEST_UNREACH, ICMP_NET_UNR_TOS, "Destination Network Unreachable At This TOS"},
+    {ICMP_DEST_UNREACH, ICMP_HOST_UNR_TOS, "Destination Host Unreachable At This TOS"},
 #ifdef ICMP_PKT_FILTERED
-    {ICMP_PKT_FILTERED, "Packet Filtered"},
+    {ICMP_DEST_UNREACH, ICMP_PKT_FILTERED, "Packet Filtered"},
 #endif
 #ifdef ICMP_PREC_VIOLATION
-    {ICMP_PREC_VIOLATION, "Precedence Violation"},
+    {ICMP_DEST_UNREACH, ICMP_PREC_VIOLATION, "Precedence Violation"},
 #endif
 #ifdef ICMP_PREC_CUTOFF
-    {ICMP_PREC_CUTOFF, "Precedence Cutoff"},
+    {ICMP_DEST_UNREACH, ICMP_PREC_CUTOFF, "Precedence Cutoff"},
 #endif
-    {ICMP_REDIR_NET, "Redirect Network"},
-    {ICMP_REDIR_HOST, "Redirect Host"},
-    {ICMP_REDIR_NETTOS, "Redirect Type of Service and Network"},
-    {ICMP_REDIR_HOSTTOS, "Redirect Type of Service and Host"},
-    {ICMP_EXC_TTL, "Time to live exceeded"},
-    {ICMP_EXC_FRAGTIME, "Frag reassembly time exceeded"}
+    {ICMP_REDIRECT, ICMP_REDIR_NET, "Redirect Network"},
+    {ICMP_REDIRECT, ICMP_REDIR_HOST, "Redirect Host"},
+    {ICMP_REDIRECT, ICMP_REDIR_NETTOS, "Redirect Type of Service and Network"},
+    {ICMP_REDIRECT, ICMP_REDIR_HOSTTOS, "Redirect Type of Service and Host"},
+    {ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, "Time to live exceeded"},
+    {ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, "Frag reassembly time exceeded"}
   };
 
 static void
-print_icmp_code (int code, char *prefix)
+print_icmp_code (int type, int code, char *prefix)
 {
   struct icmp_code_descr *p;
 
   for (p = icmp_code_descr; p < icmp_code_descr + NITEMS (icmp_code_descr);
        p++)
-    if (p->code == code)
+    if (p->type == type && p->code == code)
       {
 	printf ("%s\n", p->diag);
 	return;
@@ -290,10 +291,10 @@ print_ip_header (struct ip *ip)
   unsigned char *cp;
 
   hlen = ip->ip_hl << 2;
-  cp = (unsigned char *) ip + 20;	/* point to options */
+  cp = (unsigned char *) ip + sizeof (*ip);	/* point to options */
 
   printf
-    ("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst Data\n");
+    ("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src\tDst\tData\n");
   printf (" %1x  %1x  %02x %04x %04x", ip->ip_v, ip->ip_hl, ip->ip_tos,
 	  ip->ip_len, ip->ip_id);
   printf ("   %1x %04x", ((ip->ip_off) & 0xe000) >> 13,
@@ -301,7 +302,7 @@ print_ip_header (struct ip *ip)
   printf ("  %02x  %02x %04x", ip->ip_ttl, ip->ip_p, ip->ip_sum);
   printf (" %s ", inet_ntoa (*((struct in_addr *) &ip->ip_src)));
   printf (" %s ", inet_ntoa (*((struct in_addr *) &ip->ip_dst)));
-  while (hlen-- > 20)
+  while (hlen-- > sizeof (*ip))
     printf ("%02x", *cp++);
 
   printf ("\n");
@@ -319,19 +320,30 @@ print_ip_data (icmphdr_t * icmp, void *data)
   hlen = ip->ip_hl << 2;
   cp = (unsigned char *) ip + hlen;
 
-  if (ip->ip_p == 6)
+  if (ip->ip_p == IPPROTO_TCP)
     printf ("TCP: from port %u, to port %u (decimal)\n",
 	    (*cp * 256 + *(cp + 1)), (*(cp + 2) * 256 + *(cp + 3)));
-  else if (ip->ip_p == 17)
+  else if (ip->ip_p == IPPROTO_UDP)
     printf ("UDP: from port %u, to port %u (decimal)\n",
 	    (*cp * 256 + *(cp + 1)), (*(cp + 2) * 256 + *(cp + 3)));
-
+  else if (ip->ip_p == IPPROTO_ICMP)
+    {
+      int type = *cp;
+      int code = *(cp + 1);
+
+      printf ("ICMP: type %u, code %u, size %u", type, code,
+	      ntohs (ip->ip_len) - hlen);
+      if (type == ICMP_ECHOREPLY || type == ICMP_ECHO)
+	printf (", id 0x%04x, seq 0x%04x", *(cp + 4) * 256 + *(cp + 5),
+		*(cp + 6) * 256 + *(cp + 7));
+      printf ("\n");
+    }
 }
 
 static void
 print_icmp (icmphdr_t * icmp, void *data)
 {
-  print_icmp_code (icmp->icmp_code, data);
+  print_icmp_code (icmp->icmp_type, icmp->icmp_code, data);
   print_ip_data (icmp, NULL);
 }
 
@@ -349,14 +361,16 @@ struct icmp_diag icmp_diag[] = {
   {ICMP_SOURCE_QUENCH, "Source Quench", print_ip_data},
   {ICMP_REDIRECT, NULL, print_icmp, "Redirect"},
   {ICMP_ECHO, "Echo Request", NULL},
+  {ICMP_ROUTERADV, "Router Advertisment", NULL},
+  {ICMP_ROUTERDISCOVERY, "Router Discovery", NULL},
   {ICMP_TIME_EXCEEDED, NULL, print_icmp, "Time exceeded"},
   {ICMP_PARAMETERPROB, NULL, print_parameterprob},
   {ICMP_TIMESTAMP, "Timestamp", NULL},
   {ICMP_TIMESTAMPREPLY, "Timestamp Reply", NULL},
   {ICMP_INFO_REQUEST, "Information Request", NULL},
-#ifdef ICMP_MASKREQ
-  {ICMP_MASKREPLY, "Address Mask Reply", NULL},
-#endif
+  {ICMP_INFO_REPLY, "Information Reply", NULL},
+  {ICMP_ADDRESS, "Address Mask Request", NULL},
+  {ICMP_ADDRESSREPLY, "Address Mask Reply", NULL},
 };
 
 void
@@ -412,13 +426,15 @@ print_ip_opt (struct ip *ip, int hlen)
 	break;
 
       case IPOPT_LSRR:
-	printf ("\nLSRR: ");
+      case IPOPT_SSRR:
+	printf ("\n%cSRR: ", (*cp == IPOPT_LSRR) ? 'L' : 'S');
 	hlen -= 2;
 	j = *++cp;
 	++cp;
 	if (j > IPOPT_MINOFF)
 	  for (;;)
 	    {
+	      /* Fetch in network byte order, calculate as host.  */
 	      l = *++cp;
 	      l = (l << 8) + *++cp;
 	      l = (l << 8) + *++cp;
@@ -432,7 +448,7 @@ print_ip_opt (struct ip *ip, int hlen)
 		  struct in_addr ina;
 		  char *s;
 
-		  ina.s_addr = ntohl (l);
+		  ina.s_addr = htonl (l);
 		  printf ("\t%s", s = ipaddr2str (ina));
 		  free (s);
 		}
@@ -475,6 +491,7 @@ print_ip_opt (struct ip *ip, int hlen)
 	j = 0;
 	for (;;)
 	  {
+	    /* Fetch in network byte order, calculate as host.  */
 	    l = *++cp;
 	    l = (l << 8) + *++cp;
 	    l = (l << 8) + *++cp;
@@ -488,7 +505,7 @@ print_ip_opt (struct ip *ip, int hlen)
 		struct in_addr ina;
 		char *s;
 
-		ina.s_addr = ntohl (l);
+		ina.s_addr = htonl (l);
 		printf ("\t%s", s = ipaddr2str (ina));
 		free (s);
 	      }
diff --git a/ping/ping_timestamp.c b/ping/ping_timestamp.c
index 7793840..555d13a 100644
--- a/ping/ping_timestamp.c
+++ b/ping/ping_timestamp.c
@@ -57,7 +57,7 @@ ping_timestamp (char *hostname)
 {
   ping_set_type (ping, ICMP_TIMESTAMP);
   ping_set_event_handler (ping, recv_timestamp, NULL);
-  ping_set_packetsize (ping, 20);
+  ping_set_packetsize (ping, ICMP_TSLEN);
 
   if (ping_set_dest (ping, hostname))
     error (EXIT_FAILURE, 0, "unknown host");

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=1dc2e02ed08308ab0eb48460dcfc98fdfcc64d4e


commit 1dc2e02ed08308ab0eb48460dcfc98fdfcc64d4e
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue May 8 18:48:29 2012 +0200

    ping, ping6, traceroute: Portability and regression.

diff --git a/ChangeLog b/ChangeLog
index c9c12dd..32c7712 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-05-07  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Portability issue for setting timeval manually.
+
+	* ping/ping.c (ping_run): Erase RESP_TIME, INTVL, and NOW
+	before first use.
+	* ping/ping6.c (ping_run): Likewise.  Do not erase RESP_TIME
+	inside loop.
+
+	Regression in calculating response timing.
+
+	* src/traceroute.c (do_try): Use format string ` %2d ' with HOP.
+	New variable SAVE_ERRNO.  Call select() before gettimeofday(),
+	but save `errno' in SAVE_ERRNO.  Take care of microsecond
+	underflow when calculating time difference.
+	(trace_read): Replace numerical size by `sizeof (data)'.
+
 2012-04-27  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	* ping/ping_address.c (print_address): Remove duplicate
diff --git a/ping/ping.c b/ping/ping.c
index 462cc22..a9b2ad6 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -330,6 +330,14 @@ ping_run (PING * ping, int (*finish) ())
 
   fdmax = ping->ping_fd + 1;
 
+  /* Some systems use `struct timeval' of size 16.  As these are
+   * not initialising `timeval' properly by assignment alone, let
+   * us play safely here.  gettimeofday() is always sufficient.
+   */
+  memset (&resp_time, 0, sizeof (resp_time));
+  memset (&intvl, 0, sizeof (intvl));
+  memset (&now, 0, sizeof (now));
+
   for (i = 0; i < preload; i++)
     send_echo (ping);
 
diff --git a/ping/ping6.c b/ping/ping6.c
index 445ced8..3fa2e28 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -284,6 +284,14 @@ ping_run (PING * ping, int (*finish) ())
 
   fdmax = ping->ping_fd + 1;
 
+  /* Some systems use `struct timeval' of size 16.  As these are
+   * not initialising `timeval' properly by assignment alone, let
+   * us play safely here.  gettimeofday() is always sufficient.
+   */
+  memset (&resp_time, 0, sizeof (resp_time));
+  memset (&intvl, 0, sizeof (intvl));
+  memset (&now, 0, sizeof (now));
+
   for (i = 0; i < preload; i++)
     send_echo (ping);
 
@@ -304,8 +312,8 @@ ping_run (PING * ping, int (*finish) ())
 
       FD_ZERO (&fdset);
       FD_SET (ping->ping_fd, &fdset);
+
       gettimeofday (&now, NULL);
-      memset (&resp_time, 0, sizeof (resp_time));	/* 64-bit issue */
       resp_time.tv_sec = last.tv_sec + intvl.tv_sec - now.tv_sec;
       resp_time.tv_usec = last.tv_usec + intvl.tv_usec - now.tv_usec;
 
diff --git a/src/traceroute.c b/src/traceroute.c
index df17661..44128b9 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -236,10 +236,11 @@ do_try (trace_t * trace, const int hop,
   double triptime = 0.0;
   uint32_t prev_addr = 0;
 
-  printf (" %d  ", hop);
+  printf (" %2d  ", hop);
 
   for (tries = 0; tries < max_tries; tries++)
     {
+      int save_errno;
       int fd = trace_icmp_sock (trace);
 
       FD_ZERO (&readset);
@@ -252,17 +253,23 @@ do_try (trace_t * trace, const int hop,
       if (!readonly)
 	trace_write (trace);
 
+      errno = 0;
+      ret = select (fd + 1, &readset, NULL, NULL, &time);
+      save_errno = errno;
+
       gettimeofday (&now, NULL);
 
       now.tv_usec -= trace->tsent.tv_usec;
       now.tv_sec -= trace->tsent.tv_sec;
-
-      errno = 0;
-      ret = select (fd + 1, &readset, NULL, NULL, &time);
+      if (now.tv_usec < 0)
+	{
+	  --now.tv_sec;
+	  now.tv_usec += 1000000;
+	}
 
       if (ret < 0)
 	{
-	  switch (errno)
+	  switch (save_errno)
 	    {
 	    case EINTR:
 	      /* was interrupted */
@@ -398,12 +405,12 @@ trace_read (trace_t * t)
 
   siz = sizeof (t->from);
 
-  len = recvfrom (t->icmpfd, (char *) data, 56, 0,
+  len = recvfrom (t->icmpfd, (char *) data, sizeof (data), 0,
 		  (struct sockaddr *) &t->from, &siz);
   if (len < 0)
     error (EXIT_FAILURE, errno, "recvfrom");
 
-  icmp_generic_decode (data, 56, &ip, &ic);
+  icmp_generic_decode (data, sizeof (data), &ip, &ic);
 
   switch (t->type)
     {

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |   87 +++++++++++++++++++++++++++++++++++++++
 libicmp/icmp.h           |    4 +-
 libicmp/icmp_address.c   |    2 +-
 libicmp/icmp_echo.c      |    6 +-
 libicmp/icmp_timestamp.c |    2 +-
 ping/libping.c           |   19 ++++++---
 ping/ping.c              |   12 +++++-
 ping/ping6.c             |   21 +++++++---
 ping/ping_address.c      |    4 +-
 ping/ping_common.h       |   12 +++---
 ping/ping_echo.c         |  101 ++++++++++++++++++++++++++-------------------
 ping/ping_timestamp.c    |    4 +-
 src/traceroute.c         |   21 ++++++---
 13 files changed, 214 insertions(+), 81 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed May 09 17:37:03 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SSEZD-0007CE-8z
	for mharc-commit-inetutils@gnu.org; Wed, 09 May 2012 17:37:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38439)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSEZ9-000711-HB
	for commit-inetutils@gnu.org; Wed, 09 May 2012 17:37:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSEZ6-0006NI-34
	for commit-inetutils@gnu.org; Wed, 09 May 2012 17:36:59 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:60203)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSEZ5-0006Mi-UG
	for commit-inetutils@gnu.org; Wed, 09 May 2012 17:36:55 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SSEZ4-0007rs-IW
	for commit-inetutils@gnu.org; Wed, 09 May 2012 21:36:55 +0000
Date: Wed, 09 May 2012 21:36:55 +0000
Message-Id: <E1SSEZ4-0007rs-IW@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-88-gd247431
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 24f0cb0538cef541153a999aee72867794abba14
X-Git-Newrev: d2474314ec95d196af43aae5484e4a2c6073308d
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 09 May 2012 21:37:01 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d2474314ec95d196af43aae5484e4a2c6073308d (commit)
       via  81e97053dad454b70a50f09b0e988fdd6e20e904 (commit)
      from  24f0cb0538cef541153a999aee72867794abba14 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d2474314ec95d196af43aae5484e4a2c6073308d


commit d2474314ec95d196af43aae5484e4a2c6073308d
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed May 9 03:28:35 2012 +0200

    ping, ping6: Time-to-live, hoplimit.

diff --git a/ChangeLog b/ChangeLog
index 4553d9b..ec999ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2012-05-09  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	ping: Options `--mask' and `--ttl'.
+
+	* ping/ping.c (ttl): New variable.
+	(ARG_TTL): New enumeration value.
+	(argp_options): Add long option `mask' as synomym to `address'.
+	New long option `ttl'.
+	(parse_opt) <ARG_TTL>: New case.
+	(main): If `ttl > 0', set value for sockopt IP_TTL.
+	(*decode_typ): Add check for `mask'.
+
+	ping6: Option `--hoplimit'.
+
+	* ping/ping6.c (hoplimit): New variable.
+	(ARG_HOPLIMIT): New enumeration value.
+	(argp_options): New long option `hoplimit'.
+	(parse_opt) <ARG_HOPLIMIT>: New case.
+	(main): If `hoplimit > 0', set value for sockopt IPV6_UNICAST_HOPS.
+
+	* doc/inetutils.texi (ping invocation): Updates, corrections.
+
+2012-05-09  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	Discriminate UTC from non-UTC time stamps.
 
 	* ping/ping_common.c (is_normed_time, ping_cvt_time): New fcns.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index dc1b6a1..08cba61 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -470,26 +470,40 @@ ping [@var{option}@dots{}] @var{host}@dots{}
 @c Options controlling ICMP request types:
 @c       --address              Send ICMP_ADDRESS packets (root only)
 @c       --echo                 Send ICMP_ECHO packets (default)
+@c       --mask                 Same as --address
 @c       --timestamp            Send ICMP_TIMESTAMP packets
 @c   -t, --type=TYPE            Send TYPE packets
 @table @option
 @item --address
 @opindex --address
-Send ICMP_ADDRESS packets.
+Send ICMP_ADDRESS packets, thus requesting the address netmask
+being in use by the targetted host.
 
 @item --echo
 @opindex --echo
 Send ICMP_ECHO requests (default).
 
+@item --mask
+@opindex --mask
+Identical to @option{--address}.
+
 @item --timestamp
 @opindex --timestamp
-Send ICMP_TIMESTAMP packets.
-
-@itemx -t @var{type}
+Send ICMP_TIMESTAMP packets, thereby requesting a timed response
+from the targetted host.  In successful cases three time values
+will be returned.  All are expected to state the number of
+milliseconds since midnight UTC.  The first, @samp{icmp_otime},
+contains the original time for sending the request.  Then,
+@samp{icmp_rtime}, is the time of reception by the target, and
+finally, @samp{icmp_ttime}, is the time for transmitting an answer
+back to the originator.
+
+@item -t @var{type}
 @itemx --type=@var{type}
 @opindex --type
 @opindex -t
-Send TYPE packets.
+Send @var{type} packets.  Accepted values are @samp{address},
+@samp{echo}, @samp{mask}, and @samp{timestamp}.
 @end table
 
 @c Options valid for all request types:
@@ -498,9 +512,11 @@ Send TYPE packets.
 @c   -i, --interval=NUMBER      Wait NUMBER seconds between sending each packet
 @c   -n, --numeric              Do not resolve host addresses
 @c   -r, --ignore-routing       Send directly to a host on an attached network
+@c       --ttl=NUMBER           Set specified time-to-live on packet
+
 @table @option
 @item -c @var{n}
-@item --count=@var{n}
+@itemx --count=@var{n}
 @opindex -c
 @opindex --count
 Stop after sending (and receiving) @var{n} ECHO_RESPONSE packets.
@@ -535,6 +551,11 @@ attached network.  If the host is not on a directly-attached network,
 an error is returned.  This option can be used to ping a local host
 through an interface that has no route through it (e.g., after the
 interface was dropped by @command{routed}).
+
+@item --ttl=@var{n}
+@opindex --ttl
+Set the specified number @var{n} as value of time-to-live when
+transmitting packets.  Acceptable values are 1 to 255, inclusive.
 @end table
 
 @c Options valid for --echo requests:
@@ -557,7 +578,7 @@ packets are being dropped.  Only the super-user may use this option.
 This can be very hard on a network and should be used with caution.
 
 @item -l @var{n}
-@item --preload=@var{n}
+@itemx --preload=@var{n}
 @opindex -l
 @opindex --preload
 If @var{n} is specified, ping sends that many packets as fast as
diff --git a/ping/ping.c b/ping/ping.c
index b82f557..740f8fd 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -64,6 +64,7 @@ size_t interval;
 size_t data_length = PING_DATALEN;
 unsigned options;
 unsigned long preload = 0;
+int ttl = 0;
 int timeout = -1;
 int linger = MAXWAIT;
 int (*ping_type) (char *hostname) = ping_echo;
@@ -87,7 +88,8 @@ enum {
   ARG_ECHO = 256,
   ARG_ADDRESS,
   ARG_TIMESTAMP,
-  ARG_ROUTERDISCOVERY
+  ARG_ROUTERDISCOVERY,
+  ARG_TTL,
 };
 
 static struct argp_option argp_options[] = {
@@ -96,6 +98,7 @@ static struct argp_option argp_options[] = {
   {"address", ARG_ADDRESS, NULL, 0, "send ICMP_ADDRESS packets (root only)",
    GRP+1},
   {"echo", ARG_ECHO, NULL, 0, "send ICMP_ECHO packets (default)", GRP+1},
+  {"mask", ARG_ADDRESS, NULL, 0, "same as --address", GRP+1},
   {"timestamp", ARG_TIMESTAMP, NULL, 0, "send ICMP_TIMESTAMP packets", GRP+1},
   {"type", 't', "TYPE", 0, "send TYPE packets", GRP+1},
   /* This option is not yet fully implemented, so mark it as hidden. */
@@ -111,6 +114,7 @@ static struct argp_option argp_options[] = {
   {"numeric", 'n', NULL, 0, "do not resolve host addresses", GRP+1},
   {"ignore-routing", 'r', NULL, 0, "send directly to a host on an attached "
    "network", GRP+1},
+  {"ttl", ARG_TTL, "N", 0, "specify N as time-to-live", GRP+1},
   {"verbose", 'v', NULL, 0, "verbose output", GRP+1},
   {"timeout", 'w', "N", 0, "stop after N seconds", GRP+1},
   {"linger", 'W', "N", 0, "number of seconds to wait for response", GRP+1},
@@ -223,6 +227,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       ping_type = decode_type ("router");
       break;
 
+    case ARG_TTL:
+      ttl = ping_cvt_number (arg, 255, 0);
+      break;
+
     case ARGP_KEY_NO_ARGS:
       argp_error (state, "missing host operand");
 
@@ -273,6 +281,11 @@ main (int argc, char **argv)
   if (options & OPT_INTERVAL)
     ping_set_interval (ping, interval);
 
+  if (ttl > 0)
+    if (setsockopt (ping->ping_fd, IPPROTO_IP, IP_TTL,
+		    &ttl, sizeof (ttl)) < 0)
+      error (0, errno, "setsockopt(IP_TTL)");
+
   init_data_buffer (patptr, pattern_len);
 
   while (argc--)
@@ -296,6 +309,8 @@ int (*decode_type (const char *arg)) (char *hostname)
     ping_type = ping_timestamp;
   else if (strcasecmp (arg, "address") == 0)
     ping_type = ping_address;
+  else if (strcasecmp (arg, "mask") == 0)
+    ping_type = ping_address;
 #if 0
   else if (strcasecmp (arg, "router") == 0)
     ping_type = ping_router;
diff --git a/ping/ping6.c b/ping/ping6.c
index 4f7d041..8358e7b 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -57,6 +57,7 @@ size_t count = DEFAULT_PING_COUNT;
 size_t interval;
 int socket_type;
 int timeout = -1;
+int hoplimit = 0;
 static unsigned int options;
 static unsigned long preload = 0;
 
@@ -73,11 +74,16 @@ const char *program_authors[] = {
 	NULL
 };
 
+enum {
+  ARG_HOPLIMIT = 256,
+};
+
 static struct argp_option argp_options[] = {
 #define GRP 0
   {NULL, 0, NULL, 0, "Options valid for all request types:", GRP},
   {"count", 'c', "NUMBER", 0, "stop after sending NUMBER packets", GRP+1},
   {"debug", 'd', NULL, 0, "set the SO_DEBUG option", GRP+1},
+  {"hoplimit", ARG_HOPLIMIT, "N", 0, "specify N as hop-limit", GRP+1},
   {"interval", 'i', "NUMBER", 0, "wait NUMBER seconds between sending each "
    "packet", GRP+1},
   {"numeric", 'n', NULL, 0, "do not resolve host addresses", GRP+1},
@@ -162,6 +168,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       data_length = ping_cvt_number (arg, PING_MAX_DATALEN, 1);
       break;
 
+    case ARG_HOPLIMIT:
+      hoplimit = ping_cvt_number (arg, 255, 0);
+      break;
+
     case ARGP_KEY_NO_ARGS:
       argp_error (state, "missing host operand");
 
@@ -211,6 +221,11 @@ main (int argc, char **argv)
   if (options & OPT_INTERVAL)
     ping_set_interval (ping, interval);
 
+  if (hoplimit > 0)
+    if (setsockopt (ping->ping_fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
+		    &hoplimit, sizeof (hoplimit)) < 0)
+      error (0, errno, "setsockopt(IPV6_HOPLIMIT)");
+
   init_data_buffer (patptr, pattern_len);
 
   while (argc--)

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=81e97053dad454b70a50f09b0e988fdd6e20e904


commit 81e97053dad454b70a50f09b0e988fdd6e20e904
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed May 9 02:02:20 2012 +0200

    ping: Identify UTC time stamps.

diff --git a/ChangeLog b/ChangeLog
index 739dfb7..4553d9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-05-09  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Discriminate UTC from non-UTC time stamps.
+
+	* ping/ping_common.c (is_normed_time, ping_cvt_time): New fcns.
+	* ping/ping_common.h (is_normed_time, ping_cvt_time): New prototypes.
+	* ping/ping_timestamp.c (print_timestamp): New variable TIMESTR.
+	Call ping_cvt_time() to generate strings for three time values.
+	[options & OPT_VERBOSE]: Print time difference if both of
+	`icmp->icmp_otime' and `icmp->icmp_ttime' are UTC-based.
+
+	* ping/ping_common.h (_PING_BUFLEN):  Really replace the
+	parameter name `USE_IPV6' by the neutral name `u'.
+
 2012-05-08  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Critical package errors in size and allocation.
diff --git a/ping/ping_common.c b/ping/ping_common.c
index bd6d65d..58bb22f 100644
--- a/ping/ping_common.c
+++ b/ping/ping_common.c
@@ -140,6 +140,28 @@ nsqrt (double a, double prec)
 }
 
 int
+is_normed_time (n_time t)
+{
+  /* A set MSB indicates non-normalised time standard.  */
+  return (t & (1UL << 31)) ? 0 : 1;
+}
+
+const char *
+ping_cvt_time (char *buf, size_t buflen, n_time t)
+{
+  n_time t_red;
+
+  t_red = t & ((1UL << 31) - 1);
+
+  if (is_normed_time (t))
+    snprintf (buf, buflen, "%u", t_red);
+  else
+    snprintf (buf, buflen, "<%u>", t_red);
+
+  return buf;
+}
+
+int
 _ping_setbuf (PING * p, bool use_ipv6)
 {
   if (!p->ping_buffer)
diff --git a/ping/ping_common.h b/ping/ping_common.h
index 2c8c796..ee86a00 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -67,7 +67,7 @@ struct ping_stat
 } while (0)
 
 /* FIXME: Adjust IPv6 case for options and their consumption.  */
-#define _PING_BUFLEN(p, USE_IPV6) ((USE_IPV6)? ((p)->ping_datalen + sizeof (struct icmp6_hdr)) : \
+#define _PING_BUFLEN(p, u) ((u)? ((p)->ping_datalen + sizeof (struct icmp6_hdr)) : \
 				   (MAXIPLEN + (p)->ping_datalen + ICMP_TSLEN))
 
 typedef int (*ping_efp6) (int code, void *closure, struct sockaddr_in6 * dest,
@@ -146,6 +146,8 @@ double nabs (double a);
 double nsqrt (double a, double prec);
 
 size_t ping_cvt_number (const char *optarg, size_t maxval, int allow_zero);
+int is_normed_time (n_time t);
+const char * ping_cvt_time (char *buf, size_t buflen, n_time t);
 
 void init_data_buffer (unsigned char *pat, int len);
 
diff --git a/ping/ping_timestamp.c b/ping/ping_timestamp.c
index 2c50192..c0c22e6 100644
--- a/ping/ping_timestamp.c
+++ b/ping/ping_timestamp.c
@@ -93,15 +93,30 @@ print_timestamp (int dupflag, void *closure,
 		 struct sockaddr_in *dest, struct sockaddr_in *from,
 		 struct ip *ip, icmphdr_t * icmp, int datalen)
 {
+  char timestr[16];
+
   printf ("%d bytes from %s: icmp_seq=%u", datalen,
 	  inet_ntoa (*(struct in_addr *) &from->sin_addr.s_addr),
 	  ntohs (icmp->icmp_seq));
   if (dupflag)
     printf (" (DUP!)");
   printf ("\n");
-  printf ("icmp_otime = %u\n", ntohl (icmp->icmp_otime));
-  printf ("icmp_rtime = %u\n", ntohl (icmp->icmp_rtime));
-  printf ("icmp_ttime = %u\n", ntohl (icmp->icmp_ttime));
+  printf ("icmp_otime = %s\n",
+	  ping_cvt_time (timestr, sizeof (timestr),
+			 ntohl (icmp->icmp_otime)));
+  printf ("icmp_rtime = %s\n",
+	  ping_cvt_time (timestr, sizeof (timestr),
+			 ntohl (icmp->icmp_rtime)));
+  printf ("icmp_ttime = %s\n",
+	  ping_cvt_time (timestr, sizeof (timestr),
+			 ntohl (icmp->icmp_ttime)));
+
+  if ((options & OPT_VERBOSE)
+      && is_normed_time (ntohl (icmp->icmp_otime))
+      && is_normed_time (ntohl (icmp->icmp_otime)))
+    printf ("difference = %d ms\n",
+	    ntohl (icmp->icmp_ttime) - ntohl (icmp->icmp_otime));
+
   return;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   36 ++++++++++++++++++++++++++++++++++++
 doc/inetutils.texi    |   35 ++++++++++++++++++++++++++++-------
 ping/ping.c           |   17 ++++++++++++++++-
 ping/ping6.c          |   15 +++++++++++++++
 ping/ping_common.c    |   22 ++++++++++++++++++++++
 ping/ping_common.h    |    4 +++-
 ping/ping_timestamp.c |   21 ++++++++++++++++++---
 7 files changed, 138 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu May 10 17:38:36 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SSb4G-0006hL-GB
	for mharc-commit-inetutils@gnu.org; Thu, 10 May 2012 17:38:36 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53643)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSb4C-0006ZM-KH
	for commit-inetutils@gnu.org; Thu, 10 May 2012 17:38:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSb48-0005FE-Tm
	for commit-inetutils@gnu.org; Thu, 10 May 2012 17:38:32 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46119)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSb48-0005Ez-QO
	for commit-inetutils@gnu.org; Thu, 10 May 2012 17:38:28 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SSb47-0001No-9h
	for commit-inetutils@gnu.org; Thu, 10 May 2012 21:38:27 +0000
Date: Thu, 10 May 2012 21:38:27 +0000
Message-Id: <E1SSb47-0001No-9h@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-90-g8aebed7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d2474314ec95d196af43aae5484e4a2c6073308d
X-Git-Newrev: 8aebed791231ca1e2fb20588f929d97f6b894fdc
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 May 2012 21:38:34 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  8aebed791231ca1e2fb20588f929d97f6b894fdc (commit)
       via  dd74888217cc86866ba4f14a9d7415d305f0c44b (commit)
      from  d2474314ec95d196af43aae5484e4a2c6073308d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=8aebed791231ca1e2fb20588f929d97f6b894fdc


commit 8aebed791231ca1e2fb20588f929d97f6b894fdc
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 10 23:33:06 2012 +0200

    ping, ping6: Refactor common resolver.

diff --git a/ChangeLog b/ChangeLog
index 6aa0834..0ad7cb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2012-05-10  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Refactor address-to-string conversion as common code.
+
+	* ping/ping6.c (options): Remove qualifier `static'.
+	(ipaddr2str): Removed function.
+	(print_icmp_error): Call ipaddr2str() with new signature.
+	* ping/ping_common.c: Include <errno.h>, <netinet/in.h>,
+	<arpa/inet.h>, and <netdb.h>.
+	(options): New external variable.
+	(ipaddr2str, sinaddr2str): New functions.
+	* ping/ping_common.h (ipaddr2str, sinaddr2str): New prototypes.
+	* ping/ping_echo.c (ipaddr2str): Removed function.
+	(print_icmp_header): Call ipaddr2str() with new signature.
+	(print_ip_opt): Replace ipaddr2str() with sinaddr2str().
+
+2012-05-10  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	* ping/ping6.c (argp_options): New option `verbose'.
 	(parse_opt) <v>: New case.
 	(ping_echo): Print identity in verbose mode.
diff --git a/ping/ping6.c b/ping/ping6.c
index 1848e2a..d432af4 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -58,7 +58,7 @@ size_t interval;
 int socket_type;
 int timeout = -1;
 int hoplimit = 0;
-static unsigned int options;
+unsigned int options;
 static unsigned long preload = 0;
 
 static int ping_echo (char *hostname);
@@ -242,44 +242,6 @@ main (int argc, char **argv)
   return status;
 }
 
-static char *
-ipaddr2str (struct sockaddr_in6 *from)
-{
-  int err;
-  size_t len;
-  char *buf, ipstr[256], hoststr[256];
-
-  err = getnameinfo ((struct sockaddr *) from, sizeof (*from), ipstr,
-		     sizeof (ipstr), NULL, 0, NI_NUMERICHOST);
-  if (err)
-    {
-      const char *errmsg;
-
-      if (err == EAI_SYSTEM)
-	errmsg = strerror (errno);
-      else
-	errmsg = gai_strerror (err);
-
-      fprintf (stderr, "ping: getnameinfo: %s\n", errmsg);
-      return xstrdup ("unknown");
-    }
-
-  if (options & OPT_NUMERIC)
-    return xstrdup (ipstr);
-
-  err = getnameinfo ((struct sockaddr *) from, sizeof (*from), hoststr,
-		     sizeof (hoststr), NULL, 0, NI_NAMEREQD);
-  if (err)
-    return xstrdup (ipstr);
-
-  len = strlen (ipstr) + strlen (hoststr) + 4;	/* Pair of parentheses, a space
-						   and a NUL. */
-  buf = xmalloc (len);
-  sprintf (buf, "%s (%s)", hoststr, ipstr);
-
-  return buf;
-}
-
 static volatile int stop = 0;
 
 static void
@@ -692,7 +654,7 @@ print_icmp_error (struct sockaddr_in6 *from, struct icmp6_hdr *icmp6, int len)
   char *s;
   struct icmp_diag *p;
 
-  s = ipaddr2str (from);
+  s = ipaddr2str ((struct sockaddr *) from, sizeof (*from));
   printf ("%d bytes from %s: ", len, s);
   free (s);
 
diff --git a/ping/ping_common.c b/ping/ping_common.c
index 58bb22f..8f2fcf9 100644
--- a/ping/ping_common.c
+++ b/ping/ping_common.c
@@ -25,6 +25,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 #include <xalloc.h>
 
 #include "ping_common.h"
@@ -33,6 +37,7 @@ extern unsigned char *data_buffer;
 extern size_t data_length;
 
 static void _ping_freebuf (PING * p);
+extern unsigned int options;
 
 size_t
 ping_cvt_number (const char *optarg, size_t maxval, int allow_zero)
@@ -248,3 +253,72 @@ ping_timeout_p (struct timeval *start_time, int timeout)
     }
   return 0;
 }
+
+char *
+ipaddr2str (struct sockaddr *from, socklen_t fromlen)
+{
+  int err;
+  size_t len;
+  char *buf, ipstr[INET6_ADDRSTRLEN], hoststr[256];
+
+  err = getnameinfo (from, fromlen, ipstr, sizeof (ipstr),
+		     NULL, 0, NI_NUMERICHOST);
+  if (err)
+    {
+      const char *errmsg;
+
+      if (err == EAI_SYSTEM)
+	errmsg = strerror (errno);
+      else
+	errmsg = gai_strerror (err);
+
+      fprintf (stderr, "ping: getnameinfo: %s\n", errmsg);
+      return xstrdup ("unknown");
+    }
+
+  if (options & OPT_NUMERIC)
+    return xstrdup (ipstr);
+
+  err = getnameinfo (from, fromlen, hoststr, sizeof (hoststr),
+		     NULL, 0, NI_NAMEREQD);
+  if (err)
+    return xstrdup (ipstr);
+
+  len = strlen (ipstr) + strlen (hoststr) + 4;	/* Pair of parentheses, a space
+						   and a NUL. */
+  buf = xmalloc (len);
+  snprintf (buf, len, "%s (%s)", hoststr, ipstr);
+
+  return buf;
+}
+
+char *
+sinaddr2str (struct in_addr ina)
+{
+  struct hostent *hp;
+
+  if (options & OPT_NUMERIC)
+    return xstrdup (inet_ntoa (ina));
+
+  hp = gethostbyaddr ((char *) &ina, sizeof (ina), AF_INET);
+  if (hp == NULL)
+    return xstrdup (inet_ntoa (ina));
+  else
+    {
+      char *buf, *ipstr;
+      int len;
+
+      ipstr = inet_ntoa (ina);
+      len = strlen (ipstr) + 1;
+
+      if (hp->h_name)
+	len += strlen (hp->h_name) + 4;	/* parentheses, space, and NUL */
+
+      buf = xmalloc (len);
+      if (hp->h_name)
+	snprintf (buf, len, "%s (%s)", hp->h_name, ipstr);
+      else
+	snprintf (buf, len, "%s", ipstr);
+      return buf;
+    }
+}
diff --git a/ping/ping_common.h b/ping/ping_common.h
index ee86a00..fcda0be 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -160,3 +160,6 @@ void ping_set_sockopt (PING * ping, int opt, void *val, int valsize);
 void ping_set_interval (PING * ping, size_t interval);
 void ping_unset_data (PING * p);
 int ping_timeout_p (struct timeval *start_time, int timeout);
+
+char * ipaddr2str (struct sockaddr *from, socklen_t fromlen);
+char * sinaddr2str (struct in_addr ina);
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index a401820..cc3445a 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -196,35 +196,6 @@ print_echo (int dupflag, struct ping_stat *ping_stat,
   return 0;
 }
 
-char *
-ipaddr2str (struct in_addr ina)
-{
-  struct hostent *hp;
-
-  if (options & OPT_NUMERIC)
-    return xstrdup (inet_ntoa (ina));
-
-  hp = gethostbyaddr ((char *) &ina, sizeof (ina), AF_INET);
-  if (hp == NULL)
-    return xstrdup (inet_ntoa (ina));
-  else
-    {
-      char *ipstr = inet_ntoa (ina);
-      int len = strlen (ipstr) + 1;
-      char *buf;
-
-      if (hp->h_name)
-	len += strlen (hp->h_name) + 3;	/* a pair of parentheses and a space */
-
-      buf = xmalloc (len);
-      if (hp->h_name)
-	snprintf (buf, len, "%s (%s)", hp->h_name, ipstr);
-      else
-	snprintf (buf, len, "%s", ipstr);
-      return buf;
-    }
-}
-
 #define NITEMS(a) sizeof(a)/sizeof((a)[0])
 
 struct icmp_diag
@@ -404,7 +375,8 @@ print_icmp_header (struct sockaddr_in *from,
 	|| orig_ip->ip_dst.s_addr == ping->ping_dest.ping_sockaddr.sin_addr.s_addr))
     return;
 
-  printf ("%d bytes from %s: ", len - hlen, s = ipaddr2str (from->sin_addr));
+  s = ipaddr2str ((struct sockaddr *) from, sizeof (*from));
+  printf ("%d bytes from %s: ", len - hlen, s);
   free (s);
 
   for (p = icmp_diag; p < icmp_diag + NITEMS (icmp_diag); p++)
@@ -462,7 +434,7 @@ print_ip_opt (struct ip *ip, int hlen)
 		  char *s;
 
 		  ina.s_addr = htonl (l);
-		  printf ("\t%s", s = ipaddr2str (ina));
+		  printf ("\t%s", s = sinaddr2str (ina));
 		  free (s);
 		}
 	      hlen -= 4;
@@ -519,7 +491,7 @@ print_ip_opt (struct ip *ip, int hlen)
 		char *s;
 
 		ina.s_addr = htonl (l);
-		printf ("\t%s", s = ipaddr2str (ina));
+		printf ("\t%s", s = sinaddr2str (ina));
 		free (s);
 	      }
 	    hlen -= 4;

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=dd74888217cc86866ba4f14a9d7415d305f0c44b


commit dd74888217cc86866ba4f14a9d7415d305f0c44b
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 10 23:30:31 2012 +0200

    ping, ping6: Additional verbosity.

diff --git a/ChangeLog b/ChangeLog
index ec999ff..6aa0834 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-10  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* ping/ping6.c (argp_options): New option `verbose'.
+	(parse_opt) <v>: New case.
+	(ping_echo): Print identity in verbose mode.
+	* ping/ping_echo.c (ping_echo): Likewise.
+	(print_ip_header): Print IP header dump in verbose mode.
+
 2012-05-09  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ping: Options `--mask' and `--ttl'.
diff --git a/ping/ping6.c b/ping/ping6.c
index 8358e7b..1848e2a 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -90,6 +90,7 @@ static struct argp_option argp_options[] = {
   {"ignore-routing", 'r', NULL, 0, "send directly to a host on an attached "
    "network", GRP+1},
   {"timeout", 'w', "N", 0, "stop after N seconds", GRP+1},
+  {"verbose", 'v', NULL, 0, "verbose output", GRP+1},
 #undef GRP
 #define GRP 10
   {NULL, 0, NULL, 0, "Options valid for --echo requests:", GRP},
@@ -160,14 +161,18 @@ parse_opt (int key, char *arg, struct argp_state *state)
       socket_type |= SO_DONTROUTE;
       break;
 
-    case 'w':
-      timeout = ping_cvt_number (arg, INT_MAX, 0);
-      break;
-
     case 's':
       data_length = ping_cvt_number (arg, PING_MAX_DATALEN, 1);
       break;
 
+    case 'v':
+      options |= OPT_VERBOSE;
+      break;
+
+    case 'w':
+      timeout = ping_cvt_number (arg, INT_MAX, 0);
+      break;
+
     case ARG_HOPLIMIT:
       hoplimit = ping_cvt_number (arg, 255, 0);
       break;
@@ -486,8 +491,12 @@ ping_echo (char *hostname)
       error (EXIT_FAILURE, 0, "getnameinfo: %s", errmsg);
     }
 
-  printf ("PING %s (%s): %d data bytes\n",
+  printf ("PING %s (%s): %d data bytes",
 	  ping->ping_hostname, buffer, data_length);
+  if (options & OPT_VERBOSE)
+    printf (", id 0x%04x = %u", ping->ping_ident, ping->ping_ident);
+
+  printf ("\n");
 
   status = ping_run (ping, echo_finish);
   free (ping->ping_hostname);
@@ -670,16 +679,12 @@ static struct icmp_diag
 {
   int type;
   void (*func) (struct icmp6_hdr *);
-} icmp_diag[] =
-{
-  {
-  ICMP6_DST_UNREACH, print_dst_unreach},
-  {
-  ICMP6_PACKET_TOO_BIG, print_packet_too_big},
-  {
-  ICMP6_TIME_EXCEEDED, print_time_exceeded},
-  {
-ICMP6_PARAM_PROB, print_param_prob},};
+} icmp_diag[] = {
+  {ICMP6_DST_UNREACH, print_dst_unreach},
+  {ICMP6_PACKET_TOO_BIG, print_packet_too_big},
+  {ICMP6_TIME_EXCEEDED, print_time_exceeded},
+  {ICMP6_PARAM_PROB, print_param_prob},
+};
 
 static void
 print_icmp_error (struct sockaddr_in6 *from, struct icmp6_hdr *icmp6, int len)
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index 870d685..a401820 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -101,9 +101,13 @@ ping_echo (char *hostname)
 #endif /* IP_OPTIONS */
     }
 
-  printf ("PING %s (%s): %d data bytes\n",
+  printf ("PING %s (%s): %d data bytes",
 	  ping->ping_hostname,
 	  inet_ntoa (ping->ping_dest.ping_sockaddr.sin_addr), data_length);
+  if (options & OPT_VERBOSE)
+    printf (", id 0x%04x = %u", ping->ping_ident, ping->ping_ident);
+
+  printf ("\n");
 
   status = ping_run (ping, echo_finish);
   free (ping->ping_hostname);
@@ -291,6 +295,17 @@ print_ip_header (struct ip *ip)
   hlen = ip->ip_hl << 2;
   cp = (unsigned char *) ip + sizeof (*ip);	/* point to options */
 
+  if (options & OPT_VERBOSE)
+    {
+      int j;
+
+      printf ("IP Hdr Dump:\n ");
+      for (j = 0; j < sizeof (*ip); ++j)
+	printf ("%02x%s", *((unsigned char *) ip + j),
+		(j % 2) ? " " : "");	/* Group bytes two by two.  */
+      printf ("\n");
+    }
+
   printf
     ("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src\tDst\tData\n");
   printf (" %1x  %1x  %02x %04x %04x", ip->ip_v, ip->ip_hl, ip->ip_tos,

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   24 ++++++++++++++++
 ping/ping6.c       |   77 +++++++++++++++-------------------------------------
 ping/ping_common.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++
 ping/ping_common.h |    3 ++
 ping/ping_echo.c   |   53 +++++++++++++----------------------
 5 files changed, 143 insertions(+), 88 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri May 11 11:39:23 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SSrwB-0006zq-2k
	for mharc-commit-inetutils@gnu.org; Fri, 11 May 2012 11:39:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:34619)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSrw4-0006z2-GD
	for commit-inetutils@gnu.org; Fri, 11 May 2012 11:39:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSrw0-0007yu-Ay
	for commit-inetutils@gnu.org; Fri, 11 May 2012 11:39:16 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33197)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SSrw0-0007yq-7J
	for commit-inetutils@gnu.org; Fri, 11 May 2012 11:39:12 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SSrvy-0001db-54
	for commit-inetutils@gnu.org; Fri, 11 May 2012 15:39:11 +0000
Date: Fri, 11 May 2012 15:39:10 +0000
Message-Id: <E1SSrvy-0001db-54@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-91-g5893d2e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8aebed791231ca1e2fb20588f929d97f6b894fdc
X-Git-Newrev: 5893d2ec601754a03e8cd5e5fa059966c769224a
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 May 2012 15:39:21 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  5893d2ec601754a03e8cd5e5fa059966c769224a (commit)
      from  8aebed791231ca1e2fb20588f929d97f6b894fdc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=5893d2ec601754a03e8cd5e5fa059966c769224a


commit 5893d2ec601754a03e8cd5e5fa059966c769224a
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri May 11 17:37:14 2012 +0200

    traceroute: Identity and sequence.
    
    Set dynamic identity and use running sequence number
    for every sent packet.  This improves reliability.

diff --git a/ChangeLog b/ChangeLog
index 0ad7cb9..969822b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-05-11  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	traceroute: Dynamic identity and sequence numbers.
+
+	* src/traceroute.c (seqno): New variable.
+	(main): Assign getpid() to `pid'.  Initialise `seqno'.
+	(trace_read) <TRACE_UDP>: Replace numerical offset `11'.
+	(trace_read) <TRACE_ICMP && ICMP_ECHOREPLY>: Apply ntohs()
+	to `ic->icmp_seq' and to `ic->icmp_id'.
+	<TRACE_ICMP && ICMP_TIME_EXCEEDED>: Complete code rewrite.
+	(trace_write): Activate dynamic `pid' and `seqno' in call to
+	icmp_echo_encode().
+
 2012-05-10  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Refactor address-to-string conversion as common code.
diff --git a/src/traceroute.c b/src/traceroute.c
index 44128b9..cc9abb5 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -88,7 +88,8 @@ void do_try (trace_t * trace, const int hop,
 char *get_hostname (struct in_addr *addr);
 
 int stop = 0;
-int pid = 0;
+int pid;
+int seqno;	/* Most recent sequence number.  */
 static char *hostname = NULL;
 char addrstr[INET6_ADDRSTRLEN];
 struct sockaddr_in dest;
@@ -181,11 +182,14 @@ static struct argp argp = {argp_options, parse_opt, args_doc, doc};
 int
 main (int argc, char **argv)
 {
+  int hop;
   struct addrinfo hints, *res;
   trace_t trace;
 
   set_program_name (argv[0]);
 
+  pid = getpid();
+
   /* Parse command line */
   iu_argp_init ("traceroute", program_authors);
   argp_parse (&argp, argc, argv, 0, NULL, NULL);
@@ -212,7 +216,9 @@ main (int argc, char **argv)
 
   trace_init (&trace, dest, opt_type);
 
-  int hop = 1;
+  hop = 1;
+  seqno = -1;	/* One less than first usable packet number 0.  */
+
   while (!stop)
     {
       if (hop > opt_max_hops)
@@ -424,8 +430,9 @@ trace_read (trace_t * t)
 	  return -1;
 
 	/* check whether it's for us */
-        port = (unsigned short *) &ic->icmp_ip + 11;
-	if (*port != t->to.sin_port)
+        port = (unsigned short *) ((void *) &ic->icmp_ip +
+			sizeof (struct ip) + sizeof (in_port_t));
+	if (*port != t->to.sin_port)	/* Network byte order!  */
 	  return -1;
 
 	if (ic->icmp_code == ICMP_PORT_UNREACH)
@@ -440,13 +447,21 @@ trace_read (trace_t * t)
 	return -1;
 
       if (ic->icmp_type == ICMP_ECHOREPLY
-	  && (ic->icmp_seq != pid || ic->icmp_id != pid))
+	  && (ntohs (ic->icmp_seq) != seqno
+	      || ntohs (ic->icmp_id) != pid))
 	return -1;
       else if (ic->icmp_type == ICMP_TIME_EXCEEDED)
 	{
-	  unsigned short *seq = (unsigned short *) &ic->icmp_ip + 12;
-	  unsigned short *ident = (unsigned short *) &ic->icmp_ip + 13;
-	  if (*seq != pid || *ident != pid)
+	  unsigned short seq, ident;
+	  struct ip *old_ip;
+	  icmphdr_t *old_icmp;
+
+	  old_ip = (struct ip *) &ic->icmp_ip;
+	  old_icmp = (icmphdr_t *) ((void *) old_ip + sizeof (struct ip));
+	  seq = ntohs (old_icmp->icmp_seq);
+	  ident = ntohs (old_icmp->icmp_id);
+
+	  if (seq != seqno || ident != pid)
 	    return -1;
 	}
 
@@ -497,8 +512,10 @@ trace_write (trace_t * t)
     case TRACE_ICMP:
       {
 	icmphdr_t hdr;
-	/* FIXME: We could use the pid as the icmp seqno/ident. */
-	if (icmp_echo_encode ((unsigned char *) &hdr, sizeof (hdr), pid, pid))
+
+	/* The sequence number is updated to a valid value!  */
+	if (icmp_echo_encode ((unsigned char *) &hdr, sizeof (hdr),
+			      pid, ++seqno))
 	  return -1;
 
 	len = sendto (t->icmpfd, (char *) &hdr, sizeof (hdr),

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog        |   13 +++++++++++++
 src/traceroute.c |   37 +++++++++++++++++++++++++++----------
 2 files changed, 40 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Sat May 12 09:40:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1STCYx-0002Bx-0N
	for mharc-commit-inetutils@gnu.org; Sat, 12 May 2012 09:40:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48712)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STCYt-0002Bl-Ih
	for commit-inetutils@gnu.org; Sat, 12 May 2012 09:40:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STCYq-0007wB-KG
	for commit-inetutils@gnu.org; Sat, 12 May 2012 09:40:43 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38998)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STCYq-0007w6-96
	for commit-inetutils@gnu.org; Sat, 12 May 2012 09:40:40 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1STCYn-0005mC-73
	for commit-inetutils@gnu.org; Sat, 12 May 2012 13:40:39 +0000
Date: Sat, 12 May 2012 13:40:37 +0000
Message-Id: <E1STCYn-0005mC-73@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-92-gd5298c7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 5893d2ec601754a03e8cd5e5fa059966c769224a
X-Git-Newrev: d5298c7cf092f160f135d206dece09040e2c2410
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 12 May 2012 13:40:45 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d5298c7cf092f160f135d206dece09040e2c2410 (commit)
      from  5893d2ec601754a03e8cd5e5fa059966c769224a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d5298c7cf092f160f135d206dece09040e2c2410


commit d5298c7cf092f160f135d206dece09040e2c2410
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat May 12 15:05:13 2012 +0200

    ping: Support IP option Timestamp.

diff --git a/ChangeLog b/ChangeLog
index 969822b..f2562e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2012-05-12  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ping: Support IP option Timestamp.
+
+	* doc/inetutils.texi (ping invocation): Update.
+	* ping/ping.c (suboptions): New variable.
+	(decode_ip_timestamp): New function.
+	(ARG_IPTIMESTAMP): New enumeration value.
+	(argp_options): Add long option `ip-timestamp'.
+	(parse_opt) <ARG_IPTIMESTAMP>: New case.
+	* ping/ping_common.h (OPT_IPTIMESTAMP, SOPT_TSONLY)
+	(SOPT_TSADDR, SOPT_TSPRESPEC): New macros.
+	* ping/ping_echo.c (ping_echo) [options & OPT_IPTIMESTAMP]:
+	New setup case.
+	(print_ip_opt): New variable K.
+	<IPOPT_TS>: New printout case.
+	* ping/ping_impl.h [!USE_IPV6] (suboptions): New external.
+
 2012-05-11  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	traceroute: Dynamic identity and sequence numbers.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 08cba61..cc2506b 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -560,10 +560,12 @@ transmitting packets.  Acceptable values are 1 to 255, inclusive.
 
 @c Options valid for --echo requests:
 @c   -f, --flood                Flood ping (root only)
+@c       --ip-timestamp=FLAG    Timestamp IP option of types tsonly,
+@                               tsaddr, or (not yet implemented) prespec.
 @c   -l, --preload=NUMBER       Send NUMBER packets as fast as possible before
 @c                              falling into normal mode of behavior (root only)
 @c   -p, --pattern=PATTERN      Fill ICMP packet with given pattern (hex)
-@c   -R, --route                Record route
+@c   -R, --route                Record route IP option
 @c   -s, --size=NUMBER          Send NUMBER data octets
 @table @option
 @item -f
@@ -577,6 +579,13 @@ backspace is printed.  This provides a rapid display of how many
 packets are being dropped.  Only the super-user may use this option.
 This can be very hard on a network and should be used with caution.
 
+@item --ip-timestamp=@var{flag}
+@opindex --ip-timestamp
+Include IP option Timestamp in transmitted packets.  The value
+@var{flag} is either of @samp{tsonly}, which only records up to nine
+time stamps, and @samp{tsaddr}, which records IP addresses as well
+as time stamps for at most four hosts.
+
 @item -l @var{n}
 @itemx --preload=@var{n}
 @opindex -l
diff --git a/ping/ping.c b/ping/ping.c
index 740f8fd..6b3f2e7 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -63,6 +63,7 @@ size_t count = DEFAULT_PING_COUNT;
 size_t interval;
 size_t data_length = PING_DATALEN;
 unsigned options;
+unsigned int suboptions;
 unsigned long preload = 0;
 int ttl = 0;
 int timeout = -1;
@@ -70,6 +71,7 @@ int linger = MAXWAIT;
 int (*ping_type) (char *hostname) = ping_echo;
 
 int (*decode_type (const char *arg)) (char *hostname);
+static int decode_ip_timestamp (char *arg);
 static int send_echo (PING * ping);
 
 #define MIN_USER_INTERVAL (200000/PING_PRECISION)
@@ -90,6 +92,7 @@ enum {
   ARG_TIMESTAMP,
   ARG_ROUTERDISCOVERY,
   ARG_TTL,
+  ARG_IPTIMESTAMP,
 };
 
 static struct argp_option argp_options[] = {
@@ -128,6 +131,8 @@ static struct argp_option argp_options[] = {
    GRP+1},
   {"quiet", 'q', NULL, 0, "quiet output", GRP+1},
   {"route", 'R', NULL, 0, "record route", GRP+1},
+  {"ip-timestamp", ARG_IPTIMESTAMP, "FLAG", 0, "IP timestamp of type FLAG, "
+   "which is one of \"tsonly\" and \"tsaddr\"", GRP+1},
   {"size", 's', "NUMBER", 0, "send NUMBER data octets", GRP+1},
 #undef GRP
   {NULL}
@@ -231,6 +236,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
       ttl = ping_cvt_number (arg, 255, 0);
       break;
 
+    case ARG_IPTIMESTAMP:
+      options |= OPT_IPTIMESTAMP;
+      suboptions |= decode_ip_timestamp (arg);
+      break;
+
     case ARGP_KEY_NO_ARGS:
       argp_error (state, "missing host operand");
 
@@ -321,6 +331,25 @@ int (*decode_type (const char *arg)) (char *hostname)
  return ping_type;
 }
 
+int
+decode_ip_timestamp (char *arg)
+{
+  int sopt = 0;
+
+  if (strcasecmp (arg, "tsonly") == 0)
+    sopt = SOPT_TSONLY;
+  else if (strcasecmp (arg, "tsaddr") == 0)
+    sopt = SOPT_TSADDR;
+#if 0	/* Not yet implemented.  */
+  else if (strcasecmp (arg, "prespec") == 0)
+    sopt = SOPT_TSPRESPEC;
+#endif
+  else
+    error (EXIT_FAILURE, 0, "unsupported timestamp type: %s", arg);
+
+  return sopt;
+}
+
 int volatile stop = 0;
 
 void
diff --git a/ping/ping_common.h b/ping/ping_common.h
index fcda0be..68f477c 100644
--- a/ping/ping_common.h
+++ b/ping/ping_common.h
@@ -35,6 +35,11 @@
 #define OPT_QUIET       0x008
 #define OPT_RROUTE      0x010
 #define OPT_VERBOSE     0x020
+#define OPT_IPTIMESTAMP 0x040
+
+#define SOPT_TSONLY     0x001
+#define SOPT_TSADDR     0x002
+#define SOPT_TSPRESPEC  0x004
 
 struct ping_stat
 {
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index cc3445a..9eac495 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -100,6 +100,43 @@ ping_echo (char *hostname)
              "implementation.");
 #endif /* IP_OPTIONS */
     }
+  else if (options & OPT_IPTIMESTAMP)
+    {
+      int type;
+
+      if (suboptions & SOPT_TSPRESPEC)
+#ifdef IPOPT_TS_PRESPEC_RFC791
+	type = IPOPT_TS_PRESPEC_RFC791;
+#else
+	type = IPOPT_TS_PRESPEC;
+#endif
+      else if (suboptions & SOPT_TSADDR)
+	type = IPOPT_TS_TSANDADDR;
+      else
+        type = IPOPT_TS_TSONLY;
+
+#ifdef IP_OPTIONS
+      memset (rspace, 0, sizeof (rspace));
+      rspace[IPOPT_OPTVAL] = IPOPT_TS;
+      rspace[IPOPT_OLEN] = sizeof (rspace);
+      if (type != IPOPT_TS_TSONLY)
+	rspace[IPOPT_OLEN] -= sizeof (n_time);	/* Exsessive part.  */
+      rspace[IPOPT_OFFSET] = IPOPT_MINOFF + 1;
+
+# ifdef IPOPT_POS_OV_FLG
+      rspace[IPOPT_POS_OV_FLG] = type;
+# else
+      rspace[3] = type;
+# endif /* !IPOPT_POS_OV_FLG */
+
+      if (setsockopt (ping->ping_fd, IPPROTO_IP,
+		      IP_OPTIONS, rspace, rspace[IPOPT_OLEN]) < 0)
+        error (EXIT_FAILURE, errno, "setsockopt");
+#else /* !IP_OPTIONS */
+      error (EXIT_FAILURE, 0, "IP timestamp not available in this "
+             "implementation.");
+#endif /* IP_OPTIONS */
+    }
 
   printf ("PING %s (%s): %d data bytes",
 	  ping->ping_hostname,
@@ -397,7 +434,7 @@ void
 print_ip_opt (struct ip *ip, int hlen)
 {
   unsigned char *cp;
-  int i, j, l;
+  int i, j, k, l;
   static int old_rrlen;
   static char old_rr[MAX_IPOPTLEN];
 
@@ -508,6 +545,62 @@ print_ip_opt (struct ip *ip, int hlen)
 	  }
 	break;
 
+      case IPOPT_TS:
+	j = *++cp;	/* len */
+	i = *++cp;	/* ptr */
+	hlen -= 2;
+	if (i > j)
+	  i = j;
+
+	k = *++cp;	/* OV, FL */
+	++cp;		/* Points at first content.  */
+	hlen -= 2;
+
+	printf ("\nTS:");
+	j = 5;		/* First possible slot.  */
+	for (;;)
+	  {
+	    char timestr[16];
+
+	    if ((k & 0x0f) != IPOPT_TS_TSONLY
+		&& ((j / 4) % 2 == 1))	/* find 5, 13, 21, 29 */
+	      {
+		/* IP addresses */
+		struct in_addr ina;
+		char *s;
+
+		ina.s_addr = *((in_addr_t *) cp);
+		printf ("\t%s", s = sinaddr2str (ina));
+		free (s);
+
+		hlen -= sizeof (in_addr_t);
+		cp += sizeof (in_addr_t);
+		j += sizeof (in_addr_t);
+	      }
+	    else
+	      {
+		/* Timestamps */
+		printf ("\t%s ms",
+			ping_cvt_time (timestr, sizeof (timestr),
+					ntohl (*(n_time *) cp)));
+		if (options & OPT_VERBOSE)
+		  printf (" = 0x%08x", ntohl (*(n_time *) cp));
+
+		hlen -= sizeof (n_time);
+		cp += sizeof (n_time);
+		j += sizeof (n_time);
+
+		putchar ('\n');
+	      }
+
+	    if (j >= i)
+	      break;
+	  }
+
+	if (k & 0xf0)
+	  printf ("\t(%u overflowing hosts)", k >> 4);
+	break;
+
       case IPOPT_NOP:
 	printf ("\nNOP");
 	break;
diff --git a/ping/ping_impl.h b/ping/ping_impl.h
index a8ebc36..91b8b87 100644
--- a/ping/ping_impl.h
+++ b/ping/ping_impl.h
@@ -20,6 +20,9 @@
 #define PING_MAX_DATALEN (65535 - MAXIPLEN - MAXICMPLEN)
 
 extern unsigned options;
+#if !USE_IPV6
+extern unsigned int suboptions;
+#endif
 extern PING *ping;
 extern unsigned char *data_buffer;
 extern size_t data_length;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   18 ++++++++++
 doc/inetutils.texi |   11 +++++-
 ping/ping.c        |   29 ++++++++++++++++
 ping/ping_common.h |    5 +++
 ping/ping_echo.c   |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 ping/ping_impl.h   |    3 ++
 6 files changed, 159 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Mon May 14 13:04:29 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1STyhB-0004eP-Uv
	for mharc-commit-inetutils@gnu.org; Mon, 14 May 2012 13:04:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:56737)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STyh6-0004cn-Dt
	for commit-inetutils@gnu.org; Mon, 14 May 2012 13:04:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STyh0-0008Ti-Fh
	for commit-inetutils@gnu.org; Mon, 14 May 2012 13:04:23 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33200)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1STyh0-0008Te-By
	for commit-inetutils@gnu.org; Mon, 14 May 2012 13:04:18 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1STygz-0004gY-BU
	for commit-inetutils@gnu.org; Mon, 14 May 2012 17:04:18 +0000
Date: Mon, 14 May 2012 17:04:18 +0000
Message-Id: <E1STygz-0004gY-BU@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-93-g3fe3430
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d5298c7cf092f160f135d206dece09040e2c2410
X-Git-Newrev: 3fe34309295537e0c494b591d800f272985d2129
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 14 May 2012 17:04:28 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  3fe34309295537e0c494b591d800f272985d2129 (commit)
      from  d5298c7cf092f160f135d206dece09040e2c2410 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=3fe34309295537e0c494b591d800f272985d2129


commit 3fe34309295537e0c494b591d800f272985d2129
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon May 14 18:46:23 2012 +0200

    traceroute: Handle unreachable destinations.

diff --git a/ChangeLog b/ChangeLog
index f2562e9..f73a5eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2012-05-14  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	traceroute: Stop at unreachable destinations.
+
+	* src/traceroute.c (unreach_sign): New variable.
+	(do_try): New local variables RC, TYPE, and CODE.  Let negative
+	return status from trace_read() be abnormal.  Print additional
+	packet failure information for ICMP_DEST_UNREACH.
+	(CAPTURE_LEN): New macro.
+	(trace_read): Set new signature to `(trace_t *, int *, int *)'.
+	Change size of DATA to CAPTURE_LEN.  New variable RC.  Capture
+	type and code of incoming ICMP message.
+	<TRACE_UDP>: Inspect all ICMP_DEST_UNREACH packets.  Calculate
+	port number using length offset in IP header.  Set `stop' for
+	all kinds of ICMP_DEST_UNREACH, and set positive return code,
+	except for ICMP_PORT_UNREACH.
+	<TRACE_ICMP>: Inspect also ICMP_DEST_UNREACH packets.  Check
+	their identity only, not seqno.  Set `stop' also for these,
+	and have them return positive status.  Calculate OLD_ICMP
+	using length offset in IP header.
+
+	* ping/ping_echo.c (ping_echo): Size of RSPACE is MAX_IPOPTLEN.
+
 2012-05-12  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ping: Support IP option Timestamp.
@@ -14,7 +37,7 @@
 	New setup case.
 	(print_ip_opt): New variable K.
 	<IPOPT_TS>: New printout case.
-	* ping/ping_impl.h [!USE_IPV6] (suboptions): New external.
+	* ping/ping_impl.h (suboptions) [!USE_IPV6]: New external.
 
 2012-05-11  Mats Erik Andersson  <gnu@gisladisker.se>
 
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index 9eac495..cd3cdf1 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -67,7 +67,7 @@ int
 ping_echo (char *hostname)
 {
 #ifdef IP_OPTIONS
-  char rspace[3 + 4 * NROUTES + 1];	/* record route space */
+  char rspace[MAX_IPOPTLEN];	/* Maximal IP option space.  */
 #endif
   struct ping_stat ping_stat;
   int status;
diff --git a/src/traceroute.c b/src/traceroute.c
index cc9abb5..1c98d7c 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -30,7 +30,7 @@
 #include <netinet/in.h>
 #include <netinet/ip.h>
 /* #include <netinet/ip_icmp.h> -- Deliberately not including this
-   since the definitions are are using are pulled in by libicmp. */
+   since the definitions in use are being pulled in by libicmp. */
 
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -75,7 +75,7 @@ void trace_init (trace_t * t, const struct sockaddr_in to,
 void trace_inc_ttl (trace_t * t);
 void trace_inc_port (trace_t * t);
 void trace_port (trace_t * t, const unsigned short port);
-int trace_read (trace_t * t);
+int trace_read (trace_t * t, int * type, int * code);
 int trace_write (trace_t * t);
 int trace_udp_sock (trace_t * t);
 int trace_icmp_sock (trace_t * t);
@@ -94,6 +94,11 @@ static char *hostname = NULL;
 char addrstr[INET6_ADDRSTRLEN];
 struct sockaddr_in dest;
 
+/* Cause for destination unreachable reply,
+ * encoded as a single character.
+ */
+const char unreach_sign[NR_ICMP_UNREACH + 2] = "NHPPFS**U**TTXXX";
+
 static enum trace_type opt_type = TRACE_ICMP;
 int opt_port = 33434;
 int opt_max_hops = 64;
@@ -295,10 +300,14 @@ do_try (trace_t * trace, const int hop,
 	{
 	  if (FD_ISSET (fd, &readset))
 	    {
+	      int rc, type, code;
+
 	      triptime = ((double) now.tv_sec) * 1000.0 +
 		((double) now.tv_usec) / 1000.0;
 
-	      if (trace_read (trace))
+	      rc = trace_read (trace, &type, &code);
+
+	      if (rc < 0)
 		{
 		  /* FIXME: printf ("Some error ocurred\n"); */
 		  tries--;
@@ -316,6 +325,10 @@ do_try (trace_t * trace, const int hop,
 		    }
 		  printf (" %.3fms ", triptime);
 
+		  /* Additional messages.  */
+		  if (rc > 0 && type == ICMP_DEST_UNREACH)
+		    printf ("!%c ", unreach_sign[code & 0x0f]);
+
 		}
 	      prev_addr = trace->from.sin_addr.s_addr;
 	    }
@@ -398,11 +411,20 @@ trace_port (trace_t * t, const unsigned short int port)
     t->to.sin_port = port;
 }
 
+/* Returned packet may contain, according to specifications:
+ *
+ *   IP-header + IP-options		(new IP-header)
+ *     + ICMP-header + old-IP-header	(ICMP message)
+ *     + old-IP-options + old-ICMP-header
+ */
+
+#define CAPTURE_LEN (MAXIPLEN + MAXICMPLEN)
+
 int
-trace_read (trace_t * t)
+trace_read (trace_t * t, int * type, int * code)
 {
-  int len;
-  unsigned char data[56];		/* For a TIME_EXCEEDED datagram. */
+  int len, rc = 0;
+  unsigned char data[CAPTURE_LEN];
   struct ip *ip;
   icmphdr_t *ic;
   socklen_t siz;
@@ -418,56 +440,77 @@ trace_read (trace_t * t)
 
   icmp_generic_decode (data, sizeof (data), &ip, &ic);
 
+  /* Pass type and code of incoming packet.  */
+  *type = ic->icmp_type;
+  *code = ic->icmp_code;
+
   switch (t->type)
     {
     case TRACE_UDP:
       {
 	unsigned short *port;
 	if ((ic->icmp_type != ICMP_TIME_EXCEEDED
-	     && ic->icmp_type != ICMP_DEST_UNREACH)
-	    || (ic->icmp_type == ICMP_DEST_UNREACH
-		&& ic->icmp_code != ICMP_PORT_UNREACH))
+	     && ic->icmp_type != ICMP_DEST_UNREACH))
 	  return -1;
 
 	/* check whether it's for us */
         port = (unsigned short *) ((void *) &ic->icmp_ip +
-			sizeof (struct ip) + sizeof (in_port_t));
+			(ic->icmp_ip.ip_hl << 2) + sizeof (in_port_t));
 	if (*port != t->to.sin_port)	/* Network byte order!  */
 	  return -1;
 
-	if (ic->icmp_code == ICMP_PORT_UNREACH)
+	if (ic->icmp_type == ICMP_DEST_UNREACH)
 	  /* FIXME: Ugly hack. */
 	  stop = 1;
+
+	/* Only ICMP_PORT_UNREACH is an expected reply,
+	 * all other denials produce additional information.
+	 */
+	if (ic->icmp_type == ICMP_DEST_UNREACH
+	    && ic->icmp_code != ICMP_PORT_UNREACH)
+	  rc = 1;
       }
       break;
 
     case TRACE_ICMP:
-      if (ic->icmp_type != ICMP_TIME_EXCEEDED
-	  && ic->icmp_type != ICMP_ECHOREPLY)
+      if (! (ic->icmp_type == ICMP_TIME_EXCEEDED
+	     || ic->icmp_type == ICMP_ECHOREPLY
+	     || ic->icmp_type == ICMP_DEST_UNREACH) )
 	return -1;
 
       if (ic->icmp_type == ICMP_ECHOREPLY
 	  && (ntohs (ic->icmp_seq) != seqno
 	      || ntohs (ic->icmp_id) != pid))
 	return -1;
-      else if (ic->icmp_type == ICMP_TIME_EXCEEDED)
+
+      if (ic->icmp_type == ICMP_TIME_EXCEEDED
+	  || ic->icmp_type == ICMP_DEST_UNREACH)
 	{
 	  unsigned short seq, ident;
 	  struct ip *old_ip;
 	  icmphdr_t *old_icmp;
 
 	  old_ip = (struct ip *) &ic->icmp_ip;
-	  old_icmp = (icmphdr_t *) ((void *) old_ip + sizeof (struct ip));
+	  old_icmp = (icmphdr_t *) ((void *) old_ip + (old_ip->ip_hl <<2));
 	  seq = ntohs (old_icmp->icmp_seq);
 	  ident = ntohs (old_icmp->icmp_id);
 
-	  if (seq != seqno || ident != pid)
+	  /* An expired packet tests identity and sequence number,
+	   * whereas an undeliverable packet only checks identity.
+	   */
+	  if (ident != pid
+	      || (ic->icmp_type == ICMP_TIME_EXCEEDED
+		  && seq != seqno))
 	    return -1;
 	}
 
-      if (ip->ip_src.s_addr == dest.sin_addr.s_addr)
+      if (ip->ip_src.s_addr == dest.sin_addr.s_addr
+	  || ic->icmp_type == ICMP_DEST_UNREACH)
 	/* FIXME: Ugly hack. */
 	stop = 1;
+
+      if (ic->icmp_type == ICMP_DEST_UNREACH)
+	rc = 1;
       break;
 
       /* FIXME: Type according to RFC 1393. */
@@ -476,7 +519,7 @@ trace_read (trace_t * t)
       break;
     }
 
-  return 0;
+  return rc;
 }
 
 int

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog        |   25 ++++++++++++++++-
 ping/ping_echo.c |    2 +-
 src/traceroute.c |   79 +++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 86 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Mon May 14 17:39:17 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SU2z7-000243-Iz
	for mharc-commit-inetutils@gnu.org; Mon, 14 May 2012 17:39:17 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41301)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SU2z5-00022x-Ag
	for commit-inetutils@gnu.org; Mon, 14 May 2012 17:39:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SU2z3-0004GA-CG
	for commit-inetutils@gnu.org; Mon, 14 May 2012 17:39:14 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:58025)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SU2z3-0004G1-91
	for commit-inetutils@gnu.org; Mon, 14 May 2012 17:39:13 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SU2z2-000773-6F
	for commit-inetutils@gnu.org; Mon, 14 May 2012 21:39:12 +0000
Date: Mon, 14 May 2012 21:39:12 +0000
Message-Id: <E1SU2z2-000773-6F@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-94-gab1f0a1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3fe34309295537e0c494b591d800f272985d2129
X-Git-Newrev: ab1f0a199cfeb217cadbfccf2c7b9095e97b452d
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 14 May 2012 21:39:16 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  ab1f0a199cfeb217cadbfccf2c7b9095e97b452d (commit)
      from  3fe34309295537e0c494b591d800f272985d2129 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=ab1f0a199cfeb217cadbfccf2c7b9095e97b452d


commit ab1f0a199cfeb217cadbfccf2c7b9095e97b452d
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon May 14 23:32:23 2012 +0200

    Build test binaries early.

diff --git a/ChangeLog b/ChangeLog
index f73a5eb..24ee853 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-05-14  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Build test binaries early.
+
+	* tests/Makefile.am (check_PROGRAMS): Removed variable.
+	(bin_PROGRAMS): New variable.
+	(TESTS): Use `bin_PROGRAMS' instead of `check_PROGRAMS'.
+
+2012-05-14  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	traceroute: Stop at unreachable destinations.
 
 	* src/traceroute.c (unreach_sign): New variable.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e48e6f4..1b3c60a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,9 +21,9 @@ AM_CPPFLAGS = $(iu_INCLUDES)
 
 LDADD = $(iu_LIBRARIES)
 
-check_PROGRAMS = localhost
+bin_PROGRAMS = localhost
 if ENABLE_inetd
-check_PROGRAMS += addrpeek
+bin_PROGRAMS += addrpeek
 endif
 
 dist_check_SCRIPTS =
@@ -68,7 +68,7 @@ if ENABLE_dnsdomainname
 dist_check_SCRIPTS += dnsdomainname.sh
 endif
 
-TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS)
+TESTS = $(bin_PROGRAMS) $(dist_check_SCRIPTS)
 
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |    8 ++++++++
 tests/Makefile.am |    6 +++---
 2 files changed, 11 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Sat May 19 19:22:47 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SVsz1-0006M5-09
	for mharc-commit-inetutils@gnu.org; Sat, 19 May 2012 19:22:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52042)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SVsyw-0006Lf-Vm
	for commit-inetutils@gnu.org; Sat, 19 May 2012 19:22:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SVsyu-0003pi-9A
	for commit-inetutils@gnu.org; Sat, 19 May 2012 19:22:42 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56523)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SVsyu-0003pc-5L
	for commit-inetutils@gnu.org; Sat, 19 May 2012 19:22:40 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SVsys-0006S6-PO
	for commit-inetutils@gnu.org; Sat, 19 May 2012 23:22:39 +0000
Date: Sat, 19 May 2012 23:22:39 +0000
Message-Id: <E1SVsys-0006S6-PO@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-96-g481c0cc
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ab1f0a199cfeb217cadbfccf2c7b9095e97b452d
X-Git-Newrev: 481c0ccc01b8d6d6328dbc85835b689ecc3531fe
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 May 2012 23:22:45 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  481c0ccc01b8d6d6328dbc85835b689ecc3531fe (commit)
       via  cbf7786f49c3f59f9623d89cea40615c4c27f180 (commit)
      from  ab1f0a199cfeb217cadbfccf2c7b9095e97b452d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=481c0ccc01b8d6d6328dbc85835b689ecc3531fe


commit 481c0ccc01b8d6d6328dbc85835b689ecc3531fe
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sun May 20 00:54:02 2012 +0200

    rexecd: Allow getpwnam_r.

diff --git a/ChangeLog b/ChangeLog
index d87fb4c..368af76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-05-20  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexecd: Use getpwnam_r() if available, thus
+	preparing migration to PAM.
+
+	* src/rexecd.c [HAVE_GETPWNAM_R]: Include <xalloc.h>.
+	(doit) [HAVE_GETPWNAM_R]: New variables PWBUF, PWBUFLEN,
+	and PWSTOR.  Dynamically allocate PWBUF.  Call getpwnam_r()
+	with composite check on result.
+
 2012-05-16  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ping, traceroute: Type-of-Service.
diff --git a/src/rexecd.c b/src/rexecd.c
index 6042032..d4d0220 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -83,6 +83,10 @@
 # include <shadow.h>
 #endif
 #include <syslog.h>
+#ifdef HAVE_GETPWNAM_R
+# include <xalloc.h>
+#endif
+
 #include <progname.h>
 #include <argp.h>
 #include <error.h>
@@ -191,7 +195,13 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 {
   char *cmdbuf, *cp, *namep;
   char *user, *pass, *pw_password;
+#ifdef HAVE_GETPWNAM_R
+  char *pwbuf;
+  int pwbuflen;
+  struct passwd *pwd, pwstor;
+#else /* !HAVE_GETPWNAM_R */
   struct passwd *pwd;
+#endif
   char rhost[INET6_ADDRSTRLEN];
   int s, ret;
   in_port_t port;
@@ -200,6 +210,14 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   char buf[BUFSIZ], sig;
   int one = 1;
 
+#ifdef HAVE_GETPWNAM_R
+  pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+  if (pwbuflen <= 0)
+    pwbuflen = 1024;	/* Guessing only.  */
+
+  pwbuf = xmalloc (pwbuflen);
+#endif /* HAVE_GETPWNAM_R */
+
   signal (SIGINT, SIG_DFL);
   signal (SIGQUIT, SIG_DFL);
   signal (SIGTERM, SIG_DFL);
@@ -289,8 +307,13 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 
   setpwent ();
 
+#ifdef HAVE_GETPWNAM_R
+  ret = getpwnam_r (user, &pwstor, pwbuf, pwbuflen, &pwd);
+  if (ret || pwd == NULL)
+#else /* !HAVE_GETPWNAM_R */
   pwd = getpwnam (user);
   if (pwd == NULL)
+#endif /* HAVE_GETPWNAM_R */
     {
       if (logging)
 	syslog (LOG_WARNING, "no user named \"%s\"", user);

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=cbf7786f49c3f59f9623d89cea40615c4c27f180


commit cbf7786f49c3f59f9623d89cea40615c4c27f180
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sun May 20 00:40:39 2012 +0200

    ping, traceroute: Type-of-service.

diff --git a/ChangeLog b/ChangeLog
index 24ee853..d87fb4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-05-16  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ping, traceroute: Type-of-Service.
+
+	* doc/inetutils <ping, traceroute invocation>: Update.
+	* ping/ping.c (tos): New variable.
+	(argp_options): New option `-T/--tos'.
+	(parse_opt): New case `T'.
+	(main): Set socket option IP_TOS.
+	* src/traceroute.c (opt_tos): New variable.
+	(argp_options): New option `-t/--tos'.
+	(parse_opt): New case `t'.
+	(trace_init): New variable FD.  Set socket option IP_TOS.
+
 2012-05-14  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Build test binaries early.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index cc2506b..de7d8f7 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -512,6 +512,7 @@ Send @var{type} packets.  Accepted values are @samp{address},
 @c   -i, --interval=NUMBER      Wait NUMBER seconds between sending each packet
 @c   -n, --numeric              Do not resolve host addresses
 @c   -r, --ignore-routing       Send directly to a host on an attached network
+@c   -T, --tos=NUM              Set type-of-service to NUM
 @c       --ttl=NUMBER           Set specified time-to-live on packet
 
 @table @option
@@ -552,6 +553,12 @@ an error is returned.  This option can be used to ping a local host
 through an interface that has no route through it (e.g., after the
 interface was dropped by @command{routed}).
 
+@item -T @var{num}
+@itemx --tos=@var{num}
+@opindex -T
+@opindex --tos
+Set type-of-service, TOS, to NUM on transmitted packets.
+
 @item --ttl=@var{n}
 @opindex --ttl
 Set the specified number @var{n} as value of time-to-live when
@@ -780,6 +787,12 @@ Send @var{num} probe packets per hop (default: 3).
 @item --resolve-hostnames
 @opindex --resolve-hostnames
 Resolve hostnames.
+
+@item -t @var{num}
+@itemx --tos=@var{num}
+@opindex -t
+@opindex --tos
+Set type-of-service, TOS, to NUM on transmitted packets.
 @end table
 
 @node whois invocation
diff --git a/ping/ping.c b/ping/ping.c
index 6b3f2e7..22f5368 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -65,6 +65,7 @@ size_t data_length = PING_DATALEN;
 unsigned options;
 unsigned int suboptions;
 unsigned long preload = 0;
+int tos = -1;		/* Triggers with non-negative values.  */
 int ttl = 0;
 int timeout = -1;
 int linger = MAXWAIT;
@@ -117,6 +118,7 @@ static struct argp_option argp_options[] = {
   {"numeric", 'n', NULL, 0, "do not resolve host addresses", GRP+1},
   {"ignore-routing", 'r', NULL, 0, "send directly to a host on an attached "
    "network", GRP+1},
+  {"tos", 'T', "NUM", 0, "set type of service (TOS) to NUM", GRP+1},
   {"ttl", ARG_TTL, "N", 0, "specify N as time-to-live", GRP+1},
   {"verbose", 'v', NULL, 0, "verbose output", GRP+1},
   {"timeout", 'w', "N", 0, "stop after N seconds", GRP+1},
@@ -186,18 +188,22 @@ parse_opt (int key, char *arg, struct argp_state *state)
       options |= OPT_QUIET;
       break;
 
-    case 'w':
-      timeout = ping_cvt_number (arg, INT_MAX, 0);
+    case 'T':
+      tos = ping_cvt_number (arg, 255, 1);
       break;
 
-    case 'W':
-      linger = ping_cvt_number (arg, INT_MAX, 0);
+    case 'w':
+      timeout = ping_cvt_number (arg, INT_MAX, 0);
       break;
 
     case 'R':
       options |= OPT_RROUTE;
       break;
 
+    case 'W':
+      linger = ping_cvt_number (arg, INT_MAX, 0);
+      break;
+
     case 'v':
       options |= OPT_VERBOSE;
       break;
@@ -296,6 +302,11 @@ main (int argc, char **argv)
 		    &ttl, sizeof (ttl)) < 0)
       error (0, errno, "setsockopt(IP_TTL)");
 
+  if (tos >= 0)
+    if (setsockopt (ping->ping_fd, IPPROTO_IP, IP_TOS,
+		    &tos, sizeof (tos)) < 0)
+      error (0, errno, "setsockopt(IP_TOS)");
+
   init_data_buffer (patptr, pattern_len);
 
   while (argc--)
diff --git a/src/traceroute.c b/src/traceroute.c
index 1c98d7c..8332167 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -104,6 +104,7 @@ int opt_port = 33434;
 int opt_max_hops = 64;
 static int opt_max_tries = 3;
 int opt_resolve_hostnames = 0;
+int opt_tos = -1;	/* Triggers with non-negative values.  */
 
 const char args_doc[] = "HOST";
 const char doc[] = "Print the route packets trace to network host.";
@@ -122,6 +123,7 @@ static struct argp_option argp_options[] = {
   {"port", 'p', "PORT", 0, "use destination PORT port (default: 33434)",
    GRP+1},
   {"resolve-hostnames", OPT_RESOLVE, NULL, 0, "resolve hostnames", GRP+1},
+  {"tos", 't', "NUM", 0, "set type of service (TOS) to NUM", GRP+1},
   {"tries", 'q', "NUM", 0, "send NUM probe packets per hop (default: 3)",
    GRP+1},
   {"type", 'M', "METHOD", 0, "use METHOD (`icmp' or `udp') for traceroute "
@@ -144,10 +146,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
         error (EXIT_FAILURE, 0, "invalid port number `%s'", arg);
       break;
 
-    case OPT_RESOLVE:
-      opt_resolve_hostnames = 1;
-      break;
-
     case 'q':
       opt_max_tries = (int) strtol (arg, &p, 10);
       if (*p)
@@ -156,6 +154,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
         error (EXIT_FAILURE, 0, "number of tries should be between 1 and 10");
       break;
 
+    case 't':
+      opt_tos = strtoul (arg, &p, 0);
+      if (*p || opt_tos < 0 || opt_tos > 255)
+	error (EXIT_FAILURE, 0, "invalid TOS value `%s'", arg);
+      break;
+
     case 'M':
       if (strcmp (arg, "icmp") == 0)
         opt_type = TRACE_ICMP;
@@ -165,6 +169,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
         argp_error (state, "invalid method");
       break;
 
+    case OPT_RESOLVE:
+      opt_resolve_hostnames = 1;
+      break;
+
     case ARGP_KEY_ARG:
       host_is_given = true;
       hostname = xstrdup(arg);
@@ -354,7 +362,9 @@ void
 trace_init (trace_t * t, const struct sockaddr_in to,
 	    const enum trace_type type)
 {
+  int fd;
   const int *ttlp;
+
   assert (t);
   ttlp = &t->ttl;
 
@@ -399,6 +409,13 @@ trace_init (trace_t * t, const struct sockaddr_in to,
     {
       /* FIXME: type according to RFC 1393 */
     }
+
+  fd = (t->type == TRACE_UDP ? t->udpfd : t->icmpfd);
+
+  if (opt_tos >= 0)
+    if (setsockopt (fd, IPPROTO_IP, IP_TOS,
+		    &opt_tos, sizeof (opt_tos)) < 0)
+      error (0, errno, "setsockopt(IP_TOS)");
 }
 
 void
@@ -534,6 +551,7 @@ trace_write (trace_t * t)
     case TRACE_UDP:
       {
 	char data[] = "SUPERMAN";
+
 	len = sendto (t->udpfd, (char *) data, sizeof (data),
 		      0, (struct sockaddr *) &t->to, sizeof (t->to));
 	if (len < 0)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   24 ++++++++++++++++++++++++
 doc/inetutils.texi |   13 +++++++++++++
 ping/ping.c        |   19 +++++++++++++++----
 src/rexecd.c       |   23 +++++++++++++++++++++++
 src/traceroute.c   |   26 ++++++++++++++++++++++----
 5 files changed, 97 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Mon May 21 12:08:21 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SWV9h-00016k-6V
	for mharc-commit-inetutils@gnu.org; Mon, 21 May 2012 12:08:21 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47886)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SWV9Y-000165-KO
	for commit-inetutils@gnu.org; Mon, 21 May 2012 12:08:19 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SWV9R-0007dl-D3
	for commit-inetutils@gnu.org; Mon, 21 May 2012 12:08:12 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:45826)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SWV9R-0007de-97
	for commit-inetutils@gnu.org; Mon, 21 May 2012 12:08:05 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SWV9P-00024w-Tj
	for commit-inetutils@gnu.org; Mon, 21 May 2012 16:08:04 +0000
Date: Mon, 21 May 2012 16:08:04 +0000
Message-Id: <E1SWV9P-00024w-Tj@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-97-gbc4a16b
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 481c0ccc01b8d6d6328dbc85835b689ecc3531fe
X-Git-Newrev: bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 May 2012 16:08:19 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e (commit)
      from  481c0ccc01b8d6d6328dbc85835b689ecc3531fe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e


commit bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon May 21 12:31:53 2012 +0200

    rexecd: Implement PAM support.

diff --git a/ChangeLog b/ChangeLog
index 368af76..057b10c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2012-05-21  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexecd: Adapt to PAM authentication.
+
+	* src/Makefile.am (rexecd_LDADD): Use $(LIBPAM).
+	* src/rexecd.c [HAVE_SECURITY_PAM_APPL_H]: Include
+	<security/pam_appl.h>.
+	(pam_rc, password_pam, pam_flags, pam_handle, pam_conv)
+	[WITH_PAM]: New variables.
+	(rexec_conv) [WITH_PAM]: New function.
+	(remotehost): New variable, used in environment.
+	(envinit) [!WITH_PAM]: Add `remotehost' to list.
+	(doit) [WITH_PAM]: New variable TOKEN.  Add alternate
+	authentication checks.  Set `pam_rc = PAM_ABORT' where
+	errors are caught.
+	<parent fork>: Set `pam_handle' to NULL, since the child
+	process closes all authentication.
+	(die) [WITH_PAM]: Call pam_end() if PAM is still active.
+	* doc/inetutils.texi (rexecd invocation): Update.
+
 2012-05-20  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd: Use getpwnam_r() if available, thus
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index de7d8f7..2d81a83 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -3399,7 +3399,7 @@ useful in an ``open'' environment.
 @chapter @command{rexecd}: server for @code{rexec}
 @cindex rexecd
 
-@command{rexecd} is the server for the @code{Rexec} routine.  The
+@command{rexecd} is the server for the @code{rexec} routine.  The
 server provides remote execution facilities with authentication based
 on user names and passwords.  It passes error messages and notices
 to the @code{syslog} facility @samp{LOG_DAEMON}.
@@ -3465,6 +3465,9 @@ increased verbosity.  The @code{syslog} facility in use is
 
 @end table
 
+Should @command{rexecd} have been built with PAM support,
+it reads any setting specified for a service named @samp{rexec}.
+
 @section Diagnostics
 
 Except for the last one listed below, all diagnostic messages are
diff --git a/src/Makefile.am b/src/Makefile.am
index a98272b..75d5e6c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,7 +74,7 @@ EXTRA_PROGRAMS += inetd
 
 inetdaemon_PROGRAMS += $(rexecd_BUILD)
 rexecd_SOURCES = rexecd.c
-rexecd_LDADD = $(LDADD) $(LIBCRYPT)
+rexecd_LDADD = $(LDADD) $(LIBCRYPT) $(LIBPAM)
 EXTRA_PROGRAMS += rexecd
 
 inetdaemon_PROGRAMS += $(rlogind_BUILD)
diff --git a/src/rexecd.c b/src/rexecd.c
index d4d0220..0236a5d 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -47,8 +47,17 @@
  * SUCH DAMAGE.
  */
 
-/* TODO: Implement PAM support as `rexec' service.
- *       Pending with Mats Erik Andersson.
+/* Implementation of PAM support for a service `rexec'
+ * was done by Mats Erik Andersson.
+ *
+ * Simple PAM configuration:
+ *
+ *   rexec auth     requisite  pam_nologin.so
+ *   rexec auth     required   pam_unix.so
+ *   rexec account  required   pam_unix.so
+ *   rexec account  required   pam_time.so
+ *   rexec session  required   pam_unix.so
+ *   rexec password required   pam_deny.so
  */
 
 #include <config.h>
@@ -83,6 +92,9 @@
 # include <shadow.h>
 #endif
 #include <syslog.h>
+#ifdef HAVE_SECURITY_PAM_APPL_H
+# include <security/pam_appl.h>
+#endif
 #ifdef HAVE_GETPWNAM_R
 # include <xalloc.h>
 #endif
@@ -95,6 +107,17 @@
 void die (int code, const char *fmt, ...);
 int doit (int f, struct sockaddr *fromp, socklen_t fromlen);
 
+#ifdef WITH_PAM
+static int pam_rc = PAM_AUTH_ERR;	/* doit() and die() */
+static char *password_pam = NULL;	/* doit() and rexec_conv() */
+static int pam_flags = PAM_SILENT | PAM_DISALLOW_NULL_AUTHTOK;
+
+static pam_handle_t *pam_handle = NULL;		/* doit() and die() */
+static int rexec_conv (int, const struct pam_message **,
+		       struct pam_response **, void *);
+static struct pam_conv pam_conv = { rexec_conv, NULL };
+#endif /* WITH_PAM */
+
 static int logging = 0;
 
 static struct argp_option options[] = {
@@ -173,7 +196,11 @@ char logname[32 + sizeof ("LOGNAME=")] = "LOGNAME=";	/* Identical to USER.  */
 char homedir[256 + sizeof ("HOME=")] = "HOME=";
 char shell[256 + sizeof ("SHELL=")] = "SHELL=";
 char path[sizeof (PATH_DEFPATH) + sizeof ("PATH=")] = "PATH=";
-char *envinit[] = { homedir, shell, path, username, logname, NULL };
+char remotehost[128 + sizeof ("RHOST=")] = "RHOST=";
+#ifndef WITH_PAM
+char *envinit[] = { homedir, shell, path, username,
+		    logname, remotehost, NULL };
+#endif
 extern char **environ;
 
 char *getstr (const char *);
@@ -195,6 +222,9 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 {
   char *cmdbuf, *cp, *namep;
   char *user, *pass, *pw_password;
+#ifdef WITH_PAM
+  const void *token;
+#endif
 #ifdef HAVE_GETPWNAM_R
   char *pwbuf;
   int pwbuflen;
@@ -322,6 +352,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 
   endpwent ();
 
+#if !WITH_PAM
   /* Last need of elevated privilege.  */
   pw_password = get_user_password (pwd);
   if (*pw_password != '\0')
@@ -334,6 +365,61 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 	  die (EXIT_FAILURE, "Password incorrect.");
 	}
     }
+#else /* WITH_PAM */
+  /* Failure at this stage should not disclose server side causes,
+   * but only fail almost silently.  Use "Try again" for now.
+   */
+  password_pam = pass;		/* Needed by pam_conv().  */
+
+  pam_rc = pam_start ("rexec", user, &pam_conv, &pam_handle);
+  if (pam_rc != PAM_SUCCESS)
+    die (EXIT_FAILURE, "Try again.");
+
+  pam_rc = pam_set_item (pam_handle, PAM_RHOST, rhost);
+  if (pam_rc != PAM_SUCCESS)
+    die (EXIT_FAILURE, "Try again.");
+
+  pam_rc = pam_authenticate (pam_handle, pam_flags);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_ABORT:
+	  /* This is potentially severe.  No communication!  */
+	  pam_end (pam_handle, pam_rc);
+	  exit (EXIT_FAILURE);
+	  break;
+	case PAM_AUTHINFO_UNAVAIL:
+	case PAM_CRED_INSUFFICIENT:
+	case PAM_USER_UNKNOWN:
+	  die (EXIT_FAILURE, "Login incorrect.");
+	  break;
+	case PAM_AUTH_ERR:
+	case PAM_MAXTRIES:
+	default:
+	  die (EXIT_FAILURE, "Password incorrect.");
+	  break;
+	}
+    }
+
+  pam_rc = pam_acct_mgmt (pam_handle, pam_flags);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_NEW_AUTHTOK_REQD:
+	case PAM_PERM_DENIED:
+	  die (EXIT_FAILURE, "Password incorrect.");
+	  break;
+	case PAM_ACCT_EXPIRED:
+	case PAM_AUTH_ERR:
+	case PAM_USER_UNKNOWN:
+	default:
+	  die (EXIT_FAILURE, "Login incorrect.");
+	  break;
+	}
+    }
+#endif /* WITH_PAM */
 
   /* Step down from superuser personality.
    *
@@ -343,6 +429,9 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
    */
   if (setgid ((gid_t) pwd->pw_gid) < 0)
     {
+#ifdef WITH_PAM
+      pam_rc = PAM_ABORT;
+#endif
       syslog (LOG_DEBUG, "setgid(gid = %d): %m", pwd->pw_gid);
       die (EXIT_FAILURE, "Failed group protections.");
     }
@@ -350,14 +439,30 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 #ifdef HAVE_INITGROUPS
   if (initgroups (pwd->pw_name, pwd->pw_gid) < 0)
     {
+# ifdef WITH_PAM
+      pam_rc = PAM_ABORT;
+# endif
       syslog (LOG_DEBUG, "initgroups(%s, %s): %m",
 	      pwd->pw_name, pwd->pw_gid);
       die (EXIT_FAILURE, "Failed group protections.");
     }
 #endif
 
+#ifdef WITH_PAM
+  pam_rc = pam_setcred(pam_handle, PAM_ESTABLISH_CRED);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_ERR, "pam_setcred: %s",
+	      pam_strerror (pam_handle, pam_rc));
+      pam_rc = PAM_SUCCESS;	/* Only report the above anomaly.  */
+    }
+#endif /* WITH_PAM */
+
   if (setuid ((uid_t) pwd->pw_uid) < 0)
     {
+#ifdef WITH_PAM
+      pam_rc = PAM_ABORT;
+#endif
       syslog (LOG_DEBUG, "setuid(uid = %d): %m", pwd->pw_uid);
       die (EXIT_FAILURE, "Failed user identity.");
     }
@@ -370,11 +475,22 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 	{
 	  if (logging)
 	    syslog (LOG_ERR, "forking for \"%s\": %m", user);
+#ifdef WITH_PAM
+	  pam_rc = PAM_ABORT;
+#endif
 	  die (EXIT_FAILURE, "Try again.");
 	}
 
       if (pid)
 	{
+#ifdef WITH_PAM
+	  /* This process steps down from PAM now,
+	   * the child continues communication.  */
+	  pam_handle = NULL;
+# ifdef PAM_DATA_SILENT
+	  pam_rc |= PAM_DATA_SILENT;
+# endif
+#endif /* WITH_PAM */
 	  close (STDIN_FILENO);
 	  close (STDOUT_FILENO);
 	  close (STDERR_FILENO);
@@ -432,15 +548,58 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
     {
       if (logging)
 	syslog (LOG_NOTICE, "\"%s\" uses invalid \"%s\"", user, pwd->pw_dir);
+#ifdef WITH_PAM
+      pam_rc = PAM_ABORT;
+#endif
       die (EXIT_FAILURE, "No remote directory.");
     }
 
+#ifdef WITH_PAM
+  /* Refresh knowledge of user, which might have been
+   * remapped by the PAM stack during conversation.
+   */
+  pam_rc = pam_get_item (pam_handle, PAM_USER, &token);
+  if (pam_rc != PAM_SUCCESS)
+    die (EXIT_FAILURE, "Try again.");
+
+# ifdef HAVE_GETPWNAM_R
+  ret = getpwnam_r (user, &pwstor, pwbuf, pwbuflen, &pwd);
+  if (ret || pwd == NULL)
+# else /* !HAVE_GETPWNAM_R */
+  pwd = getpwnam (user);
+  if (pwd == NULL)
+# endif /* HAVE_GETPWNAM_R */
+    {
+      syslog (LOG_ERR, "no user named \"%s\"", user);
+      die (EXIT_FAILURE, "Login incorrect.");
+    }
+#endif /* WITH_PAM */
+
   strcat (path, PATH_DEFPATH);
-  environ = envinit;
   strncat (homedir, pwd->pw_dir, sizeof (homedir) - sizeof ("HOME=") - 1);
   strncat (shell, pwd->pw_shell, sizeof (shell) - sizeof ("SHELL=") - 1);
   strncat (username, pwd->pw_name, sizeof (username) - sizeof ("USER=") - 1);
   strncat (logname, pwd->pw_name, sizeof (logname) - sizeof ("LOGNAME=") - 1);
+  strncat (remotehost, rhost, sizeof (remotehost) - sizeof ("RHOST=") - 1);
+
+#ifdef WITH_PAM
+  if (pam_getenv (pam_handle, "PATH") == NULL)
+    (void) pam_putenv (pam_handle, path);
+  if (pam_getenv (pam_handle, "HOME") == NULL)
+    (void) pam_putenv (pam_handle, homedir);
+  if (pam_getenv (pam_handle, "SHELL") == NULL)
+    (void) pam_putenv (pam_handle, shell);
+  if (pam_getenv (pam_handle, "USER") == NULL)
+    (void) pam_putenv (pam_handle, username);
+  if (pam_getenv (pam_handle, "LOGNAME") == NULL)
+    (void) pam_putenv (pam_handle, logname);
+  if (pam_getenv (pam_handle, "RHOST") == NULL)
+    (void) pam_putenv (pam_handle, remotehost);
+
+  environ = pam_getenvlist (pam_handle);
+#else /* !WITH_PAM */
+  environ = envinit;
+#endif /* !WITH_PAM */
 
   if (*pwd->pw_shell == '\0')
     pwd->pw_shell = PATH_BSHELL;
@@ -482,6 +641,10 @@ die (int code, const char *fmt, ...)
     n = sizeof buf - 1;
   buf[n++] = '\n';
   write (STDERR_FILENO, buf, n);
+#ifdef WITH_PAM
+  if (pam_handle != NULL)
+    pam_end (pam_handle, pam_rc);
+#endif
   exit (code);
 }
 
@@ -522,3 +685,46 @@ getstr (const char *err)
 
   return buf;
 }
+
+#ifdef WITH_PAM
+/* Call back function for passing user's password
+ * to any PAM module requesting this information.
+ */
+static int
+rexec_conv (int num, const struct pam_message **pam_msg,
+	    struct pam_response **pam_resp, void *data)
+{
+  struct pam_response *resp;
+
+  /* Reject composite call-backs.  */
+  if (num <= 0 || num > 1)
+    return PAM_CONV_ERR;
+
+  /* We only accept password reporting.  */
+  if (pam_msg[0]->msg_style != PAM_PROMPT_ECHO_OFF)
+    return PAM_CONV_ERR;
+
+  /* Allocate a single response structure,
+   * as we are ignoring composite calls.
+   *
+   * This is an external call-back, so we check
+   * for successful allocation ourselves.
+   */
+  resp = malloc (sizeof (*resp));
+  if (resp == NULL)
+    return PAM_BUF_ERR;
+
+  /* Prepare response to a single PAM_PROMPT_ECHO_OFF.  */
+  resp->resp_retcode = 0;
+  resp->resp = strdup (password_pam);
+  if (resp->resp == NULL)
+    {
+      free (resp);
+      return PAM_BUF_ERR;
+    }
+
+  *pam_resp = resp;
+
+  return PAM_SUCCESS;
+}
+#endif /* WITH_PAM */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   20 +++++
 doc/inetutils.texi |    5 +-
 src/Makefile.am    |    2 +-
 src/rexecd.c       |  214 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 235 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu May 24 15:17:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SXdXI-0007bD-Ps
	for mharc-commit-inetutils@gnu.org; Thu, 24 May 2012 15:17:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:50596)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXdXF-0007aQ-TP
	for commit-inetutils@gnu.org; Thu, 24 May 2012 15:17:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXdXC-0007XH-U8
	for commit-inetutils@gnu.org; Thu, 24 May 2012 15:17:21 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56633)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXdXC-0007XC-Qm
	for commit-inetutils@gnu.org; Thu, 24 May 2012 15:17:18 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SXdXA-0003gX-Qo
	for commit-inetutils@gnu.org; Thu, 24 May 2012 19:17:18 +0000
Date: Thu, 24 May 2012 19:17:18 +0000
Message-Id: <E1SXdXA-0003gX-Qo@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-98-gcc49b1f
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e
X-Git-Newrev: cc49b1f9c3c7ce696684375f298adab0825f553f
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 May 2012 19:17:23 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  cc49b1f9c3c7ce696684375f298adab0825f553f (commit)
      from  bc4a16bcd250c497340ac7d22c3d8bd4c2a0531e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=cc49b1f9c3c7ce696684375f298adab0825f553f


commit cc49b1f9c3c7ce696684375f298adab0825f553f
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 24 21:17:49 2012 +0200

    ftp: Large file offsets.
    
    Integer truncation corrupts offset data.

diff --git a/ChangeLog b/ChangeLog
index 057b10c..d141eba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-05-24  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftp: Large file support.  The implementation
+	has been truncating offset values.
+
+	* ftp/cmds.c (restart): Convert `restart_point' using atoll().
+	Use a format string `%jd' and cast as `intmax_t'.
+	* ftp/ftp.c (sendrequest): Remove cast of `restart_point'
+	as `long'. Use format string `%jd' and cast as `intmax_t'.
+	(recvrequest): Likewise.  Variables I and N must be `off_t'
+	for computations with `restart_point'.
+
 2012-05-21  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd: Adapt to PAM authentication.
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 0fee735..30c837c 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -2376,10 +2376,8 @@ restart (int argc, char **argv)
     printf ("restart: offset not specified\n");
   else
     {
-      restart_point = atol (argv[1]);
-      printf ((sizeof (restart_point) > sizeof (long)
-	       ? "restarting at %lld. %s\n"
-	       : "restarting at %ld. %s\n"), restart_point,
+      restart_point = atoll (argv[1]);
+      printf ("restarting at %jd. %s\n", (intmax_t) restart_point,
 	      "execute get, put or append to initiate transfer");
     }
 }
diff --git a/ftp/ftp.c b/ftp/ftp.c
index 4f19563..ab13982 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -637,7 +637,7 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
       switch (curtype)
 	{
 	case TYPE_A:
-	  rc = fseeko (fin, (long) restart_point, SEEK_SET);
+	  rc = fseeko (fin, restart_point, SEEK_SET);
 	  break;
 	case TYPE_I:
 	case TYPE_L:
@@ -652,7 +652,7 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
 	    (*closefunc) (fin);
 	  return;
 	}
-      if (command ("REST %ld", (long) restart_point) != CONTINUE)
+      if (command ("REST %jd", (intmax_t) restart_point) != CONTINUE)
 	{
 	  restart_point = 0;
 	  if (closefunc != NULL)
@@ -887,7 +887,7 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
   if (setjmp (recvabort))
     goto abort;
   if (is_retr && restart_point &&
-      command ("REST %ld", (long) restart_point) != CONTINUE)
+      command ("REST %jd", (intmax_t) restart_point) != CONTINUE)
     return;
   if (remote)
     {
@@ -998,7 +998,8 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
     case TYPE_A:
       if (restart_point)
 	{
-	  int i, n, ch;
+	  off_t i, n;
+	  int ch;
 
 	  if (fseeko (fout, 0L, SEEK_SET) < 0)
 	    goto done;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog  |   12 ++++++++++++
 ftp/cmds.c |    6 ++----
 ftp/ftp.c  |    9 +++++----
 3 files changed, 19 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu May 24 17:54:58 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SXfzm-0007jP-4N
	for mharc-commit-inetutils@gnu.org; Thu, 24 May 2012 17:54:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49241)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXfzj-0007j2-Sc
	for commit-inetutils@gnu.org; Thu, 24 May 2012 17:54:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXfzh-0007je-Nc
	for commit-inetutils@gnu.org; Thu, 24 May 2012 17:54:55 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:41620)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SXfzh-0007jS-KR
	for commit-inetutils@gnu.org; Thu, 24 May 2012 17:54:53 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SXfze-0004IE-Lp
	for commit-inetutils@gnu.org; Thu, 24 May 2012 21:54:51 +0000
Date: Thu, 24 May 2012 21:54:51 +0000
Message-Id: <E1SXfze-0004IE-Lp@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-99-g15320eb
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: cc49b1f9c3c7ce696684375f298adab0825f553f
X-Git-Newrev: 15320ebe213fc558691878f26eb2f2a655f2e948
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 May 2012 21:54:57 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  15320ebe213fc558691878f26eb2f2a655f2e948 (commit)
      from  cc49b1f9c3c7ce696684375f298adab0825f553f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=15320ebe213fc558691878f26eb2f2a655f2e948


commit 15320ebe213fc558691878f26eb2f2a655f2e948
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 24 23:50:07 2012 +0200

    ftp: Missing inclusion.

diff --git a/ChangeLog b/ChangeLog
index d141eba..1dbbe4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-05-24  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Portability to FreeBSD.
+
+	* ftp/cmds.c: Include <stdint.h> for `intmax_t'.
+	* ftp/ftp.c: Likewise.
+
+2012-05-24  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	ftp: Large file support.  The implementation
 	has been truncating offset values.
 
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 30c837c..c163e37 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -69,6 +69,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>	/* intmax_t */
 #include <string.h>
 #include <sys/time.h>
 #include <time.h>
diff --git a/ftp/ftp.c b/ftp/ftp.c
index ab13982..48c21ba 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -77,6 +77,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>	/* intmax_t */
 #include <string.h>
 #include <unistd.h>
 #include <stdarg.h>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog  |    7 +++++++
 ftp/cmds.c |    1 +
 ftp/ftp.c  |    1 +
 3 files changed, 9 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri May 25 19:56:02 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SY4MU-0006tI-HW
	for mharc-commit-inetutils@gnu.org; Fri, 25 May 2012 19:56:02 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38541)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SY4MR-0006si-3R
	for commit-inetutils@gnu.org; Fri, 25 May 2012 19:56:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SY4MP-0002MX-3P
	for commit-inetutils@gnu.org; Fri, 25 May 2012 19:55:58 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:40578)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SY4MO-0002MD-W1
	for commit-inetutils@gnu.org; Fri, 25 May 2012 19:55:57 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SY4MM-0004es-G7
	for commit-inetutils@gnu.org; Fri, 25 May 2012 23:55:55 +0000
Date: Fri, 25 May 2012 23:55:55 +0000
Message-Id: <E1SY4MM-0004es-G7@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-100-g02389aa
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 15320ebe213fc558691878f26eb2f2a655f2e948
X-Git-Newrev: 02389aa8517089cac8a9635dfe52bcfc96cb75eb
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 May 2012 23:56:00 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  02389aa8517089cac8a9635dfe52bcfc96cb75eb (commit)
      from  15320ebe213fc558691878f26eb2f2a655f2e948 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=02389aa8517089cac8a9635dfe52bcfc96cb75eb


commit 02389aa8517089cac8a9635dfe52bcfc96cb75eb
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat May 26 01:43:00 2012 +0200

    ftp: Large file's accounting.

diff --git a/ChangeLog b/ChangeLog
index 1dbbe4f..93b8a5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-05-26  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftp: Reporting and accounting of large files.
+
+	* ftp/extern.h (ptransfer): New signature
+	`(char *, long long, struct timeval *, struct timeval *)'.
+	* ftp/ftp.c (sendrequest, recvrequest): New type `long long'
+	for BYTES and LOCAL_HASHBYTES.
+	(ptransfer): New type `long long' for BS.  New format string
+	`%lld' for byte counter and byte rate.
+
 2012-05-24  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Portability to FreeBSD.
diff --git a/ftp/extern.h b/ftp/extern.h
index c10e18d..9117eb8 100644
--- a/ftp/extern.h
+++ b/ftp/extern.h
@@ -104,7 +104,7 @@ void proxabort (int sig);
 void proxtrans (char *, char *, char *);
 void psabort (int sig);
 void pswitch (int);
-void ptransfer (char *, long, struct timeval *, struct timeval *);
+void ptransfer (char *, long long, struct timeval *, struct timeval *);
 void put (int, char **);
 void pwd (int, char **);
 void quit (int, char **);
diff --git a/ftp/ftp.c b/ftp/ftp.c
index 48c21ba..b662259 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -541,7 +541,7 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
   FILE *fin, *dout = 0, *popen (const char *, const char *);
   int (*closefunc) (FILE *);
   sighandler_t oldintr, oldintp;
-  long bytes = 0, local_hashbytes = hashbytes;
+  long long bytes = 0, local_hashbytes = hashbytes;
   char *lmode, buf[BUFSIZ], *bufp;
 
   if (verbose && printnames)
@@ -826,7 +826,7 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
   int c, d, is_retr, tcrflag, bare_lfs = 0, blksize;
   static int bufsize = 0;
   static char *buf;
-  long bytes = 0, local_hashbytes = hashbytes;
+  long long bytes = 0, local_hashbytes = hashbytes;
   struct timeval start, stop;
 
   is_retr = strcmp (cmd, "RETR") == 0;
@@ -1483,11 +1483,12 @@ dataconn (char *lmode)
 }
 
 void
-ptransfer (char *direction, long int bytes, struct timeval *t0, struct timeval *t1)
+ptransfer (char *direction, long long int bytes,
+	   struct timeval *t0, struct timeval *t1)
 {
   struct timeval td;
   float s;
-  long bs;
+  long long bs;
 
   if (verbose)
     {
@@ -1495,7 +1496,7 @@ ptransfer (char *direction, long int bytes, struct timeval *t0, struct timeval *
       s = td.tv_sec + (td.tv_usec / 1000000.);
 #define nz(x)	((x) == 0 ? 1 : (x))
       bs = bytes / nz (s);
-      printf ("%ld bytes %s in %.3g seconds (%ld bytes/s)\n",
+      printf ("%lld bytes %s in %.3g seconds (%lld bytes/s)\n",
 	      bytes, direction, s, bs);
     }
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog    |   11 +++++++++++
 ftp/extern.h |    2 +-
 ftp/ftp.c    |   11 ++++++-----
 3 files changed, 18 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Sat May 26 17:59:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SYP1g-00085n-If
	for mharc-commit-inetutils@gnu.org; Sat, 26 May 2012 17:59:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41258)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SYP1d-00085T-Bm
	for commit-inetutils@gnu.org; Sat, 26 May 2012 17:59:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SYP1a-0000da-Rx
	for commit-inetutils@gnu.org; Sat, 26 May 2012 17:59:52 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:52491)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SYP1a-0000dU-OH
	for commit-inetutils@gnu.org; Sat, 26 May 2012 17:59:50 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SYP1Y-0002xK-SW
	for commit-inetutils@gnu.org; Sat, 26 May 2012 21:59:49 +0000
Date: Sat, 26 May 2012 21:59:49 +0000
Message-Id: <E1SYP1Y-0002xK-SW@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-101-g0a66bdd
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 02389aa8517089cac8a9635dfe52bcfc96cb75eb
X-Git-Newrev: 0a66bdd5a5318bd9a2a6861e423040ed99cb069e
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 26 May 2012 21:59:55 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  0a66bdd5a5318bd9a2a6861e423040ed99cb069e (commit)
      from  02389aa8517089cac8a9635dfe52bcfc96cb75eb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=0a66bdd5a5318bd9a2a6861e423040ed99cb069e


commit 0a66bdd5a5318bd9a2a6861e423040ed99cb069e
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat May 26 23:03:48 2012 +0200

    More FTP test cases.

diff --git a/ChangeLog b/ChangeLog
index 93b8a5c..528339e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2012-05-26  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	* tests/ftp-localhost.sh (do_transfer, GETME, PUTME):
+	New variables.  Environmental TRANSFERTEST sets do_transfer.
+	(posttesting): Remove file `$FTPHOME/$PUTME' if $do_transfer
+	is true and file exists.
+	(test_report): Lessen verbosity by printing exchange data
+	only if $VERBOSE is non-empty.
+	[do_transfer]: Execute transmission tests.  These execute
+	an additional `put' for selected addressing and modes.
+
+2012-05-26  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	ftp: Reporting and accounting of large files.
 
 	* ftp/extern.h (ptransfer): New signature
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 684c717..41a68b1 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -39,6 +39,8 @@
 #
 # Wanted:  * standalone-mode
 #          * underprivileged mode.
+#
+# FIXME: Resolve the hard coded dependency on anonymous mode.
 
 # Address mapping IPv4-to-IPv6 is not uniform an all platforms,
 # thus separately using `tcp4' and `tcp6' for streams in `inetd.conf'.
@@ -56,6 +58,16 @@ TARGET=${TARGET:-127.0.0.1}
 TARGET6=${TARGET6:-::1}
 TARGET46=${TARGET46:-::ffff:127.0.0.1}
 
+# Extended transmission testing.
+# This puts contents into $FTPHOME,
+# and is therefore not active by default.
+do_transfer=false
+test "${TRANSFERTEST+yes}" = "yes" && do_transfer=true
+
+# Files used in transmission tests.
+GETME=getme.$$
+PUTME=putme.$$
+
 # Portability fix for SVR4
 PWD="${PWD:-`pwd`}"
 
@@ -156,6 +168,9 @@ posttesting () {
 	&& { kill "`cat $TMPDIR/inetd.pid`" \
 	     || kill -9 "`cat $TMPDIR/inetd.pid`"; }
     test -n "$TMPDIR" && test -d "$TMPDIR" && rm -rf "$TMPDIR"
+    $do_transfer && test -n "$FTPHOME" \
+	&& test -f "$FTPHOME/$PUTME" && rm -f "$FTPHOME/$PUTME" \
+	|| true
 }
 
 trap posttesting 0 1 2 3 15
@@ -215,6 +230,9 @@ fi
 
 chmod 600 "$TMPDIR/.netrc"
 
+# Some simple, but variable content.
+ls -l > "$TMPDIR/$GETME"
+
 $INETD --pidfile="$TMPDIR/inetd.pid" "$TMPDIR/inetd.conf" ||
     {
 	echo 'Not able to start Inetd.  Skipping test.' >&2
@@ -240,7 +258,7 @@ test -r "$TMPDIR/inetd.pid" ||
 # test_report  errno output_file hint_msg
 #
 test_report () {
-    test -z "${VERBOSE+yes}" || cat "$2"
+    test -z "${VERBOSE}" || cat "$2"
 
     if [ $1 != 0 ]; then
 	echo "Running '$FTP' failed with errno $1." >&2
@@ -276,22 +294,48 @@ echo "PASV to $TARGET (IPv4) using inetd."
 cat <<STOP |
 rstatus
 dir
+`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 STOP
 HOME=$TMPDIR $FTP "$TARGET" $PORT -4 -v -p -t >$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "PASV/$TARGET"
 
+$do_transfer && \
+    if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	date "+%s" >> "$TMPDIR/$GETME"
+    else
+	echo >&2 'Binary transfer failed.'
+	exit 1
+    fi
+
 # Test an active connection: PORT and IPv4.
 #
 echo "PORT to $TARGET (IPv4) using inetd."
 cat <<STOP |
 rstatus
 dir
+`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 STOP
 HOME=$TMPDIR $FTP "$TARGET" $PORT -4 -v -t >$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "PORT/$TARGET"
 
+$do_transfer && \
+    if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	date "+%s" >> "$TMPDIR/$GETME"
+    else
+	echo >&2 'Binary transfer failed.'
+	exit 1
+    fi
+
 # Test a passive connection: EPSV and IPv4.
 #
 echo "EPSV to $TARGET (IPv4) using inetd."
@@ -311,11 +355,24 @@ cat <<STOP |
 rstatus
 epsv4
 dir
+`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 STOP
 HOME=$TMPDIR $FTP "$TARGET" $PORT -4 -v -t >$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "EPRT/$TARGET"
 
+$do_transfer && \
+    if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	date "+%s" >> "$TMPDIR/$GETME"
+    else
+	echo >&2 'Binary transfer failed.'
+	exit 1
+    fi
+
 # Test a passive connection: EPSV and IPv6.
 #
 echo "EPSV to $TARGET6 (IPv6) using inetd."
@@ -333,11 +390,24 @@ echo "EPRT to $TARGET6 (IPv6) using inetd."
 cat <<STOP |
 rstatus
 dir
+`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 STOP
 HOME=$TMPDIR $FTP "$TARGET6" $PORT -6 -v -t >$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "EPRT/$TARGET6"
 
+$do_transfer && \
+    if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	date "+%s" >> "$TMPDIR/$GETME"
+    else
+	echo >&2 'Binary transfer failed.'
+	exit 1
+    fi
+
 # Availability of IPv4-mapped IPv6 addresses.
 #
 # These are impossible on OpenBSD, so a flexible test
@@ -398,21 +468,46 @@ if $have_address_mapping && test -n "$TARGET46" ; then
     cat <<-STOP |
 	rstatus
 	dir
+	`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 	STOP
     HOME=$TMPDIR $FTP "$TARGET46" $PORT -6 -v -p -t >$TMPDIR/ftp.stdout 2>&1
 
     test_report $? "$TMPDIR/ftp.stdout" "EPSV/$TARGET46"
 
+    $do_transfer && \
+	if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	    test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	    date "+%s" >> "$TMPDIR/$GETME"
+	else
+	    echo >&2 'Binary transfer failed.'
+	    exit 1
+	fi
+
     # Test an active connection: EPRT and IPvIPv6.
     #
     echo "EPRT to $TARGET46 (IPv4-as-IPv6) using inetd."
     cat <<-STOP |
 	rstatus
 	dir
+	`$do_transfer && echo "\
+lcd $TMPDIR
+image
+put $GETME $PUTME"`
 	STOP
     HOME=$TMPDIR $FTP "$TARGET46" $PORT -6 -v -t >$TMPDIR/ftp.stdout 2>&1
 
     test_report $? "$TMPDIR/ftp.stdout" "EPRT/$TARGET46"
+
+    $do_transfer && \
+	if cmp -s "$TMPDIR/$GETME" "$FTPHOME/$PUTME"; then
+	    test "${VERBOSE+yes}" && echo >&2 'Binary transfer succeeded.'
+	else
+	    echo >&2 'Binary transfer failed.'
+	    exit 1
+	fi
 else
     # The IPv4-as-IPv6 tests were not performed.
     echo 'Skipping two tests of IPv4 mapped as IPv6.'

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |   11 +++++
 tests/ftp-localhost.sh |   97 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed May 30 17:11:34 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SZqB4-00045z-1c
	for mharc-commit-inetutils@gnu.org; Wed, 30 May 2012 17:11:34 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44512)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZqB1-00045P-DN
	for commit-inetutils@gnu.org; Wed, 30 May 2012 17:11:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZqAy-0003zD-GW
	for commit-inetutils@gnu.org; Wed, 30 May 2012 17:11:30 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33262)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZqAy-0003xu-CI
	for commit-inetutils@gnu.org; Wed, 30 May 2012 17:11:28 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SZqAv-0008U1-0a
	for commit-inetutils@gnu.org; Wed, 30 May 2012 21:11:26 +0000
Date: Wed, 30 May 2012 21:11:25 +0000
Message-Id: <E1SZqAv-0008U1-0a@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-103-g2aea8c1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 0a66bdd5a5318bd9a2a6861e423040ed99cb069e
X-Git-Newrev: 2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 May 2012 21:11:33 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb (commit)
       via  b0a461970ae42ede3460ac3dd58f73e0fd8329b4 (commit)
      from  0a66bdd5a5318bd9a2a6861e423040ed99cb069e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb


commit 2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed May 30 12:36:56 2012 +0200

    Incomplete variadic printing.
    
    Missing va_start() and va_end() cause crashes.

diff --git a/ChangeLog b/ChangeLog
index d7360ff..faabde2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+ 2012-05-30  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Incomplete coding of variadic printing.  Each such command
+	consumes the pointer, leaving it in an undefined state.
+	Some 64-bit systems are sensitive to these mistakes.
+
+	* ftpd/ftpd.c (reply, lreply): Missing va_end(). Give each
+	vprintf() and vsyslog() a separate pair va_start()/va_end().
+	* src/rcp.c (run_err): Likewise for vfprintf().
+	* src/rshd.c (rshd_error): Missing va_end().
+
 2012-05-30  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Allow 64-bit offsets and file sizes.  Restrict
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index ba5560e..b33c246 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -1568,12 +1568,15 @@ reply (int n, const char *fmt, ...)
   va_start (ap, fmt);
   printf ("%d ", n);
   vprintf (fmt, ap);
+  va_end (ap);
   printf ("\r\n");
   fflush (stdout);
   if (debug)
     {
       syslog (LOG_DEBUG, "<--- %d ", n);
+      va_start (ap, fmt);
       vsyslog (LOG_DEBUG, fmt, ap);
+      va_end (ap);
     }
 }
 
@@ -1584,12 +1587,15 @@ lreply (int n, const char *fmt, ...)
   va_start (ap, fmt);
   printf ("%d- ", n);
   vprintf (fmt, ap);
+  va_end (ap);
   printf ("\r\n");
   fflush (stdout);
   if (debug)
     {
       syslog (LOG_DEBUG, "<--- %d- ", n);
+      va_start (ap, fmt);
       vsyslog (LOG_DEBUG, fmt, ap);
+      va_end (ap);
     }
 }
 
diff --git a/src/rcp.c b/src/rcp.c
index cd0c25b..3907c53 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -1111,17 +1111,18 @@ run_err (const char *fmt, ...)
   fprintf (fp, "%c", 0x01);
   fprintf (fp, "rcp: ");
   vfprintf (fp, fmt, ap);
+  va_end (ap);
   fprintf (fp, "\n");
   fflush (fp);
 
   if (!iamremote)
     {
       fprintf (stderr, "%s: ", program_invocation_name);
+      va_start (ap, fmt);
       vfprintf (stderr, fmt, ap);
+      va_end (ap);
       fprintf (stderr, "\n");
     }
-
-  va_end (ap);
 }
 
 char *
diff --git a/src/rshd.c b/src/rshd.c
index e5df05f..c0cd7db 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -1212,6 +1212,7 @@ rshd_error (const char *fmt, ...)
   else
     len = 0;
   vsnprintf (bp, sizeof (buf) - 1, fmt, ap);
+  va_end (ap);
   write (STDERR_FILENO, buf, len + strlen (bp));
 }
 

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=b0a461970ae42ede3460ac3dd58f73e0fd8329b4


commit b0a461970ae42ede3460ac3dd58f73e0fd8329b4
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed May 30 12:30:55 2012 +0200

    ftpd: Grave binary mode issues.
    
    Empty buffer allocation and 64-bit artifacts.

diff --git a/ChangeLog b/ChangeLog
index 528339e..d7360ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2012-05-30  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Allow 64-bit offsets and file sizes.  Restrict
+	file size for use of mmap() and only null offset, since
+	Solaris and Linux demand page size alignment.  Assign
+	a positive malloc size for use in data transmission.
+
+	* ftpd/ftpcmd.y: Include <inttypes.h> or <stdint.h>.
+	(token union): Use `intmax_t i' instead of `int i' in order
+	to handle 64-bit offsets and sizes.
+	(cmd, rcmd, host_port, sizecmd): Use format strings `%jd'
+	and `%ju'.  Append `LL' to numerical constants.
+	(yylex) <ARGS>: Convert numeric strings using strtoimax().
+	* ftpd/ftpd.c (retrieve): Initialise BUFFER_SIZE to `BUFSIZ'
+	in all cases.  Essential correction, since malloc() would
+	otherwise allocate 0 bytes in binary mode.
+	(IU_MMAP_SIZE): New macro.
+	(send_data): Initialise BUF to `MAP_FAILED'.  Change LEN
+	and FILESIZE to be `off_t'.  Add debug logging about offsets
+	and transmission modes `ascii/image/mmap'.
+	[HAVE_MMAP]: Attempt mapping only if file size is less than
+	IU_MMAP_SIZE and only when `restart_point == 0'.
+
 2012-05-26  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	* tests/ftp-localhost.sh (do_transfer, GETME, PUTME):
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index dc88350..533a827 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -78,6 +78,11 @@
 #include <pwd.h>
 #include <setjmp.h>
 #include <signal.h>
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>	/* strtoimax */
+#elif defined HAVE_STDINT_H
+# include <stdint.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -126,7 +131,7 @@ static void yyerror       (const char *s);
 %}
 
 %union {
-	int	i;
+	intmax_t i;
 	char   *s;
 }
 
@@ -607,7 +612,7 @@ cmd
 					struct addrinfo hints, *res;
 
 					memset (&hints, 0, sizeof (hints));
-					snprintf (p, sizeof (p), "%u", $9 & 0xffff);
+					snprintf (p, sizeof (p), "%jd", $9 & 0xffffLL);
 					hints.ai_family = $5;
 					hints.ai_socktype = SOCK_STREAM;
 					hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
@@ -733,11 +738,9 @@ rcmd
 		{
 		        free (fromname);
 			fromname = (char *) 0;
-			restart_point = $3;	/* XXX $3 is only "int" */
-			reply(350,
-			      (sizeof(restart_point) > sizeof(long)
-			       ? "Restarting at %lld. %s"
-			       : "Restarting at %ld. %s"), restart_point,
+			restart_point = $3;
+			reply(350, "Restarting at %jd. %s",
+			    (intmax_t) restart_point,
 			    "Send STORE or RETRIEVE to initiate transfer.");
 		}
 	;
@@ -787,10 +790,10 @@ host_port
 			char a[INET6_ADDRSTRLEN], p[8];
 			struct addrinfo hints, *res;
 
-			snprintf (a, sizeof (a), "%u.%u.%u.%u",
-				$1 & 0xff, $3 & 0xff, $5 & 0xff, $7 & 0xff);
-			snprintf (p, sizeof (p), "%u",
-				(($9 & 0xff) << 8) + ($11 & 0xff));
+			snprintf (a, sizeof (a), "%jd.%jd.%jd.%jd",
+				  $1 & 0xffLL, $3 & 0xffLL, $5 & 0xffLL, $7 & 0xffLL);
+			snprintf (p, sizeof (p), "%jd",
+				  (($9 & 0xffLL) << 8) + ($11 & 0xffLL));
 			memset (&hints, 0, sizeof (hints));
 			hints.ai_family = his_addr.ss_family;
 			hints.ai_socktype = SOCK_STREAM;
@@ -802,8 +805,8 @@ host_port
 #ifdef AI_V4MAPPED
 			    hints.ai_flags |= AI_V4MAPPED;
 #endif
-			    snprintf (a, sizeof (a), "::ffff:%u.%u.%u.%u",
-				      $1 & 0xff, $3 & 0xff, $5 & 0xff, $7 & 0xff);
+			    snprintf (a, sizeof (a), "::ffff:%jd.%jd.%jd.%jd",
+				      $1 & 0xffLL, $3 & 0xffLL, $5 & 0xffLL, $7 & 0xffLL);
 			}
 
 			err = getaddrinfo (a, p, &hints, &res);
@@ -1352,7 +1355,7 @@ yylex(void)
 					;
 				c = cbuf[cpos];
 				cbuf[cpos] = '\0';
-				yylval.i = atoi(cp);
+				yylval.i = strtoimax (cp, NULL, 10);	/* off_t */
 				cbuf[cpos] = c;
 				return (NUMBER);
 			}
@@ -1523,9 +1526,7 @@ sizecmd(char *filename)
 		if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
 			reply(550, "%s: not a plain file.", filename);
 		else
-			reply(213,
-			      (sizeof (stbuf.st_size) > sizeof(long)
-			       ? "%llu" : "%lu"), stbuf.st_size);
+			reply(213, "%ju", (uintmax_t) stbuf.st_size);
 		break; }
 	case TYPE_A: {
 		FILE *fin;
@@ -1551,8 +1552,7 @@ sizecmd(char *filename)
 		}
 		 fclose(fin);
 
-		reply(213, sizeof(count) > sizeof(long) ? "%lld" : "%ld",
-		      count);
+		reply(213, "%jd", (intmax_t) count);
 		break; }
 	default:
 		reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 3693a21..ba5560e 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -876,7 +876,7 @@ retrieve (const char *cmd, const char *name)
   FILE *fin, *dout;
   struct stat st;
   int (*closefunc) (FILE *);
-  size_t buffer_size = 0;
+  const size_t buffer_size = BUFSIZ;	/* Dynamic buffer.  */
 
   if (cmd == 0)
     {
@@ -891,7 +891,6 @@ retrieve (const char *cmd, const char *name)
       name = line;
       fin = ftpd_popen (line, "r"), closefunc = ftpd_pclose;
       st.st_size = -1;
-      buffer_size = BUFSIZ;
     }
 
   if (fin == NULL)
@@ -1198,6 +1197,8 @@ dataconn (const char *name, off_t size, const char *mode)
   return file;
 }
 
+#define IU_MMAP_SIZE 0x800000	/* 8 MByte */
+
 /* Tranfer the contents of "instr" to "outstr" peer using the appropriate
    encapsulation of the data subject * to Mode, Structure, and Type.
 
@@ -1206,9 +1207,9 @@ static void
 send_data (FILE * instr, FILE * outstr, off_t blksize)
 {
   int c, cnt, filefd, netfd;
-  char *buf, *bp;
+  char *buf = MAP_FAILED, *bp;
   off_t curpos;
-  size_t len, filesize;
+  off_t len, filesize;
 
   transflag++;
   if (setjmp (urgcatch))
@@ -1220,9 +1221,16 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
   netfd = fileno (outstr);
   filefd = fileno (instr);
 #ifdef HAVE_MMAP
-  if (file_size > 0)
+  /* Last argument in mmap() must be page aligned,
+   * at least for Solaris and Linux, so use mmap()
+   * only with null offset retrievals.
+   */
+  if (file_size > 0 && file_size < IU_MMAP_SIZE && restart_point == 0)
     {
       curpos = lseek (filefd, 0, SEEK_CUR);
+      if (debug)
+	syslog (LOG_DEBUG, "Position is %jd. Attempting mmap call.",
+		curpos);
       if (curpos >= 0)
 	{
 	  filesize = file_size - curpos;
@@ -1238,6 +1246,8 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
 #ifdef HAVE_MMAP
       if (file_size > 0 && curpos >= 0 && buf != MAP_FAILED)
 	{
+	  if (debug)
+	    syslog (LOG_DEBUG, "Reading file as ascii in mmap mode.");
 	  len = 0;
 	  while (len < filesize)
 	    {
@@ -1260,6 +1270,8 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
 	  return;
 	}
 #endif
+      if (debug)
+	syslog (LOG_DEBUG, "Reading file as ascii in byte mode.");
       while ((c = getc (instr)) != EOF)
 	{
 	  byte_count++;
@@ -1285,6 +1297,8 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
 #ifdef HAVE_MMAP
       if (file_size > 0 && curpos >= 0 && buf != MAP_FAILED)
 	{
+	  if (debug)
+	    syslog (LOG_DEBUG, "Reading file as image in mmap mode.");
 	  bp = buf;
 	  len = filesize;
 	  do
@@ -1304,6 +1318,16 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
 	  return;
 	}
 #endif
+      if (debug)
+	{
+	  syslog (LOG_DEBUG, "Reading file as image in block mode.");
+	  curpos = lseek (filefd, 0, SEEK_CUR);
+	  if (curpos < 0)
+	    syslog (LOG_DEBUG, "Input file: %m");
+	  else
+	    syslog (LOG_DEBUG, "Starting at position %jd.", curpos);
+	}
+
       buf = malloc ((u_int) blksize);
       if (buf == NULL)
 	{
@@ -1314,6 +1338,7 @@ send_data (FILE * instr, FILE * outstr, off_t blksize)
       while ((cnt = read (filefd, buf, (u_int) blksize)) > 0 &&
 	     write (netfd, buf, cnt) == cnt)
 	byte_count += cnt;
+
       transflag = 0;
       free (buf);
       if (cnt != 0)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog     |   34 ++++++++++++++++++++++++++++++++++
 ftpd/ftpcmd.y |   38 +++++++++++++++++++-------------------
 ftpd/ftpd.c   |   41 ++++++++++++++++++++++++++++++++++++-----
 src/rcp.c     |    5 +++--
 src/rshd.c    |    1 +
 5 files changed, 93 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed May 30 19:24:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SZsFj-0004JH-9U
	for mharc-commit-inetutils@gnu.org; Wed, 30 May 2012 19:24:31 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49150)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZsFg-0004J8-Nh
	for commit-inetutils@gnu.org; Wed, 30 May 2012 19:24:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZsFe-0001y4-NF
	for commit-inetutils@gnu.org; Wed, 30 May 2012 19:24:28 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:40321)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SZsFe-0001xt-JS
	for commit-inetutils@gnu.org; Wed, 30 May 2012 19:24:26 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SZsFc-0005bT-S1
	for commit-inetutils@gnu.org; Wed, 30 May 2012 23:24:25 +0000
Date: Wed, 30 May 2012 23:24:25 +0000
Message-Id: <E1SZsFc-0005bT-S1@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-104-gac18df3
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb
X-Git-Newrev: ac18df39a8502d98ebd8988937fffb98c5e405df
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 May 2012 23:24:30 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  ac18df39a8502d98ebd8988937fffb98c5e405df (commit)
      from  2aea8c1ea8e0ce1f4dc173ab84dd34bd7e9782eb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=ac18df39a8502d98ebd8988937fffb98c5e405df


commit ac18df39a8502d98ebd8988937fffb98c5e405df
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 31 00:30:27 2012 +0200

    ftpd: Adaptive block sizes.
    
    Improve throughput by use of block sizes
    as reported by file system data.

diff --git a/ChangeLog b/ChangeLog
index faabde2..2aebde6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+ 2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Use adaptive block sizes in image mode.
+
+	* ftpd/ftpd.c (receive_data): Update signature to
+	`(FILE *, FILE *, off_t)'.  Make BUF a pointer to
+	allocated memory.
+	<TYPE_I> : Allocate BUF of size `blksize'.  Change
+	buffer size to this value inside loop calling read().
+	(retrieve): Remove `const' from BUFFER_SIZE again.
+	If `cmd == 0', use `st_blksize' for setting BUFFER_SIZE.
+	(store): Call fstat() on successful stream `fout'.
+
  2012-05-30  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Incomplete coding of variadic printing.  Each such command
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index b33c246..4c1711f 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -248,7 +248,7 @@ static FILE *getdatasock (const char *);
 static char *gunique (const char *);
 static void lostconn (int);
 static void myoob (int);
-static int receive_data (FILE *, FILE *);
+static int receive_data (FILE *, FILE *, off_t);
 static void send_data (FILE *, FILE *, off_t);
 static void sigquit (int);
 
@@ -876,7 +876,7 @@ retrieve (const char *cmd, const char *name)
   FILE *fin, *dout;
   struct stat st;
   int (*closefunc) (FILE *);
-  const size_t buffer_size = BUFSIZ;	/* Dynamic buffer.  */
+  size_t buffer_size = BUFSIZ;	/* Dynamic buffer.  */
 
   if (cmd == 0)
     {
@@ -911,6 +911,9 @@ retrieve (const char *cmd, const char *name)
       reply (550, "%s: not a plain file.", name);
       goto done;
     }
+  else if (cmd == 0)
+    buffer_size = st.st_blksize;	/* Depends on file system.  */
+
   if (restart_point)
     {
       if (type == TYPE_A)
@@ -975,7 +978,7 @@ store (const char *name, const char *mode, int unique)
     mode = "r+";
   fout = fopen (name, mode);
   closefunc = fclose;
-  if (fout == NULL)
+  if (fout == NULL || fstat (fileno (fout), &st) < 0)
     {
       perror_reply (553, name);
       LOGCMD (*mode == 'w' ? "put" : "append", name);
@@ -1020,7 +1023,7 @@ store (const char *name, const char *mode, int unique)
   din = dataconn (name, (off_t) - 1, "r");
   if (din == NULL)
     goto done;
-  if (receive_data (din, fout) == 0)
+  if (receive_data (din, fout, st.st_blksize) == 0)
     {
       if (unique)
 	reply (226, "Transfer complete (unique file name:%s).", name);
@@ -1370,11 +1373,11 @@ file_err:
 
    N.B.: Form isn't handled.  */
 static int
-receive_data (FILE * instr, FILE * outstr)
+receive_data (FILE * instr, FILE * outstr, off_t blksize)
 {
   int c;
   int cnt, bare_lfs = 0;
-  char buf[BUFSIZ];
+  char *buf;
 
   transflag++;
   if (setjmp (urgcatch))
@@ -1386,12 +1389,24 @@ receive_data (FILE * instr, FILE * outstr)
     {
     case TYPE_I:
     case TYPE_L:
-      while ((cnt = read (fileno (instr), buf, sizeof (buf))) > 0)
+      buf = malloc ((u_int) blksize);
+      if (buf == NULL)
+	{
+	  transflag = 0;
+	  perror_reply (451, "Local resource failure: malloc");
+	  return -1;
+	}
+
+      while ((cnt = read (fileno (instr), buf, blksize)) > 0)
 	{
 	  if (write (fileno (outstr), buf, cnt) != cnt)
-	    goto file_err;
+	    {
+	      free (buf);
+	      goto file_err;
+	    }
 	  byte_count += cnt;
 	}
+      free (buf);
       if (cnt < 0)
 	goto data_err;
       transflag = 0;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   |   13 +++++++++++++
 ftpd/ftpd.c |   31 +++++++++++++++++++++++--------
 2 files changed, 36 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu May 31 12:30:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Sa8Ge-0001mp-4J
	for mharc-commit-inetutils@gnu.org; Thu, 31 May 2012 12:30:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46571)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Sa8GX-0001lu-UF
	for commit-inetutils@gnu.org; Thu, 31 May 2012 12:30:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Sa8GV-0004ZN-8S
	for commit-inetutils@gnu.org; Thu, 31 May 2012 12:30:25 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39917)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Sa8GV-0004ZG-4g
	for commit-inetutils@gnu.org; Thu, 31 May 2012 12:30:23 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Sa8GR-00080T-Hg
	for commit-inetutils@gnu.org; Thu, 31 May 2012 16:30:22 +0000
Date: Thu, 31 May 2012 16:30:22 +0000
Message-Id: <E1Sa8GR-00080T-Hg@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-105-g890be11
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ac18df39a8502d98ebd8988937fffb98c5e405df
X-Git-Newrev: 890be117d428028e4e77608303416598c163c158
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 31 May 2012 16:30:30 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  890be117d428028e4e77608303416598c163c158 (commit)
      from  ac18df39a8502d98ebd8988937fffb98c5e405df (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=890be117d428028e4e77608303416598c163c158


commit 890be117d428028e4e77608303416598c163c158
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu May 31 17:13:41 2012 +0200

    ftp: Adaptive block size.

diff --git a/ChangeLog b/ChangeLog
index 2aebde6..9f72a57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
  2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	ftp: Adaptive block size in image mode.
+
+	* ftp/ftp.c (sendrequest): New variables BLKSIZE, BUFSIZE.
+	Change type of BUF to `static char *' for allocation.
+	Set BLKSIZE to `st_blksize' for input file.  Allocate and
+	increase size of buffer as needed.
+	<TYPE_I>: Use BUFSIZE for buffer length when calling read().
+	(recvrequest): Call fstat() on successful stream `fout'
+	and set BLKSIZE to `st_blksize'.
+	(abort_remote): Replace macro BUFSIZ by `sizeof(buf)'.
+
+ 2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	ftpd: Use adaptive block sizes in image mode.
 
 	* ftpd/ftpd.c (receive_data): Update signature to
diff --git a/ftp/ftp.c b/ftp/ftp.c
index b662259..3317055 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -542,7 +542,10 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
   int (*closefunc) (FILE *);
   sighandler_t oldintr, oldintp;
   long long bytes = 0, local_hashbytes = hashbytes;
-  char *lmode, buf[BUFSIZ], *bufp;
+  char *lmode, *bufp;
+  int blksize = BUFSIZ;
+  static int bufsize = 0;
+  static char *buf;
 
   if (verbose && printnames)
     {
@@ -616,6 +619,7 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
 	  code = -1;
 	  return;
 	}
+	blksize = st.st_blksize;
     }
   if (initconn ())
     {
@@ -687,6 +691,20 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
   dout = dataconn (lmode);
   if (dout == NULL)
     goto abort;
+
+  if (blksize > bufsize)
+    {
+      free (buf);
+      buf = malloc ((unsigned) blksize);
+      if (buf == NULL)
+	{
+	  error (0, errno, "malloc");
+	  bufsize = 0;
+	  goto abort;
+	}
+      bufsize = blksize;
+    }
+
   gettimeofday (&start, (struct timezone *) 0);
   oldintp = signal (SIGPIPE, SIG_IGN);
   switch (curtype)
@@ -695,7 +713,7 @@ sendrequest (char *cmd, char *local, char *remote, int printnames)
     case TYPE_I:
     case TYPE_L:
       errno = d = 0;
-      while ((c = read (fileno (fin), buf, sizeof (buf))) > 0)
+      while ((c = read (fileno (fin), buf, bufsize)) > 0)
 	{
 	  bytes += c;
 	  for (bufp = buf; c > 0; c -= d, bufp += d)
@@ -823,7 +841,8 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
   FILE *fout, *din = 0;
   int (*closefunc) (FILE *);
   sighandler_t oldintr, oldintp;
-  int c, d, is_retr, tcrflag, bare_lfs = 0, blksize;
+  int c, d, is_retr, tcrflag, bare_lfs = 0;
+  int blksize = BUFSIZ;
   static int bufsize = 0;
   static char *buf;
   long long bytes = 0, local_hashbytes = hashbytes;
@@ -909,6 +928,7 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
   din = dataconn ("r");
   if (din == NULL)
     goto abort;
+
   if (strcmp (local, "-") == 0)
     fout = stdout;
   else if (*local == '|')
@@ -924,15 +944,18 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
     }
   else
     {
+      struct stat st;
+
       fout = fopen (local, lmode);
-      if (fout == NULL)
+      if (fout == NULL || fstat (fileno (fout), &st) < 0)
 	{
 	  error (0, errno, "local: %s", local);
 	  goto abort;
 	}
       closefunc = fclose;
+      blksize = st.st_blksize;
     }
-  blksize = BUFSIZ;
+
   if (blksize > bufsize)
     {
       free (buf);
@@ -945,6 +968,7 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
 	}
       bufsize = blksize;
     }
+
   gettimeofday (&start, (struct timezone *) 0);
   switch (curtype)
     {
@@ -974,6 +998,7 @@ recvrequest (char *cmd, char *local, char *remote, char *lmode, int printnames)
 	      fflush (stdout);
 	    }
 	}
+
       if (hash && bytes > 0)
 	{
 	  if (bytes < local_hashbytes)
@@ -1891,7 +1916,7 @@ abort_remote (FILE *din)
     }
   if (din && FD_ISSET (fileno (din), &mask))
     {
-      while (read (fileno (din), buf, BUFSIZ) > 0)
+      while (read (fileno (din), buf, sizeof (buf)) > 0)
 	/* LOOP */ ;
     }
   if (getreply (0) == ERROR && code == 552)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog |   13 +++++++++++++
 ftp/ftp.c |   37 +++++++++++++++++++++++++++++++------
 2 files changed, 44 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


