From MAILER-DAEMON Wed Apr 11 16:10:39 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SI3sF-0006fX-Ry
	for mharc-commit-inetutils@gnu.org; Wed, 11 Apr 2012 16:10:39 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58596)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SI3sA-0006en-61
	for commit-inetutils@gnu.org; Wed, 11 Apr 2012 16:10:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SI3s4-0004eE-79
	for commit-inetutils@gnu.org; Wed, 11 Apr 2012 16:10:33 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42330)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SI3s4-0004e9-3H
	for commit-inetutils@gnu.org; Wed, 11 Apr 2012 16:10:28 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SI3s2-0006SQ-Lk
	for commit-inetutils@gnu.org; Wed, 11 Apr 2012 20:10:27 +0000
Date: Wed, 11 Apr 2012 20:10:27 +0000
Message-Id: <E1SI3s2-0006SQ-Lk@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-73-g982ff0e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8f92df2bd52bcbddf8841e3b79d779109d485e5c
X-Git-Newrev: 982ff0eeab04235b193b312ea6433993296db515
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, 11 Apr 2012 20:10:39 -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  982ff0eeab04235b193b312ea6433993296db515 (commit)
      from  8f92df2bd52bcbddf8841e3b79d779109d485e5c (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=982ff0eeab04235b193b312ea6433993296db515


commit 982ff0eeab04235b193b312ea6433993296db515
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed Apr 11 22:08:09 2012 +0200

    Portability fixes and cleanup.
    
    Support DragonFly BSD and fix a resilient
    issue on OpenSolaris.

diff --git a/ChangeLog b/ChangeLog
index 7bdd098..09c71c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-04-11  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Support for DragonFly BSD.
+
+	* configure.ac: Define UTMPX for `*dragonfly*'.
+	* ftpd/extern.h: Include <sys/socket.h>.
+	* src/rexec.c (do_rexec): Explicit casts as `struct sockaddr'.
+	* src/tftpd.c (validate_access): Declare TIMEOUTBUF correctly
+	to be of type `sigjmp_buf'.
+	* telnet/externs.h: Include <errno.h> unconditionally.  Remove
+	conditionals for `errno' depending on macro CRAY.
+
 2012-03-31  Alfred M. Szmidt  <ams@gnu.org>
 
 	configure.ac: Minor cleanup.
diff --git a/configure.ac b/configure.ac
index 47e8133..6b474c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -832,7 +832,7 @@ case "$host" in
   AC_DEFINE([UTMPX], 1, [FIXME])
   AC_DEFINE([HAVE_STREAMSPTY], 1, [FIXME])
   ;;
-*irix* | *hpux* | *netbsd*)
+*irix* | *hpux* | *netbsd* | *dragonfly* )
   AC_DEFINE([UTMPX], 1, [FIXME])
   ;;
 esac
diff --git a/ftpd/extern.h b/ftpd/extern.h
index 422bd99..acf673f 100644
--- a/ftpd/extern.h
+++ b/ftpd/extern.h
@@ -51,6 +51,7 @@
 #include <setjmp.h>
 #include <getopt.h>
 #include <sys/types.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 
 extern void cwd (const char *);
diff --git a/src/rexec.c b/src/rexec.c
index 3cce369..57d6aee 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -206,7 +206,7 @@ do_rexec (struct arguments *arguments)
 
   addr.sin_port = htons ((short)arguments->port);
 
-  if (connect (sock, &addr, sizeof (addr)) < 0)
+  if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
     error (EXIT_FAILURE, errno, "cannot connect to the specified host");
 
   if (!arguments->use_err)
@@ -228,11 +228,12 @@ do_rexec (struct arguments *arguments)
       memset (&serv_addr, 0, sizeof (serv_addr));
 
       serv_addr.sin_port = arguments->err_port;
-      if (bind (serv_sock, &serv_addr, sizeof (serv_addr)) < 0)
+      if (bind (serv_sock, (struct sockaddr *) &serv_addr,
+		sizeof (serv_addr)) < 0)
         error (EXIT_FAILURE, errno, "cannot bind socket");
 
       len = sizeof (serv_addr);
-      if (getsockname (serv_sock, &serv_addr, &len))
+      if (getsockname (serv_sock, (struct sockaddr *) &serv_addr, &len))
         error (EXIT_FAILURE, errno, "error reading socket port");
 
       if (listen (serv_sock, 1))
@@ -242,7 +243,7 @@ do_rexec (struct arguments *arguments)
       sprintf (port_str, "%i", arguments->err_port);
       safe_write (sock, port_str, strlen (port_str) + 1);
 
-      err_sock = accept (serv_sock, &serv_addr, &len);
+      err_sock = accept (serv_sock, (struct sockaddr *) &serv_addr, &len);
       if (err_sock < 0)
         error (EXIT_FAILURE, errno, "error accepting connection");
 
diff --git a/src/tftpd.c b/src/tftpd.c
index 99ac02b..1112c78 100644
--- a/src/tftpd.c
+++ b/src/tftpd.c
@@ -522,7 +522,7 @@ validate_access (char **filep, int mode)
 }
 
 int timeout;
-jmp_buf timeoutbuf;
+sigjmp_buf timeoutbuf;
 
 void
 timer (int sig)
diff --git a/telnet/externs.h b/telnet/externs.h
index d621dbf..4171a8e 100644
--- a/telnet/externs.h
+++ b/telnet/externs.h
@@ -78,9 +78,7 @@
 #ifdef HAVE_SYS_FILIO_H
 # include <sys/filio.h>
 #endif
-#ifdef CRAY
-# include <errno.h>
-#endif /* CRAY */
+#include <errno.h>
 #ifdef	USE_TERMIO
 # ifndef VINTR
 #  ifdef SYSV_TERMIO
@@ -121,12 +119,6 @@ typedef unsigned char cc_t;
 
 #define SUBBUFSIZE	256
 
-#ifndef CRAY
-# ifndef errno
-extern int errno;		/* outside this world */
-# endif
-#endif /* !CRAY */
-
 extern int autologin,		/* Autologin enabled */
   skiprc,			/* Don't process the ~/.telnetrc file */
   eight,			/* use eight bit mode (binary in and/or out */

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

Summary of changes:
 ChangeLog        |   12 ++++++++++++
 configure.ac     |    2 +-
 ftpd/extern.h    |    1 +
 src/rexec.c      |    9 +++++----
 src/tftpd.c      |    2 +-
 telnet/externs.h |   10 +---------
 6 files changed, 21 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Apr 13 16:29:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SIn7Y-0000sW-HB
	for mharc-commit-inetutils@gnu.org; Fri, 13 Apr 2012 16:29:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58034)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SIn7V-0000oA-Cb
	for commit-inetutils@gnu.org; Fri, 13 Apr 2012 16:29:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SIn7Q-0006Qs-Sd
	for commit-inetutils@gnu.org; Fri, 13 Apr 2012 16:29:24 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:54948)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SIn7Q-0006QO-MP
	for commit-inetutils@gnu.org; Fri, 13 Apr 2012 16:29:20 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SIn7P-0003uL-Fr
	for commit-inetutils@gnu.org; Fri, 13 Apr 2012 20:29:20 +0000
Date: Fri, 13 Apr 2012 20:29:19 +0000
Message-Id: <E1SIn7P-0003uL-Fr@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-74-gc76e1f1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 982ff0eeab04235b193b312ea6433993296db515
X-Git-Newrev: c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a
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, 13 Apr 2012 20:29:27 -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  c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a (commit)
      from  982ff0eeab04235b193b312ea6433993296db515 (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=c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a


commit c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Apr 13 21:24:25 2012 +0200

    ftpd: Incomplete access verification.

diff --git a/ChangeLog b/ChangeLog
index 09c71c5..8774399 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-04-13  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Improve checking of FTP access verification.
+
+	* ftpd/ftpd.c (complete_login): Abort login attempt when
+	setegid() fails.
+	(pass): Clear LOGIN_ATTEMPTS only if login was really granted.
+
 2012-04-11  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Support for DragonFly BSD.
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 4103dab..3693a21 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -646,7 +646,7 @@ complete_login (struct credentials *pcred)
   if (setegid ((gid_t) pcred->gid) < 0)
     {
       reply (550, "Can't set gid.");
-      return;
+      goto bad;
     }
 
 #ifdef HAVE_INITGROUPS
@@ -726,7 +726,7 @@ complete_login (struct credentials *pcred)
   return;
 bad:
   /* Forget all about it... */
-  end_login (pcred);
+  end_login (pcred);	/* Resets pcred->logged_in.  */
 }
 
 /* USER command.
@@ -864,7 +864,10 @@ pass (const char *passwd)
     }
   cred.logged_in = 1;		/* Everything seems to be allright.  */
   complete_login (&cred);
-  login_attempts = 0;		/* This time successful.  */
+  if (cred.logged_in)
+    login_attempts = 0;		/* This time successful.  */
+  else
+    ++login_attempts;
 }
 
 void

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

Summary of changes:
 ChangeLog   |    8 ++++++++
 ftpd/ftpd.c |    9 ++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Apr 20 06:07:08 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLAk8-0004Uh-3C
	for mharc-commit-inetutils@gnu.org; Fri, 20 Apr 2012 06:07:08 -0400
Received: from eggs.gnu.org ([208.118.235.92]:42092)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLAjz-0004Tw-Gm
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 06:07:06 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLAjr-0001kW-Jg
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 06:06:59 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53879)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLAjr-0001kL-F6
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 06:06:51 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SLAjp-0003X5-UH
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 10:06:51 +0000
Date: Fri, 20 Apr 2012 10:06:50 +0000
Message-Id: <E1SLAjp-0003X5-UH@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-77-g6dec6e1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a
X-Git-Newrev: 6dec6e1745be4386f3bc48ad6ca6df7e27100fe7
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, 20 Apr 2012 10:07: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  6dec6e1745be4386f3bc48ad6ca6df7e27100fe7 (commit)
       via  22a00b23073fe17a7b027b154b77e6da07a3d51c (commit)
       via  f730d11f7f578db86ec699c619f4a65e7ac60752 (commit)
      from  c76e1f1f0591a30a42d17bd7b18e1abd531b8d2a (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=6dec6e1745be4386f3bc48ad6ca6df7e27100fe7


commit 6dec6e1745be4386f3bc48ad6ca6df7e27100fe7
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Apr 20 03:54:17 2012 +0200

    rexec, rexecd: Implement support for IPv6.

diff --git a/ChangeLog b/ChangeLog
index 1d4e0da..e1aa06f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2012-04-20  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexec, rexecd: Implement support for IPv6.
+
+	* src/rexec.c (options): New `-4/ipv4', `-6/ipv6', and `-a/ipany'.
+	(struct arguments): New member `int af'.
+	(parse_opt): Detect `4', `6', and `a'.
+	(do_rexec): New variables `ret', `addrlen', `hints', `ai', `res'.
+	New type `struct sockaddr_storage` for ADDR.  Removed `host'.
+	Replace gethostbyname() by getaddrinfo() in resolving host name.
+	(do_rexec) <use error stream>: Use `struct sockaddr_storage` for
+	SERV_ADDR and prepare bind() based on properties of ADDR.
+	* src/rexecd.c (main): Use `struct sockaddr_storage' for FROM.
+	(a_sin): Removed variable.
+	(doit): New signature `doit(int, struct sockaddr *, socklen_t)`
+	Change PORT to be `in_port_t'.  Remove call to bind().  Rewrite
+	preparations for connect() to detect address family.
+
 2012-04-19  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Let `rexec' return a relevant return status.
diff --git a/src/rexec.c b/src/rexec.c
index b3eacbb..cbf7f7e 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -65,6 +65,9 @@ static struct argp_option options[] = {
   {"port",  'P', "port", 0, "Specify the port to connect to"},
   {"noerr", 'n', NULL, 0, "Disable the stderr stream"},
   {"error",  'e', "error", 0, "Specify a TCP port to use for stderr"},
+  {"ipv4",  '4', NULL, 0, "Use IPv4 address space."},
+  {"ipv6",  '6', NULL, 0, "Use IPv6 address space."},
+  {"ipany",  'a', NULL, 0, "Allow any address family. (default)"},
   { 0 }
 };
 
@@ -74,6 +77,7 @@ struct arguments
   const char *user;
   const char *password;
   const char *command;
+  int af;
   int port;
   int use_err;
   int err_port;
@@ -104,6 +108,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
     case 'n':
       arguments->use_err = 0;
       break;
+    case '4':
+      arguments->af = AF_INET;
+      break;
+    case '6':
+      arguments->af = AF_INET6;
+      break;
+    case 'a':
+      arguments->af = AF_UNSPEC;
+      break;
     case ARGP_KEY_ARG:
       arguments->command = arg;
       state->next = state->argc;
@@ -131,6 +144,7 @@ main (int argc, char **argv)
   arguments.password = NULL;
   arguments.host = NULL;
   arguments.command = NULL;
+  arguments.af = AF_UNSPEC;
   arguments.err_port = 0;
   arguments.use_err = 1;
   arguments.port = 512;
@@ -181,35 +195,49 @@ do_rexec (struct arguments *arguments)
 {
   int err;
   char buffer[1024];
-  int sock;
-  char port_str[6];
-  struct sockaddr_in addr;
-  struct hostent *host;
+  int sock, ret;
+  char port_str[12];
+  socklen_t addrlen;
+  struct sockaddr_storage addr;
+  struct addrinfo hints, *ai, *res;
   int stdin_fd = STDIN_FILENO;
   int err_sock = -1;
 
-  sock = socket (AF_INET, SOCK_STREAM, 0);
-  if (sock < 0)
-    error (EXIT_FAILURE, errno, "cannot open socket");
-
-  host = gethostbyname (arguments->host);
-  if (host == NULL)
-    error (EXIT_FAILURE, errno, "cannot find host %s", arguments->host);
-
-  memset (&addr, 0, sizeof (addr));
-  addr.sin_family = AF_INET;
-  memmove ((caddr_t) &addr.sin_addr,
-#ifdef HAVE_STRUCT_HOSTENT_H_ADDR_LIST
-	       host->h_addr_list[0],
-#else
-	       host->h_addr,
-#endif
-	       host->h_length);
+  snprintf (port_str, sizeof (port_str), "%d", arguments->port);
+
+  memset (&hints, 0, sizeof (hints));
+  hints.ai_family = arguments->af;
+  hints.ai_socktype = SOCK_STREAM;
+
+  ret = getaddrinfo (arguments->host, port_str, &hints, &res);
+  if (ret)
+    error (EXIT_FAILURE, errno, "getaddrinfo: %s", gai_strerror (ret));
+
+  for (ai = res; ai != NULL; ai = ai->ai_next)
+    {
+      sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+      if (sock < 0)
+	continue;
+
+      if (connect (sock, ai->ai_addr, ai->ai_addrlen) < 0)
+	{
+	  close (sock);
+	  sock = -1;
+	  continue;
+	}
+
+      break;	/* Acceptable.  */
+    }
 
-  addr.sin_port = htons ((short)arguments->port);
+  if (ai == NULL)
+    {
+      freeaddrinfo (res);
+      error (EXIT_FAILURE, errno, "cannot find host %s", arguments->host);
+    }
 
-  if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
-    error (EXIT_FAILURE, errno, "cannot connect to the specified host");
+  addrlen = ai->ai_addrlen;
+  memcpy (&addr, ai->ai_addr, ai->ai_addrlen);
+  freeaddrinfo (res);
 
   if (!arguments->use_err)
     {
@@ -220,24 +248,42 @@ do_rexec (struct arguments *arguments)
     }
   else
     {
-      struct sockaddr_in serv_addr;
+      struct sockaddr_storage serv_addr;
       socklen_t len;
       int on = 1;
-      int serv_sock = socket (AF_INET, SOCK_STREAM, 0);
+      int serv_sock = socket (addr.ss_family, SOCK_STREAM, 0);
 
       if (serv_sock < 0)
         error (EXIT_FAILURE, errno, "cannot open socket");
 
+      setsockopt (serv_sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
+
       memset (&serv_addr, 0, sizeof (serv_addr));
 
-      serv_addr.sin_family = AF_INET;
+      /* Need to bind to explicit port, when err_port is non-zero,
+       * or to be assigned a free port, should err_port be naught.
+       */
+      switch (addr.ss_family)
+	{
+	case AF_INET:
 #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
-      serv_addr.sin_len = sizeof (serv_addr);
+	  ((struct sockaddr_in *) &serv_addr)->sin_len = addrlen;
 #endif
-      serv_addr.sin_port = arguments->err_port;
-      setsockopt (serv_sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
-      if (bind (serv_sock, (struct sockaddr *) &serv_addr,
-		sizeof (serv_addr)) < 0)
+	  ((struct sockaddr_in *) &serv_addr)->sin_family = addr.ss_family;
+	  ((struct sockaddr_in *) &serv_addr)->sin_port = arguments->err_port;
+	  break;
+	case AF_INET6:
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+	  ((struct sockaddr_in6 *) &serv_addr)->sin6_len = addrlen;
+#endif
+	  ((struct sockaddr_in6 *) &serv_addr)->sin6_family = addr.ss_family;
+	  ((struct sockaddr_in6 *) &serv_addr)->sin6_port = arguments->err_port;
+	  break;
+	default:
+	  error (EXIT_FAILURE, EAFNOSUPPORT, "unknown address family");
+	}
+
+      if (bind (serv_sock, (struct sockaddr *) &serv_addr, addrlen) < 0)
         error (EXIT_FAILURE, errno, "cannot bind socket");
 
       len = sizeof (serv_addr);
@@ -247,8 +293,18 @@ do_rexec (struct arguments *arguments)
       if (listen (serv_sock, 1))
         error (EXIT_FAILURE, errno, "error listening on socket");
 
-      arguments->err_port = ntohs (serv_addr.sin_port);
-      sprintf (port_str, "%i", arguments->err_port);
+      switch (serv_addr.ss_family)
+	{
+	case AF_INET:
+	  arguments->err_port = ntohs (((struct sockaddr_in *) &serv_addr)->sin_port);
+	  break;
+	case AF_INET6:
+	  arguments->err_port = ntohs (((struct sockaddr_in6 *) &serv_addr)->sin6_port);
+	  break;
+	default:
+	  error (EXIT_FAILURE, EAFNOSUPPORT, "unknown address family");
+	}
+      snprintf (port_str, sizeof (port_str), "%u", arguments->err_port);
       safe_write (sock, port_str, strlen (port_str) + 1);
 
       err_sock = accept (serv_sock, (struct sockaddr *) &serv_addr, &len);
diff --git a/src/rexecd.c b/src/rexecd.c
index db804d5..87b1098 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -84,7 +84,7 @@
 #include "libinetutils.h"
 
 void die (int code, const char *fmt, ...);
-int doit (int f, struct sockaddr_in *fromp);
+int doit (int f, struct sockaddr *fromp, socklen_t fromlen);
 
 const char doc[] = "remote execution daemon";
 
@@ -108,7 +108,7 @@ static struct argp argp = {
 int
 main (int argc, char **argv)
 {
-  struct sockaddr_in from;
+  struct sockaddr_storage from;
   socklen_t fromlen;
   int sockfd = STDIN_FILENO;
   int index;
@@ -123,7 +123,7 @@ main (int argc, char **argv)
   fromlen = sizeof (from);
   if (getpeername (sockfd, (struct sockaddr *) &from, &fromlen) < 0)
     error (EXIT_FAILURE, errno, "getpeername");
-  doit (sockfd, &from);
+  doit (sockfd, (struct sockaddr *) &from, fromlen);
   exit (EXIT_SUCCESS);
 }
 
@@ -137,12 +137,6 @@ char path[sizeof (PATH_DEFPATH) + sizeof ("PATH=")] = "PATH=";
 char *envinit[] = { homedir, shell, path, username, logname, NULL };
 extern char **environ;
 
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
-struct sockaddr_in a_sin = { sizeof (a_sin), AF_INET };
-#else
-struct sockaddr_in a_sin = { AF_INET };
-#endif
-
 char *getstr (const char *);
 
 static char *
@@ -158,13 +152,13 @@ get_user_password (struct passwd *pwd)
 }
 
 int
-doit (int f, struct sockaddr_in *fromp)
+doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 {
   char *cmdbuf, *cp, *namep;
   char *user, *pass, *pw_password;
   struct passwd *pwd;
   int s;
-  unsigned short port;
+  in_port_t port;
   int pv[2], pid, cc;
   fd_set readfrom, ready;
   char buf[BUFSIZ], sig;
@@ -204,15 +198,23 @@ doit (int f, struct sockaddr_in *fromp)
   alarm (0);
   if (port != 0)
     {
-      s = socket (AF_INET, SOCK_STREAM, 0);
+      s = socket (fromp->sa_family, SOCK_STREAM, 0);
       if (s < 0)
 	exit (EXIT_FAILURE);
       setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
-      if (bind (s, (struct sockaddr *) &a_sin, sizeof (a_sin)) < 0)
-	exit (EXIT_FAILURE);
       alarm (60);
-      fromp->sin_port = htons (port);
-      if (connect (s, (struct sockaddr *) fromp, sizeof (*fromp)) < 0)
+      switch (fromp->sa_family)
+	{
+	case AF_INET:
+	  ((struct sockaddr_in *) fromp)->sin_port = htons (port);
+	  break;
+	case AF_INET6:
+	  ((struct sockaddr_in6 *) fromp)->sin6_port = htons (port);
+	  break;
+	default:
+	  exit (EXIT_FAILURE);
+	}
+      if (connect (s, fromp, fromlen) < 0)
 	exit (EXIT_FAILURE);
       alarm (0);
     }

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


commit 22a00b23073fe17a7b027b154b77e6da07a3d51c
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Apr 19 23:23:40 2012 +0200

    rexec, rexecd: Reliability and exit codes.

diff --git a/ChangeLog b/ChangeLog
index b3eb406..1d4e0da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2012-04-19  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Let `rexec' return a relevant return status.
+
+	* src/rexec.c (remote_err): New variable.
+	(main): Return `remote_err' as status.
+	(do_rexec): New variable ON.  Set SO_REUSEADDR on SERV_SOCK.
+	(do_rexec) <while loop>: New variables CONSUMED and OFFSET.
+	Filter off initial bytes `\000' and `\001' appearing on either
+	of the sockets SOCK and ERR_SOCK, since these represent return
+	statuses and are now recorded in `remote_err'.
+
+	String storage sanitation and intelligible return codes.
+
+	* src/rexecd.c (username, logname, homedir, shell): Increase length.
+	(envinit): Use NULL as last member, not naught.
+	(doit): Set SO_REUSEADDR on socket S.  Use sizeof() to calculate
+	explicit offset in strncat() with environment variables.  Let
+	LOGNAME inherit the value from USER.
+	(doit, getstr) <die calls>: Use EXIT_FAILURE as first argument.
+
 2012-04-18  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	* src/rexec.c (do_exec): Set missing values for `sin_family' and
diff --git a/src/rexec.c b/src/rexec.c
index 6d83d0e..b3eacbb 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -116,6 +116,8 @@ static struct argp argp = {options, parse_opt, args_doc, doc};
 
 static void do_rexec (struct arguments *arguments);
 
+static int remote_err = EXIT_SUCCESS;
+
 int
 main (int argc, char **argv)
 {
@@ -164,7 +166,7 @@ main (int argc, char **argv)
 
   do_rexec (&arguments);
 
-  exit (EXIT_SUCCESS);
+  exit (remote_err);
 }
 
 static void
@@ -220,6 +222,7 @@ do_rexec (struct arguments *arguments)
     {
       struct sockaddr_in serv_addr;
       socklen_t len;
+      int on = 1;
       int serv_sock = socket (AF_INET, SOCK_STREAM, 0);
 
       if (serv_sock < 0)
@@ -232,6 +235,7 @@ do_rexec (struct arguments *arguments)
       serv_addr.sin_len = sizeof (serv_addr);
 #endif
       serv_addr.sin_port = arguments->err_port;
+      setsockopt (serv_sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
       if (bind (serv_sock, (struct sockaddr *) &serv_addr,
 		sizeof (serv_addr)) < 0)
         error (EXIT_FAILURE, errno, "cannot bind socket");
@@ -262,7 +266,8 @@ do_rexec (struct arguments *arguments)
 
   while (1)
     {
-      int ret;
+      int consumed = 0;		/* Signals remote return status.  */
+      int ret, offset;
       fd_set rsocks;
 
       /* No other data to read.  */
@@ -314,8 +319,17 @@ do_rexec (struct arguments *arguments)
               continue;
             }
 
-          if (write (STDOUT_FILENO, buffer, err) < 0)
+	  offset = 0;
+
+	  if ((err > 0) && (consumed < 2))	/* Status can be two chars.  */
+	    while ((err > offset) && (offset < 2)
+		   && (buffer[offset] == 0 || buffer[offset] == 1))
+	      remote_err = buffer[offset++];
+
+          if (write (STDOUT_FILENO, buffer + offset, err - offset) < 0)
             error (EXIT_FAILURE, errno, "error writing");
+
+	  consumed += err;
         }
 
      if (0 <= err_sock && FD_ISSET (err_sock, &rsocks))
@@ -332,8 +346,17 @@ do_rexec (struct arguments *arguments)
               continue;
             }
 
-          if (write (STDERR_FILENO, buffer, err) < 0)
+	  offset = 0;
+
+	  if ((err > 0) && (consumed < 2))	/* Status can be two chars.  */
+	    while ((err > offset) && (offset < 2)
+		   && (buffer[offset] == 0 || buffer[offset] == 1))
+	      remote_err = buffer[offset++];
+
+          if (write (STDERR_FILENO, buffer + offset, err - offset) < 0)
             error (EXIT_FAILURE, errno, "error writing to stderr");
+
+	  consumed += err;
         }
     }
 }
diff --git a/src/rexecd.c b/src/rexecd.c
index a888c0f..db804d5 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -127,12 +127,14 @@ main (int argc, char **argv)
   exit (EXIT_SUCCESS);
 }
 
-char username[20] = "USER=";
-char logname[23] = "LOGNAME=";
-char homedir[64] = "HOME=";
-char shell[64] = "SHELL=";
+/* Set lengths of USER and LOGNAME longer than
+ * the REXEC protocol prescribes.  */
+char username[32 + sizeof ("USER=")] = "USER=";
+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, 0 };
+char *envinit[] = { homedir, shell, path, username, logname, NULL };
 extern char **environ;
 
 #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
@@ -205,6 +207,7 @@ doit (int f, struct sockaddr_in *fromp)
       s = socket (AF_INET, SOCK_STREAM, 0);
       if (s < 0)
 	exit (EXIT_FAILURE);
+      setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
       if (bind (s, (struct sockaddr *) &a_sin, sizeof (a_sin)) < 0)
 	exit (EXIT_FAILURE);
       alarm (60);
@@ -221,7 +224,7 @@ doit (int f, struct sockaddr_in *fromp)
   setpwent ();
   pwd = getpwnam (user);
   if (pwd == NULL)
-    die (1, "Login incorrect.");
+    die (EXIT_FAILURE, "Login incorrect.");
 
   endpwent ();
   pw_password = get_user_password (pwd);
@@ -229,7 +232,7 @@ doit (int f, struct sockaddr_in *fromp)
     {
       namep = crypt (pass, pw_password);
       if (strcmp (namep, pw_password))
-	die (1, "Password incorrect.");
+	die (EXIT_FAILURE, "Password incorrect.");
     }
   write (STDERR_FILENO, "\0", 1);
   if (port)
@@ -237,7 +240,7 @@ doit (int f, struct sockaddr_in *fromp)
       pipe (pv);
       pid = fork ();
       if (pid == -1)
-	die (1, "Try again.");
+	die (EXIT_FAILURE, "Try again.");
 
       if (pid)
 	{
@@ -303,12 +306,13 @@ doit (int f, struct sockaddr_in *fromp)
   if (setuid ((uid_t) pwd->pw_uid) < 0)
     error (EXIT_FAILURE, errno, "failed to set user-ID");
   if (chdir (pwd->pw_dir) < 0)
-    die (1, "No remote directory.");
+    die (EXIT_FAILURE, "No remote directory.");
   strcat (path, PATH_DEFPATH);
   environ = envinit;
-  strncat (homedir, pwd->pw_dir, sizeof (homedir) - 6);
-  strncat (shell, pwd->pw_shell, sizeof (shell) - 7);
-  strncat (username, pwd->pw_name, sizeof (username) - 6);
+  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);
   cp = strrchr (pwd->pw_shell, '/');
   if (cp)
     cp++;
@@ -345,7 +349,7 @@ getstr (const char *err)
   char *buf = malloc (buf_len), *end = buf;
 
   if (!buf)
-    die (1, "Out of space reading %s", err);
+    die (EXIT_FAILURE, "Out of space reading %s", err);
 
   do
     {
@@ -354,7 +358,7 @@ getstr (const char *err)
       if (rd <= 0)
 	{
 	  if (rd == 0)
-	    die (1, "EOF reading %s", err);
+	    die (EXIT_FAILURE, "EOF reading %s", err);
 	  else
 	    error (EXIT_FAILURE, 0, "%s", err);
 	}
@@ -367,7 +371,7 @@ getstr (const char *err)
 	  buf_len += buf_len;
 	  buf = realloc (buf, buf_len);
 	  if (!buf)
-	    die (1, "Out of space reading %s", err);
+	    die (EXIT_FAILURE, "Out of space reading %s", err);
 	  end = buf + end_offs;
 	}
     }

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


commit f730d11f7f578db86ec699c619f4a65e7ac60752
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed Apr 18 16:53:20 2012 +0200

    rexec, rexecd: Corrected functionality.

diff --git a/ChangeLog b/ChangeLog
index 8774399..b3eb406 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-04-18  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* src/rexec.c (do_exec): Set missing values for `sin_family' and
+	`sin_len' in SERV_ADDR.
+	* src/rexecd.c (die): Use vsnprintf() for variadic lists!  Send
+	also final newline character.  Call exit() at the end!
+
 2012-04-13  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Improve checking of FTP access verification.
diff --git a/src/rexec.c b/src/rexec.c
index 57d6aee..6d83d0e 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -227,6 +227,10 @@ do_rexec (struct arguments *arguments)
 
       memset (&serv_addr, 0, sizeof (serv_addr));
 
+      serv_addr.sin_family = AF_INET;
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+      serv_addr.sin_len = sizeof (serv_addr);
+#endif
       serv_addr.sin_port = arguments->err_port;
       if (bind (serv_sock, (struct sockaddr *) &serv_addr,
 		sizeof (serv_addr)) < 0)
diff --git a/src/rexecd.c b/src/rexecd.c
index d5a7fc7..a888c0f 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -329,12 +329,13 @@ die (int code, const char *fmt, ...)
 
   va_start (ap, fmt);
   buf[0] = 1;
-  n = snprintf (buf + 1, sizeof buf - 1, fmt, ap);
+  n = vsnprintf (buf + 1, sizeof buf - 1, fmt, ap);
   va_end (ap);
   if (n > sizeof buf - 1)
     n = sizeof buf - 1;
-  buf[n] = '\n';
+  buf[n++] = '\n';
   write (STDERR_FILENO, buf, n);
+  exit (code);
 }
 
 char *

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

Summary of changes:
 ChangeLog    |   46 +++++++++++++++++
 src/rexec.c  |  153 ++++++++++++++++++++++++++++++++++++++++++++-------------
 src/rexecd.c |   73 +++++++++++++++-------------
 3 files changed, 204 insertions(+), 68 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Apr 20 09:28:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLDsu-0005rp-Il
	for mharc-commit-inetutils@gnu.org; Fri, 20 Apr 2012 09:28:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46496)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLDso-0005rG-0T
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 09:28:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLDsi-0001AR-D7
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 09:28:17 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46996)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLDsi-00019c-9W
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 09:28:12 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SLDsg-0007Cl-Ud
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 13:28:11 +0000
Date: Fri, 20 Apr 2012 13:28:11 +0000
Message-Id: <E1SLDsg-0007Cl-Ud@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-78-g3aae672
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 6dec6e1745be4386f3bc48ad6ca6df7e27100fe7
X-Git-Newrev: 3aae672f300bd655d4a86405183ee462ad1abc34
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, 20 Apr 2012 13:28:22 -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  3aae672f300bd655d4a86405183ee462ad1abc34 (commit)
      from  6dec6e1745be4386f3bc48ad6ca6df7e27100fe7 (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=3aae672f300bd655d4a86405183ee462ad1abc34


commit 3aae672f300bd655d4a86405183ee462ad1abc34
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Apr 20 14:04:36 2012 +0200

    ping, ping6, traceroute: 64-bit portability issues.

diff --git a/ChangeLog b/ChangeLog
index e1aa06f..9c3308e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-04-20  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Portability issue found on 64-bit OpenBSD.
+
+	* ping/ping.c (ping_run): Break infinite loop by calling error()
+	after failure in select().
+	* ping/ping6.c (ping_run): Likewise.  Clear RESP_TIME.
+	* src/traceroute.c (do_try): New variable FD.  Clear TIME and
+	calculate NOW before calling select().  Set `fd + 1' to be the
+	maximal file descriptor when calling select().  On failure in
+	select(), return `errno' for proper detection, not EPERM.
+
+2012-04-20  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	rexec, rexecd: Implement support for IPv6.
 
 	* src/rexec.c (options): New `-4/ipv4', `-6/ipv6', and `-a/ipany'.
diff --git a/ping/ping.c b/ping/ping.c
index edfd758..462cc22 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -372,7 +372,7 @@ ping_run (PING * ping, int (*finish) ())
       if (n < 0)
 	{
 	  if (errno != EINTR)
-	    perror ("select");
+	    error (EXIT_FAILURE, errno, "select failed");
 	  continue;
 	}
       else if (n == 1)
diff --git a/ping/ping6.c b/ping/ping6.c
index 5647ded..445ced8 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -305,6 +305,7 @@ 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;
 
@@ -326,7 +327,7 @@ ping_run (PING * ping, int (*finish) ())
       if (n < 0)
 	{
 	  if (errno != EINTR)
-	    perror ("select");
+	    error (EXIT_FAILURE, errno, "select failed");
 	  continue;
 	}
       else if (n == 1)
diff --git a/src/traceroute.c b/src/traceroute.c
index 1d53d1e..df17661 100644
--- a/src/traceroute.c
+++ b/src/traceroute.c
@@ -240,22 +240,26 @@ do_try (trace_t * trace, const int hop,
 
   for (tries = 0; tries < max_tries; tries++)
     {
+      int fd = trace_icmp_sock (trace);
+
       FD_ZERO (&readset);
-      FD_SET (trace_icmp_sock (trace), &readset);
+      FD_SET (fd, &readset);
 
+      memset (&time, 0, sizeof (time));		/* 64-bit issue.  */
       time.tv_sec = TIME_INTERVAL;
       time.tv_usec = 0;
 
       if (!readonly)
 	trace_write (trace);
 
-      ret = select (FD_SETSIZE, &readset, NULL, NULL, &time);
-
       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 (ret < 0)
 	{
 	  switch (errno)
@@ -264,7 +268,7 @@ do_try (trace_t * trace, const int hop,
 	      /* was interrupted */
 	      break;
 	    default:
-              error (EXIT_FAILURE, EPERM, "select failed");
+              error (EXIT_FAILURE, errno, "select failed");
 	      break;
 	    }
 	}
@@ -276,7 +280,7 @@ do_try (trace_t * trace, const int hop,
 	}
       else
 	{
-	  if (FD_ISSET (trace_icmp_sock (trace), &readset))
+	  if (FD_ISSET (fd, &readset))
 	    {
 	      triptime = ((double) now.tv_sec) * 1000.0 +
 		((double) now.tv_usec) / 1000.0;

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

Summary of changes:
 ChangeLog        |   12 ++++++++++++
 ping/ping.c      |    2 +-
 ping/ping6.c     |    3 ++-
 src/traceroute.c |   14 +++++++++-----
 4 files changed, 24 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Apr 20 22:34:19 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLQ9T-0005Pz-HD
	for mharc-commit-inetutils@gnu.org; Fri, 20 Apr 2012 22:34:19 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52108)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLQ9N-0005Pm-5W
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 22:34:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLQ9G-0003vI-AV
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 22:34:12 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:32874)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLQ9G-0003vC-6o
	for commit-inetutils@gnu.org; Fri, 20 Apr 2012 22:34:06 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SLQ9F-00047F-Bj
	for commit-inetutils@gnu.org; Sat, 21 Apr 2012 02:34:05 +0000
Date: Sat, 21 Apr 2012 02:34:05 +0000
Message-Id: <E1SLQ9F-00047F-Bj@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-79-g126e416
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3aae672f300bd655d4a86405183ee462ad1abc34
X-Git-Newrev: 126e4166ea32331b792ffec665c49854826896bc
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, 21 Apr 2012 02:34:18 -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  126e4166ea32331b792ffec665c49854826896bc (commit)
      from  3aae672f300bd655d4a86405183ee462ad1abc34 (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=126e4166ea32331b792ffec665c49854826896bc


commit 126e4166ea32331b792ffec665c49854826896bc
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Apr 21 04:03:11 2012 +0200

    rexecd: Protocol conformity and privilege audit.

diff --git a/ChangeLog b/ChangeLog
index 9c3308e..b632cf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-04-21  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexecd: Privilege audit and protocol conformity.
+
+	* src/rexecd.c (doit): Execute changes of group as
+	soon as password has been verified.  Remove useless
+	call to setegid().  Protect setpgid() by the macro
+	HAVE_SETPGID.  Delay sending the single NUL character
+	until the time immediately before execution is handed
+	over to a shell interpreter.
+
 2012-04-20  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Portability issue found on 64-bit OpenBSD.
diff --git a/src/rexecd.c b/src/rexecd.c
index 87b1098..5c014fe 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -47,6 +47,10 @@
  * SUCH DAMAGE.
  */
 
+/* TODO: Implement PAM support as `rexec' service.
+ *       Pending with Mats Erik Andersson.
+ */
+
 #include <config.h>
 
 #include <sys/types.h>
@@ -196,6 +200,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
       port = port * 10 + c - '0';
     }
   alarm (0);
+
   if (port != 0)
     {
       s = socket (fromp->sa_family, SOCK_STREAM, 0);
@@ -224,11 +229,14 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   cmdbuf = getstr ("command");
 
   setpwent ();
+
   pwd = getpwnam (user);
   if (pwd == NULL)
     die (EXIT_FAILURE, "Login incorrect.");
 
   endpwent ();
+
+  /* Last need of elevated privilege.  */
   pw_password = get_user_password (pwd);
   if (*pw_password != '\0')
     {
@@ -236,7 +244,24 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
       if (strcmp (namep, pw_password))
 	die (EXIT_FAILURE, "Password incorrect.");
     }
-  write (STDERR_FILENO, "\0", 1);
+
+  /* Step down from superuser personality.
+   *
+   * The changing of group membership will seldomly
+   * fail, but a relevant message is passed just in
+   * case.  These messages are non-standard.
+   */
+  if (setgid ((gid_t) pwd->pw_gid) < 0)
+    die (EXIT_FAILURE, "Failed group protections.");
+
+#ifdef HAVE_INITGROUPS
+  if (initgroups (pwd->pw_name, pwd->pw_gid) < 0)
+    die (EXIT_FAILURE, "Failed group protections.");
+#endif
+
+  if (setuid ((uid_t) pwd->pw_uid) < 0)
+    die (EXIT_FAILURE, "Failed user identity.");
+
   if (port)
     {
       pipe (pv);
@@ -287,39 +312,43 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 	  while (FD_ISSET (pv[0], &readfrom) || FD_ISSET (s, &readfrom));
 	  exit (EXIT_SUCCESS);
 	}
+#ifdef HAVE_SETPGID
       setpgid (0, getpid ());
+#endif
       close (s);
       close (pv[0]);
       dup2 (pv[1], STDERR_FILENO);
     }
-  if (*pwd->pw_shell == '\0')
-    pwd->pw_shell = PATH_BSHELL;
+
   if (f > 2)
     close (f);
-  if (setegid ((gid_t) pwd->pw_gid) < 0)
-    error (EXIT_FAILURE, errno, "failed to set additional groups");
-  if (setgid ((gid_t) pwd->pw_gid) < 0)
-    error (EXIT_FAILURE, errno, "failed to set group-ID");
-#ifdef HAVE_INITGROUPS
-  if (initgroups (pwd->pw_name, pwd->pw_gid) < 0)
-    error (EXIT_FAILURE, errno,
-	   "failed to initialize the supplementary group access list");
-#endif
-  if (setuid ((uid_t) pwd->pw_uid) < 0)
-    error (EXIT_FAILURE, errno, "failed to set user-ID");
+
+  /* Last point of failure due to incorrect user settings.  */
   if (chdir (pwd->pw_dir) < 0)
     die (EXIT_FAILURE, "No remote directory.");
+
   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);
+
+  if (*pwd->pw_shell == '\0')
+    pwd->pw_shell = PATH_BSHELL;
+
   cp = strrchr (pwd->pw_shell, '/');
   if (cp)
     cp++;
   else
     cp = pwd->pw_shell;
+
+  /* This is the 7th step in the protocol standard.
+   * All authentication has been successful, and the
+   * execution can be handed over to the requested shell.
+   */
+  write (STDERR_FILENO, "\0", 1);
+
   execl (pwd->pw_shell, cp, "-c", cmdbuf, NULL);
   error (EXIT_FAILURE, errno, "executing %s", pwd->pw_shell);
 

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

Summary of changes:
 ChangeLog    |   11 +++++++++++
 src/rexecd.c |   57 +++++++++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 54 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Sat Apr 21 18:43:28 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SLj1c-0005pV-JT
	for mharc-commit-inetutils@gnu.org; Sat, 21 Apr 2012 18:43:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38945)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLj1W-0005oy-1x
	for commit-inetutils@gnu.org; Sat, 21 Apr 2012 18:43:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLj1Q-0005vR-DJ
	for commit-inetutils@gnu.org; Sat, 21 Apr 2012 18:43:21 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:45446)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SLj1Q-0005vN-97
	for commit-inetutils@gnu.org; Sat, 21 Apr 2012 18:43:16 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SLj1P-0004br-72
	for commit-inetutils@gnu.org; Sat, 21 Apr 2012 22:43:15 +0000
Date: Sat, 21 Apr 2012 22:43:15 +0000
Message-Id: <E1SLj1P-0004br-72@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-80-g6129edc
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 126e4166ea32331b792ffec665c49854826896bc
X-Git-Newrev: 6129edc81cd2dba78628a0297c39c25b0ffb3956
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, 21 Apr 2012 22:43:27 -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  6129edc81cd2dba78628a0297c39c25b0ffb3956 (commit)
      from  126e4166ea32331b792ffec665c49854826896bc (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=6129edc81cd2dba78628a0297c39c25b0ffb3956


commit 6129edc81cd2dba78628a0297c39c25b0ffb3956
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sun Apr 22 00:28:24 2012 +0200

    rexecd: Implement system logging.
    
    Include a timeout in the client `rexec'
    to avoid waiting locks.

diff --git a/ChangeLog b/ChangeLog
index b632cf7..1f1faaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2012-04-22  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexecd: Implement syslog support.
+
+	* src/rexecd.c: Include <syslog.h>.
+	(logging, options): New variables.
+	(parse_opt): New function.
+	(argp): Insert `options' and `parse_opt'.
+	(main): Call openlog().  Do not exit at surplus arguments,
+	but make a note in syslog.  Log failed getpeername().
+	(doit): New variables RHOST and RET.  In addition to error()
+	and die(), make many entries in the syslog of varying severity.
+
+	* src/rexec.c (do_rexec): Add a five second alarm around
+	accept() for stderr channel, in case the server side is
+	not responding.
+
+	* doc/inetutils.texi (rexec, rexecd): Document recent
+	additions.  Make option encoding for `rexec' complete.
+
 2012-04-21  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd: Privilege audit and protocol conformity.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 1078256..180d4ca 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -1928,26 +1928,62 @@ rexec --user=@var{login} --password=@var{pass} --host=@var{host}  \
 
 The command line arguments are as follows:
 
-@table @var
-@item --error
+@table @option
+@item -4
+@itemx --ipv4
+@opindex -4
+@opindex --ipv4
+Use only IPv4 connections as all times.
+
+@item -6
+@itemx --ipv6
+@opindex -6
+@opindex --ipv6
+Use only IPv6 connections.
+
+@item -a
+@itemx --ipany
+@opindex -a
+@opindex --ipany
+Allow any address family for connections.  This is the default.
+
+@item -e
+@itemx --error=@var{port}
+@opindex -e
+@opindex --error
 Specify the TCP port to use for stderr redirection, in case it is not
 specified a random port will be used.
 
-@item --host
-Specify the host where connect to.
+@item -h
+@item --host=@var{name}
+@opindex -h
+@opindex --host
+Specify the host with whom to connect: symbolic name or address.
 
-@item --noerr
+@item -n
+@itemx --noerr
+@opindex -n
+@opindex --noerr
 If specified, an error stream will not be created.
 
-@item --password
+@item -p
+@itemx --password=@var{passwd}
+@opindex -p
+@opindex --password
 Specify the password for logging-in.
 
-@item --port
-Specify to which port connect to, if it is not specified by default
-use 512.
+@item -P
+@itemx --port=@var{num}
+@opindex -P
+@opindex --port
+Specify to which numerical port a connection shall be sought.
+If it is not specified, then use port 512/tcp by default.
 
-@item --user
-Specify the user to log into the server.
+@item -u
+@itemx --user=@var{name}
+@opindex -u
+@opindex --user
+Specify the user with whom to log into the server.
 @end table
 
 
@@ -3316,7 +3352,8 @@ useful in an ``open'' environment.
 
 @command{rexecd} is the server for the @code{Rexec} routine.  The
 server provides remote execution facilities with authentication based
-on user names and passwords.
+on user names and passwords.  It passes error messages and notices
+to the @code{syslog} facility @samp{LOG_DAEMON}.
 
 @example
 rexecd [@var{option}]@dots{}
@@ -3364,6 +3401,21 @@ passed to the normal login shell of the user.  The shell inherits the
 network connections established by rexecd.
 @end enumerate
 
+@section Invoking
+
+The only option is as follows:
+
+@table @option
+@item -l
+@itemx --logging
+@opindex -l
+@opindex --logging
+Raise logging level for this service; use more than once for
+increased verbosity.  The @code{syslog} facility in use is
+@samp{LOG_DAEMON}.
+
+@end table
+
 @section Diagnostics
 
 Except for the last one listed below, all diagnostic messages are
diff --git a/src/rexec.c b/src/rexec.c
index cbf7f7e..5b35238 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -307,10 +307,18 @@ do_rexec (struct arguments *arguments)
       snprintf (port_str, sizeof (port_str), "%u", arguments->err_port);
       safe_write (sock, port_str, strlen (port_str) + 1);
 
+      /* Limit waiting time in case the server fails to call back:
+       * if it aborts prematurely, or if a firewall is blocking
+       * the intended STDERR connection to reach us.
+       */
+      alarm (5);
+
       err_sock = accept (serv_sock, (struct sockaddr *) &serv_addr, &len);
       if (err_sock < 0)
         error (EXIT_FAILURE, errno, "error accepting connection");
 
+      alarm (0);
+
       shutdown (err_sock, SHUT_WR);
 
       close (serv_sock);
diff --git a/src/rexecd.c b/src/rexecd.c
index 5c014fe..6042032 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -82,6 +82,7 @@
 #ifdef HAVE_SHADOW_H
 # include <shadow.h>
 #endif
+#include <syslog.h>
 #include <progname.h>
 #include <argp.h>
 #include <error.h>
@@ -90,11 +91,33 @@
 void die (int code, const char *fmt, ...);
 int doit (int f, struct sockaddr *fromp, socklen_t fromlen);
 
+static int logging = 0;
+
+static struct argp_option options[] = {
+  { "logging", 'l', NULL, 0, "logging of requests and errors" },
+  { NULL }
+};
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case 'l':
+      ++logging;
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
 const char doc[] = "remote execution daemon";
 
 static struct argp argp = {
-  NULL,
-  NULL,
+  options,
+  parse_opt,
   NULL,
   doc,
   NULL,
@@ -121,12 +144,20 @@ main (int argc, char **argv)
 
   iu_argp_init ("rexecd", default_program_authors);
   argp_parse (&argp, argc, argv, 0, &index, NULL);
+
+  openlog ("rexecd", LOG_PID | LOG_ODELAY | LOG_NOWAIT, LOG_DAEMON);
+
   if (argc > index)
-    error (EXIT_FAILURE, 0, "surplus arguments");
+    /* Record this complaint locally.  */
+    syslog (LOG_NOTICE, "%d extra arguments", argc - index);
 
   fromlen = sizeof (from);
   if (getpeername (sockfd, (struct sockaddr *) &from, &fromlen) < 0)
-    error (EXIT_FAILURE, errno, "getpeername");
+    {
+      syslog (LOG_ERR, "getpeername: %m");
+      error (EXIT_FAILURE, errno, "getpeername");
+    }
+
   doit (sockfd, (struct sockaddr *) &from, fromlen);
   exit (EXIT_SUCCESS);
 }
@@ -161,7 +192,8 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   char *cmdbuf, *cp, *namep;
   char *user, *pass, *pw_password;
   struct passwd *pwd;
-  int s;
+  char rhost[INET6_ADDRSTRLEN];
+  int s, ret;
   in_port_t port;
   int pv[2], pid, cc;
   fd_set readfrom, ready;
@@ -188,13 +220,28 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
       dup2 (f, STDERR_FILENO);
     }
 
+  ret = getnameinfo (fromp, fromlen, rhost, sizeof (rhost),
+		     NULL, 0, NI_NUMERICHOST);
+  if (ret)
+    {
+      syslog (LOG_WARNING, "getnameinfo: %m");
+      strncpy (rhost, "(unknown)", sizeof (rhost));
+    }
+
+  if (logging > 1)
+    syslog (LOG_INFO, "request from \"%s\"", rhost);
+
   alarm (60);
   port = 0;
   for (;;)
     {
       char c;
       if (read (f, &c, 1) != 1)
-	exit (EXIT_FAILURE);
+	{
+	  if (logging)
+	    syslog (LOG_ERR, "main socket: %m");
+	  exit (EXIT_FAILURE);
+	}
       if (c == 0)
 	break;
       port = port * 10 + c - '0';
@@ -205,7 +252,11 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
     {
       s = socket (fromp->sa_family, SOCK_STREAM, 0);
       if (s < 0)
-	exit (EXIT_FAILURE);
+	{
+	  if (logging)
+	    syslog (LOG_ERR, "stderr socket: %m");
+	  exit (EXIT_FAILURE);
+	}
       setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
       alarm (60);
       switch (fromp->sa_family)
@@ -217,10 +268,18 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 	  ((struct sockaddr_in6 *) fromp)->sin6_port = htons (port);
 	  break;
 	default:
+	  syslog (LOG_ERR, "unknown address family %d", fromp->sa_family);
 	  exit (EXIT_FAILURE);
 	}
       if (connect (s, fromp, fromlen) < 0)
-	exit (EXIT_FAILURE);
+	{
+	  /* Use LOG_NOTICE since the remote part might cause
+	   * this error by blocking.  We are less probable.
+	   */
+	  if (logging)
+	    syslog (LOG_NOTICE, "connect: %m");
+	  exit (EXIT_FAILURE);
+	}
       alarm (0);
     }
 
@@ -232,7 +291,11 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 
   pwd = getpwnam (user);
   if (pwd == NULL)
-    die (EXIT_FAILURE, "Login incorrect.");
+    {
+      if (logging)
+	syslog (LOG_WARNING, "no user named \"%s\"", user);
+      die (EXIT_FAILURE, "Login incorrect.");
+    }
 
   endpwent ();
 
@@ -242,7 +305,11 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
     {
       namep = crypt (pass, pw_password);
       if (strcmp (namep, pw_password))
-	die (EXIT_FAILURE, "Password incorrect.");
+	{
+	  if (logging)
+	    syslog (LOG_WARNING, "password failure for \"%s\"", user);
+	  die (EXIT_FAILURE, "Password incorrect.");
+	}
     }
 
   /* Step down from superuser personality.
@@ -252,22 +319,36 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
    * case.  These messages are non-standard.
    */
   if (setgid ((gid_t) pwd->pw_gid) < 0)
-    die (EXIT_FAILURE, "Failed group protections.");
+    {
+      syslog (LOG_DEBUG, "setgid(gid = %d): %m", pwd->pw_gid);
+      die (EXIT_FAILURE, "Failed group protections.");
+    }
 
 #ifdef HAVE_INITGROUPS
   if (initgroups (pwd->pw_name, pwd->pw_gid) < 0)
-    die (EXIT_FAILURE, "Failed group protections.");
+    {
+      syslog (LOG_DEBUG, "initgroups(%s, %s): %m",
+	      pwd->pw_name, pwd->pw_gid);
+      die (EXIT_FAILURE, "Failed group protections.");
+    }
 #endif
 
   if (setuid ((uid_t) pwd->pw_uid) < 0)
-    die (EXIT_FAILURE, "Failed user identity.");
+    {
+      syslog (LOG_DEBUG, "setuid(uid = %d): %m", pwd->pw_uid);
+      die (EXIT_FAILURE, "Failed user identity.");
+    }
 
   if (port)
     {
       pipe (pv);
       pid = fork ();
       if (pid == -1)
-	die (EXIT_FAILURE, "Try again.");
+	{
+	  if (logging)
+	    syslog (LOG_ERR, "forking for \"%s\": %m", user);
+	  die (EXIT_FAILURE, "Try again.");
+	}
 
       if (pid)
 	{
@@ -325,7 +406,11 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 
   /* Last point of failure due to incorrect user settings.  */
   if (chdir (pwd->pw_dir) < 0)
-    die (EXIT_FAILURE, "No remote directory.");
+    {
+      if (logging)
+	syslog (LOG_NOTICE, "\"%s\" uses invalid \"%s\"", user, pwd->pw_dir);
+      die (EXIT_FAILURE, "No remote directory.");
+    }
 
   strcat (path, PATH_DEFPATH);
   environ = envinit;
@@ -348,8 +433,12 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
    * execution can be handed over to the requested shell.
    */
   write (STDERR_FILENO, "\0", 1);
+  if (logging)
+    syslog (LOG_INFO, "accepted user \"%s\" from %s", user, rhost);
 
   execl (pwd->pw_shell, cp, "-c", cmdbuf, NULL);
+  if (logging)
+    syslog (LOG_ERR, "execl fails for \"%s\": %m", user);
   error (EXIT_FAILURE, errno, "executing %s", pwd->pw_shell);
 
   return -1;

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

Summary of changes:
 ChangeLog          |   20 +++++++++
 doc/inetutils.texi |   76 ++++++++++++++++++++++++++++-----
 src/rexec.c        |    8 ++++
 src/rexecd.c       |  119 +++++++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 196 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Tue Apr 24 16:13:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SMm7S-0003Ls-Jc
	for mharc-commit-inetutils@gnu.org; Tue, 24 Apr 2012 16:13:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46021)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SMm7O-0003Ig-Dy
	for commit-inetutils@gnu.org; Tue, 24 Apr 2012 16:13:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SMm7M-0001CY-Ba
	for commit-inetutils@gnu.org; Tue, 24 Apr 2012 16:13:45 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:37150)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SMm7M-0001CS-8l
	for commit-inetutils@gnu.org; Tue, 24 Apr 2012 16:13:44 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SMm7L-000197-0d
	for commit-inetutils@gnu.org; Tue, 24 Apr 2012 20:13:43 +0000
Date: Tue, 24 Apr 2012 20:13:43 +0000
Message-Id: <E1SMm7L-000197-0d@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-81-g32ef549
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 6129edc81cd2dba78628a0297c39c25b0ffb3956
X-Git-Newrev: 32ef5496304612223b50cffcd4c639544201b4e7
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, 24 Apr 2012 20:13:49 -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  32ef5496304612223b50cffcd4c639544201b4e7 (commit)
      from  6129edc81cd2dba78628a0297c39c25b0ffb3956 (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=32ef5496304612223b50cffcd4c639544201b4e7


commit 32ef5496304612223b50cffcd4c639544201b4e7
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue Apr 24 22:13:26 2012 +0200

    rexec: Password from stdin.

diff --git a/ChangeLog b/ChangeLog
index 1f1faaf..5dec85a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-04-24  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexec: Read password from stdin.
+
+	* src/rexec.c (main): New variables PASSWORD and N.
+	If `arguments.password' is a single dash, read a line
+	from standard in and assign it to `arguments.password'.
+	* doc/inetutils.texi (rexec invocation):  Mention new
+	treatment of `-p/--password'.
+
 2012-04-22  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd: Implement syslog support.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 180d4ca..dc1b6a1 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -1970,7 +1970,13 @@ If specified, an error stream will not be created.
 @itemx --password=@var{passwd}
 @opindex -p
 @opindex --password
-Specify the password for logging-in.
+Specify the password for logging-in.  The special value
+consisting of a single dash @samp{-} will make @command{rexec}
+read a single line from stdin.  This input is then used
+as password and is passed as such to the remote server.
+Thus it is possible to hide vital access information
+slightly better than the full disclosure implicit in
+the text of a command line option.
 
 @item -P
 @itemx --port=@var{num}
diff --git a/src/rexec.c b/src/rexec.c
index 5b35238..cee880f 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -135,7 +135,8 @@ int
 main (int argc, char **argv)
 {
   struct arguments arguments;
-  int failed = 0;
+  char password[64];
+  int n, failed = 0;
   set_program_name (argv[0]);
 
   iu_argp_init ("rexec", program_authors);
@@ -178,6 +179,27 @@ main (int argc, char **argv)
   if (failed > 0)
     exit (EXIT_FAILURE);
 
+  if (strcmp ("-", arguments.password) == 0)
+    {
+      password[0] = '\0';
+
+      alarm (15);
+      fgets (password, sizeof (password), stdin);
+      alarm (0);
+
+      n = strlen (password);
+      if ((n > 0) && (password[n - 1] == '\n'))
+	{
+	  password[n - 1] = '\0';
+	  --n;
+	}
+
+      if (n == 0)
+	error (EXIT_FAILURE, 0, "empty password");
+      else
+	arguments.password = password;
+    }
+
   do_rexec (&arguments);
 
   exit (remote_err);

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

Summary of changes:
 ChangeLog          |   10 ++++++++++
 doc/inetutils.texi |    8 +++++++-
 src/rexec.c        |   24 +++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Apr 26 20:08:54 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SNYk2-0006ce-3N
	for mharc-commit-inetutils@gnu.org; Thu, 26 Apr 2012 20:08:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60196)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SNYjz-0006cQ-RH
	for commit-inetutils@gnu.org; Thu, 26 Apr 2012 20:08:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SNYjx-0003lp-JE
	for commit-inetutils@gnu.org; Thu, 26 Apr 2012 20:08:51 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:54355)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SNYjx-0003lk-GN
	for commit-inetutils@gnu.org; Thu, 26 Apr 2012 20:08:49 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SNYjw-0000gP-On
	for commit-inetutils@gnu.org; Fri, 27 Apr 2012 00:08:49 +0000
Date: Fri, 27 Apr 2012 00:08:48 +0000
Message-Id: <E1SNYjw-0000gP-On@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-82-g1534341
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 32ef5496304612223b50cffcd4c639544201b4e7
X-Git-Newrev: 153434103dc0b365bd1d187a2c72d2e4a62a27a8
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, 27 Apr 2012 00:08:53 -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  153434103dc0b365bd1d187a2c72d2e4a62a27a8 (commit)
      from  32ef5496304612223b50cffcd4c639544201b4e7 (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=153434103dc0b365bd1d187a2c72d2e4a62a27a8


commit 153434103dc0b365bd1d187a2c72d2e4a62a27a8
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Apr 27 01:50:13 2012 +0200

    ping: Payload adjustment.

diff --git a/ChangeLog b/ChangeLog
index 5dec85a..c9c12dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-04-27  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* ping/ping_address.c (print_address): Remove duplicate
+	prototype.  Print additional newline to conform with output
+	formatting for other types of reporting.
+	* ping/ping_echo.c (ping_echo)
+	[(options & OPT_ROUTE) & IP_OPTIONS]: Increase data length
+	to accomodate the amount used for record routes in IP header.
+
 2012-04-24  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexec: Read password from stdin.
diff --git a/ping/ping_address.c b/ping/ping_address.c
index 04574d7..fedc82f 100644
--- a/ping/ping_address.c
+++ b/ping/ping_address.c
@@ -50,9 +50,6 @@ static int recv_address (int code, void *closure,
 static void print_address (int dupflag, void *closure,
 			   struct sockaddr_in *dest, struct sockaddr_in *from,
 			   struct ip *ip, icmphdr_t * icmp, int datalen);
-static void print_address (int dupflag, void *closure,
-			   struct sockaddr_in *dest, struct sockaddr_in *from,
-			   struct ip *ip, icmphdr_t * icmp, int datalen);
 static int address_finish (void);
 
 int
@@ -103,6 +100,7 @@ print_address (int dupflag, void *closure,
 	  icmp->icmp_seq);
   if (dupflag)
     printf (" (DUP!)");
+  printf ("\n");
   addr.s_addr = icmp->icmp_mask;
   printf ("icmp_mask = %s", inet_ntoa (addr));
   printf ("\n");
diff --git a/ping/ping_echo.c b/ping/ping_echo.c
index 0278e35..f62582b 100644
--- a/ping/ping_echo.c
+++ b/ping/ping_echo.c
@@ -95,6 +95,8 @@ 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.");

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

Summary of changes:
 ChangeLog           |    9 +++++++++
 ping/ping_address.c |    4 +---
 ping/ping_echo.c    |    2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


