From MAILER-DAEMON Fri Jun 01 18:31:44 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SaaNk-0007um-CP
	for mharc-commit-inetutils@gnu.org; Fri, 01 Jun 2012 18:31:44 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44822)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SaaNg-0007uL-0i
	for commit-inetutils@gnu.org; Fri, 01 Jun 2012 18:31:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SaaNc-0006DD-TM
	for commit-inetutils@gnu.org; Fri, 01 Jun 2012 18:31:39 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56620)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SaaNc-0006D7-Oe
	for commit-inetutils@gnu.org; Fri, 01 Jun 2012 18:31:36 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SaaNb-0006e6-B4
	for commit-inetutils@gnu.org; Fri, 01 Jun 2012 22:31:36 +0000
Date: Fri, 01 Jun 2012 22:31:35 +0000
Message-Id: <E1SaaNb-0006e6-B4@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-107-g3370c78
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 890be117d428028e4e77608303416598c163c158
X-Git-Newrev: 3370c78d40133eae964a669342a3a2be4cf229ef
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, 01 Jun 2012 22:31:42 -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  3370c78d40133eae964a669342a3a2be4cf229ef (commit)
       via  3d90d83248d0a632c8080cf2970eda50f835e665 (commit)
      from  890be117d428028e4e77608303416598c163c158 (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=3370c78d40133eae964a669342a3a2be4cf229ef


commit 3370c78d40133eae964a669342a3a2be4cf229ef
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Jun 2 00:21:19 2012 +0200

    ftpd: Long passive transfer request.
    
    Add the command request `LPSV'.

diff --git a/ChangeLog b/ChangeLog
index 58a1836..5504e7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2012-06-02  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Long passive transfer request.
+
+	* ftpd/extern.h (PASSIVE_PASV, PASSIVE_EPSV, PASSIVE_LPSV):
+	New macros.
+	* ftpd/ftpcmd.y (LPSV): New token.
+	(cmd) <PASV>: Call passive() with PASSIVE_PASV.
+	<EPSV>: Call passive() with PASSIVE_EPSV; both variants.
+	<LPSV>: New subcommand.
+	(cmdtab): New entry `LPSV'.
+	* ftpd/ftpd.c (passive): Use macros PASSIVE_* to distinguish
+	subcases.  Add two subcases for `LPSV', with pointer math
+	shared with `PASV'.
+	* doc/inetutils.texi: Updated.
+
 2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftp: Adaptive block size in image mode.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 6de8d94..d048397 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -2897,10 +2897,11 @@ case of the requests is ignored.
 @item CDUP         @tab  change to parent of current working directory
 @item CWD          @tab  change working directory
 @item DELE         @tab  delete a file
-@item EPSV         @tab  prepare for server-to-server transfer
+@item EPSV         @tab  extended passive transfer request
 @item EPRT         @tab  specify data connection port
 @item HELP         @tab  give help information
 @item LIST         @tab  give list files in a directory (``ls -lgA'')
+@item LPSV         @tab  long passive transfer request
 @item MKD          @tab  make a directory
 @item MDTM         @tab  show last modification time of file
 @item MODE         @tab  specify data transfer mode
@@ -2946,7 +2947,7 @@ the @code{SITE} request.
 The remaining FTP requests specified in RFC 959 are recognized, but
 not implemented.  The extensions @code{MDTM}, @code{REST},
 and @code{SIZE} are specified in RFC 3659, while @code{EPRT}
-and @code{EPSV} appear in RFC 2428.
+and @code{EPSV} appear in RFC 2428, and @code{LPSV} in RFC 1639.
 
 The ftp server will abort an active file transfer only when the
 @code{ABOR} command is preceded by a Telnet @samp{Interrupt Process}
diff --git a/ftpd/extern.h b/ftpd/extern.h
index acf673f..ed53cce 100644
--- a/ftpd/extern.h
+++ b/ftpd/extern.h
@@ -113,6 +113,11 @@ extern char tmpline[];
 /* Exported from ftpcmd.y.  */
 extern off_t restart_point;
 
+/* Distinguish passive address modes.  */
+#define PASSIVE_PASV 0
+#define PASSIVE_EPSV 1
+#define PASSIVE_LPSV 2
+
 /* Exported from server_mode.c.  */
 extern int usefamily;
 extern int server_mode (const char *pidfile, struct sockaddr *phis_addr,
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index f8099bd..1fd0ac6 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -50,11 +50,12 @@
 /*
  * Grammar for FTP commands:
  *
- *   See RFC 959, RFC 2428, and RFC 3659 (MDTM, REST, SIZE).
+ *   See RFC 959, RFC 1636 (LPSV), RFC 2428,
+ *   and RFC 3659 (MDTM, REST, SIZE).
  *
  * TODO: Update with RFC 3659 (MLST, MLSD).
  *
- * TODO: RFC 1639 (LPRT, LPSV).
+ * TODO: RFC 1639 (LPRT).
  *
  * TODO: RFC 2389 (FEAT, OPTS).
  *
@@ -150,7 +151,7 @@ static void yyerror       (const char *s);
 	STAT	HELP	NOOP	MKD	RMD	PWD
 	CDUP	STOU	SMNT	SYST	SIZE	MDTM
 
-	EPRT	EPSV
+	EPRT	EPSV	LPSV
 
 	UMASK	IDLE	CHMOD
 
@@ -230,7 +231,7 @@ cmd
 	| PASV check_login CRLF
 		{
 			if ($2)
-				passive(0, AF_INET);
+				passive(PASSIVE_PASV, AF_INET);
 		}
 	| TYPE SP type_code CRLF
 		{
@@ -709,17 +710,26 @@ cmd
 	| EPSV check_login CRLF
 		{
 			if ($2)
-				passive(1, AF_UNSPEC);
+				passive(PASSIVE_EPSV, AF_UNSPEC);
 		}
 	| EPSV check_login SP net_proto CRLF
 		{
 			if ($2) {
 				if ($4 > 0)
-					passive(1, $4);
+					passive(PASSIVE_EPSV, $4);
 				else
 					reply (522, "Network protocol not supported, use (1,2)");
 			}
 		}
+
+		/*
+		 * LPSV is in RFC 1639.
+		 */
+	| LPSV check_login CRLF
+		{
+			if ($2)
+				passive(PASSIVE_LPSV, 0 /* not used */);
+		}
 	| QUIT CRLF
 		{
 			reply(221, "Goodbye.");
@@ -1067,6 +1077,7 @@ struct tab cmdtab[] = {		/* In order defined in RFC 765 */
 	{ "MDTM", MDTM, OSTR, 1,	"<sp> path-name" },
 	{ "EPRT", EPRT, DLIST, 1,	"<sp> <d> proto <d> addr <d> port <d>" },
 	{ "EPSV", EPSV, ARGS, 1,	"[ <sp> af ]" },
+	{ "LPSV", LPSV, ARGS, 1,	"(set server in long passive mode)" },
 	{ NULL,   0,    0,    0,	0 }
 };
 
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 4c1711f..9014a1e 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -1819,7 +1819,7 @@ passive (int epsv, int af)
   int try_af;
 
   /* EPSV might ask for a particular address family.  */
-  if (epsv && af > 0)
+  if (epsv == PASSIVE_EPSV && af > 0)
     try_af = af;
   else
     try_af = ctrl_addr.ss_family;
@@ -1852,7 +1852,7 @@ passive (int epsv, int af)
   if (listen (pdata, 1) < 0)
     goto pasv_error;
 
-  if (epsv)
+  if (epsv == PASSIVE_EPSV)
     {
       /* EPSV for IPv4 and IPv6.  */
       reply (229, "Entering Extended Passive Mode (|||%u|)",
@@ -1861,13 +1861,16 @@ passive (int epsv, int af)
 		    : ((struct sockaddr_in6 *) &pasv_addr)->sin6_port));
       return;
     }
-  else /* !epsv */
+  else /* !EPSV */
     {
-      /* PASV for IPv4.
+      /* PASV for IPv4, or LPSV for IPv4 or IPv6.
        *
        * Some systems, like OpenSolaris, prefer to return
        * an IPv4-mapped-IPv6 address, which must be processed
        * for printout.  */
+
+#define UC(b) (((int) b) & 0xff)
+
       if (pasv_addr.ss_family == AF_INET6
 	  && IN6_IS_ADDR_V4MAPPED (&((struct sockaddr_in6 *) &pasv_addr)->sin6_addr))
 	{
@@ -1875,16 +1878,38 @@ passive (int epsv, int af)
 	  a += 3 * sizeof (struct in_addr);	/* Skip padding up to IPv4 content.  */
 	  p = (char *) &((struct sockaddr_in6 *) &pasv_addr)->sin6_port;
 	}
+      else if (pasv_addr.ss_family == AF_INET6)
+	{
+	  /* LPSV for IPv6, not mapped. */
+	  a = (char *) &((struct sockaddr_in6 *) &pasv_addr)->sin6_addr;
+	  p = (char *) &((struct sockaddr_in6 *) &pasv_addr)->sin6_port;
+
+	  reply (228, "Entering Long Passive Mode "
+		 "(6,16,%d,%d,%d,%d,%d,%d,%d,%d"	/* a[0..7] */
+		 ",%d,%d,%d,%d,%d,%d,%d,%d"	/* a[8..15] */
+		 ",2,%d,%d)",	/* p0, p1 */
+		 UC (a[0]), UC (a[1]), UC (a[2]), UC (a[3]),
+		 UC (a[4]), UC (a[5]), UC (a[6]), UC (a[7]),
+		 UC (a[8]), UC (a[9]), UC (a[10]), UC (a[11]),
+		 UC (a[12]), UC (a[13]), UC (a[14]), UC (a[15]),
+		 UC (p[0]), UC (p[1]));
+	  return;
+	}
       else
 	{
 	  a = (char *) &((struct sockaddr_in *) &pasv_addr)->sin_addr;
 	  p = (char *) &((struct sockaddr_in *) &pasv_addr)->sin_port;
 	}
 
-#define UC(b) (((int) b) & 0xff)
-
-      reply (227, "Entering Passive Mode (%d,%d,%d,%d,%d,%d)", UC (a[0]),
-	     UC (a[1]), UC (a[2]), UC (a[3]), UC (p[0]), UC (p[1]));
+      if (epsv == PASSIVE_LPSV)
+	reply (228, "Entering Long Passive Mode "
+	       "(4,4,%d,%d,%d,%d,2,%d,%d)",
+	       UC (a[0]), UC (a[1]), UC (a[2]), UC (a[3]),
+	       UC (p[0]), UC (p[1]));
+      else
+	reply (227, "Entering Passive Mode (%d,%d,%d,%d,%d,%d)",
+	       UC (a[0]), UC (a[1]), UC (a[2]), UC (a[3]),
+	       UC (p[0]), UC (p[1]));
       return;
     }
 

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


commit 3d90d83248d0a632c8080cf2970eda50f835e665
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Jun 1 18:47:39 2012 +0200

    Documentation (silent change).

diff --git a/ChangeLog b/ChangeLog
index 9f72a57..58a1836 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
- 2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
+2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftp: Adaptive block size in image mode.
 
@@ -11,7 +11,7 @@
 	and set BLKSIZE to `st_blksize'.
 	(abort_remote): Replace macro BUFSIZ by `sizeof(buf)'.
 
- 2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
+2012-05-31  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Use adaptive block sizes in image mode.
 
@@ -24,7 +24,7 @@
 	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>
+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.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 2d81a83..6de8d94 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -2879,10 +2879,10 @@ is 15 minutes).
 Set default umask(base 8).
 @end table
 
-The file @file{/etc/nologin} can be used to disable ftp access.  If
-the file exists,@command{ ftpd} displays it and exits.  If the file
+The file @file{/etc/nologin} can be used to disable FTP access.  If
+the file exists, @command{ftpd} displays it and exits.  If the file
 @file{/etc/ftpwelcome} exists, @command{ftpd} prints it before issuing
-the @samp{ready} message.  If the file @command{/etc/motd} exists,
+the @samp{ready} message.  If the file @file{/etc/motd} exists,
 @command{ftpd} prints it after a successful login.
 
 The FTP server currently supports the following FTP requests.  The
@@ -2897,6 +2897,8 @@ case of the requests is ignored.
 @item CDUP         @tab  change to parent of current working directory
 @item CWD          @tab  change working directory
 @item DELE         @tab  delete a file
+@item EPSV         @tab  prepare for server-to-server transfer
+@item EPRT         @tab  specify data connection port
 @item HELP         @tab  give help information
 @item LIST         @tab  give list files in a directory (``ls -lgA'')
 @item MKD          @tab  make a directory
@@ -2930,20 +2932,21 @@ case of the requests is ignored.
 @item XRMD         @tab  remove a directory (deprecated)
 @end multitable
 
-The following non-standard or UNIX specific commands are supported by
+The following non-standard, or UNIX specific, commands are supported by
 the @code{SITE} request.
 
 @multitable @columnfractions 0.3 0.7
 @item Request      @tab  Description
-@item UMASK        @tab  change umask, e.g.  @code{SITE UMASK 002}
-@item IDLE         @tab  set idle-timer, e.g.  @code{SITE IDLE 60}
-@item CHMOD        @tab  change mode of a file, e.g.  @code{SITE CHMOD0 0CHMOD1 1CHMOD2}
+@item UMASK        @tab  change umask, e.g. @code{SITE UMASK 002}
+@item IDLE         @tab  set idle-timer, e.g. @code{SITE IDLE 60}
+@item CHMOD        @tab  change mode of a file, e.g. @code{SITE CHMOD0 0CHMOD1 1CHMOD2}
 @item HELP         @tab  give help information.
 @end multitable
 
 The remaining FTP requests specified in RFC 959 are recognized, but
-not implemented.  @code{MDTM} and @code{SIZE} are not specified in RFC
-959, but will appear in the next updated FTP RFC.
+not implemented.  The extensions @code{MDTM}, @code{REST},
+and @code{SIZE} are specified in RFC 3659, while @code{EPRT}
+and @code{EPSV} appear in RFC 2428.
 
 The ftp server will abort an active file transfer only when the
 @code{ABOR} command is preceded by a Telnet @samp{Interrupt Process}
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index 533a827..f8099bd 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -48,14 +48,15 @@
  */
 
 /*
- * Grammar for FTP commands.
- * See RFC 959.
+ * Grammar for FTP commands:
  *
- * TODO Update to RFC 3659
+ *   See RFC 959, RFC 2428, and RFC 3659 (MDTM, REST, SIZE).
  *
- * RFC 2428
+ * TODO: Update with RFC 3659 (MLST, MLSD).
  *
- * TODO RFC 1639
+ * TODO: RFC 1639 (LPRT, LPSV).
+ *
+ * TODO: RFC 2389 (FEAT, OPTS).
  *
  * FIXME: Rewrite with GNU standard formatting.  Legacy code is changed!
  */
@@ -542,8 +543,7 @@ cmd
 		}
 
 		/*
-		 * SIZE is not in RFC959, but Postel has blessed it and
-		 * it will be in the updated RFC.
+		 * SIZE is in RFC 3659.
 		 *
 		 * Return size of file in a format suitable for
 		 * using with RESTART (we just count bytes).
@@ -556,8 +556,7 @@ cmd
 		}
 
 		/*
-		 * MDTM is not in RFC959, but Postel has blessed it and
-		 * it will be in the updated RFC.
+		 * MDTM is in RFC 3659.
 		 *
 		 * Return modification time of file as an ISO 3307
 		 * style time. E.g. YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx
@@ -585,6 +584,10 @@ cmd
 			}
 			free($4);
 		}
+
+		/*
+		 * EPRT is in RFC 2428.
+		 */
 	| EPRT check_login SP CHAR net_proto CHAR net_addr CHAR tcp_port CHAR CRLF
 		{
 			usedefault = 0;
@@ -699,6 +702,10 @@ cmd
 				reply (500, "Illegal EPRT Command");
 			}
 		}
+
+		/*
+		 * EPSV is in RFC 2428.
+		 */
 	| EPSV check_login CRLF
 		{
 			if ($2)
@@ -734,6 +741,10 @@ rcmd
 			if (fromname == (char *) 0 && $4)
 			    free($4);
 		}
+
+		/*
+		 * REST is in RFC 3659.
+		 */
 	| REST SP byte_size CRLF
 		{
 		        free (fromname);

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

Summary of changes:
 ChangeLog          |   22 +++++++++++++++++++---
 doc/inetutils.texi |   22 +++++++++++++---------
 ftpd/extern.h      |    5 +++++
 ftpd/ftpcmd.y      |   48 +++++++++++++++++++++++++++++++++++-------------
 ftpd/ftpd.c        |   41 +++++++++++++++++++++++++++++++++--------
 5 files changed, 105 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Jun 07 15:30:24 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SciPY-0000ep-SC
	for mharc-commit-inetutils@gnu.org; Thu, 07 Jun 2012 15:30:24 -0400
Received: from eggs.gnu.org ([208.118.235.92]:35644)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SciPV-0000eK-2Z
	for commit-inetutils@gnu.org; Thu, 07 Jun 2012 15:30:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SciPR-0004XN-QW
	for commit-inetutils@gnu.org; Thu, 07 Jun 2012 15:30:20 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46801)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SciPR-0004XC-La
	for commit-inetutils@gnu.org; Thu, 07 Jun 2012 15:30:17 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SciPO-0003Vx-V5
	for commit-inetutils@gnu.org; Thu, 07 Jun 2012 19:30:16 +0000
Date: Thu, 07 Jun 2012 19:30:15 +0000
Message-Id: <E1SciPO-0003Vx-V5@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-110-gb65e343
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3370c78d40133eae964a669342a3a2be4cf229ef
X-Git-Newrev: b65e343173354b58ae3f21bdf6d745c7be260bc4
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, 07 Jun 2012 19:30: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  b65e343173354b58ae3f21bdf6d745c7be260bc4 (commit)
       via  8ee8d9acbdee43ac24ff873c57d749474cf324c5 (commit)
       via  5f1d3b85b5db26495b42d333d6ab9e4313fa21ba (commit)
      from  3370c78d40133eae964a669342a3a2be4cf229ef (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=b65e343173354b58ae3f21bdf6d745c7be260bc4


commit b65e343173354b58ae3f21bdf6d745c7be260bc4
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Jun 7 21:01:22 2012 +0200

    rexecd: PAM code audit.

diff --git a/ChangeLog b/ChangeLog
index 9db9359..0161e7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2012-06-07  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	rexecd: Audit of PAM code.
+
+	* src/rexecd.c (doc) [WITH_PAM]: Expand string.
+	(doit): Remove variable TOKEN.  Add flag PAM_SILENT
+	in call to pam_setcred().  Really update USER when
+	calling pam_get_item(PAM_USER).  When execl() fails,
+	close properly by calling pam_end().
+
+2012-06-07  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	ftpd: Audit of existing PAM code.
 
 	* ftpd/extern.h (pam_end_login) [WITH_LINUX_PAM]:
diff --git a/src/rexecd.c b/src/rexecd.c
index 0236a5d..0b39524 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -50,13 +50,22 @@
 /* Implementation of PAM support for a service `rexec'
  * was done by Mats Erik Andersson.
  *
- * Simple PAM configuration:
+ * Sample PAM configuration with variations for different systems:
  *
  *   rexec auth     requisite  pam_nologin.so
  *   rexec auth     required   pam_unix.so
+ *   # rexec auth   requisite  pam_authtok_get.so
+ *   # rexec auth   required   pam_unix_cred.so
+ *   # rexec auth   required   pam_unix_auth.so
+ *   # rexec auth   required   pam_listfile.so item=user sense=allow \
+ *                                 file=/etc/rexec.allow onerr=fail
+ *
  *   rexec account  required   pam_unix.so
  *   rexec account  required   pam_time.so
- *   rexec session  required   pam_unix.so
+ *   # rexec account requisite pam_roles.so
+ *   # rexec account required  pam_unix_account.so
+ *   # rexec account required  pam_list.so allow=/etc/rexec.allow
+ *
  *   rexec password required   pam_deny.so
  */
 
@@ -140,7 +149,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
   return 0;
 }
 
-const char doc[] = "remote execution daemon";
+const char doc[] =
+#ifdef WITH_PAM
+		   "Remote execution daemon, using PAM module 'rexec'.";
+#else /* !WITH_PAM */
+		   "Remote execution daemon.";
+#endif
 
 static struct argp argp = {
   options,
@@ -222,9 +236,6 @@ 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;
@@ -449,7 +460,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 #endif
 
 #ifdef WITH_PAM
-  pam_rc = pam_setcred(pam_handle, PAM_ESTABLISH_CRED);
+  pam_rc = pam_setcred (pam_handle, PAM_SILENT | PAM_ESTABLISH_CRED);
   if (pam_rc != PAM_SUCCESS)
     {
       syslog (LOG_ERR, "pam_setcred: %s",
@@ -558,7 +569,8 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   /* 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);
+  free (user);
+  pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
   if (pam_rc != PAM_SUCCESS)
     die (EXIT_FAILURE, "Try again.");
 
@@ -621,6 +633,9 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   execl (pwd->pw_shell, cp, "-c", cmdbuf, NULL);
   if (logging)
     syslog (LOG_ERR, "execl fails for \"%s\": %m", user);
+#ifdef WITH_PAM
+  pam_end (pam_handle, PAM_SUCCESS);
+#endif
   error (EXIT_FAILURE, errno, "executing %s", pwd->pw_shell);
 
   return -1;

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


commit 8ee8d9acbdee43ac24ff873c57d749474cf324c5
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Jun 7 15:38:52 2012 +0200

    ftpd: Audit of PAM code.

diff --git a/ChangeLog b/ChangeLog
index 43c7c52..9db9359 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-06-07  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Audit of existing PAM code.
+
+	* ftpd/extern.h (pam_end_login) [WITH_LINUX_PAM]:
+	New prototype.
+	* ftpd/ftpd.c (end_login) [WITH_LINUX_PAM]: Call
+	pam_end_login() to tear down current client.
+	* ftpd/pam.c: Include <syslog.h>.
+	(pam_doit): Add missing call to pam_open_session().
+	(pam_end_login): New function.
+
 2012-06-06  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Restrict to Linux-PAM, which is only valid code.
diff --git a/ftpd/extern.h b/ftpd/extern.h
index 68dee1a..7012be6 100644
--- a/ftpd/extern.h
+++ b/ftpd/extern.h
@@ -156,4 +156,5 @@ extern int auth_pass (const char *, struct credentials *);
 #ifdef WITH_LINUX_PAM
 extern int pam_user (const char *, struct credentials *);
 extern int pam_pass (const char *, struct credentials *);
+extern void pam_end_login (struct credentials *);
 #endif
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 1ea114d..c73bb7c 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -802,9 +802,15 @@ end_login (struct credentials *pcred)
 {
   char *remotehost = pcred->remotehost;
   int atype = pcred->auth_type;
+
   seteuid ((uid_t) 0);
   if (pcred->logged_in)
-    logwtmp_keep_open (ttyline, "", "");
+    {
+      logwtmp_keep_open (ttyline, "", "");
+#ifdef WITH_LINUX_PAM
+      pam_end_login (pcred);
+#endif
+    }
 
   free (pcred->name);
   if (pcred->passwd)
diff --git a/ftpd/pam.c b/ftpd/pam.c
index 9608410..41973ce 100644
--- a/ftpd/pam.c
+++ b/ftpd/pam.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <syslog.h>
 #include "extern.h"
 
 #ifdef HAVE_SECURITY_PAM_APPL_H
@@ -192,6 +193,8 @@ pam_doit (struct credentials *pcred)
       if (error == PAM_SUCCESS)
 	error = pam_setcred (pamh, PAM_ESTABLISH_CRED);
       if (error == PAM_SUCCESS)
+	error = pam_open_session (pamh, 0);
+      if (error == PAM_SUCCESS)
 	error = pam_get_item (pamh, PAM_USER, (const void **) &username);
       if (error == PAM_SUCCESS)
 	{
@@ -259,4 +262,26 @@ pam_pass (const char *passwd, struct credentials *pcred)
   return error != PAM_SUCCESS;
 }
 
+void
+pam_end_login (struct credentials * pcred)
+{
+  int error;
+
+  if (pamh)
+    {
+      error = pam_close_session (pamh, PAM_SILENT);
+      if (logging && error != PAM_SUCCESS)
+	syslog (LOG_ERR, "pam_session: %s", pam_strerror (pamh, error));
+
+      error = pam_setcred (pamh, PAM_SILENT | PAM_DELETE_CRED);
+      if (logging && error != PAM_SUCCESS)
+	syslog (LOG_ERR, "pam_setcred: %s", pam_strerror (pamh, error));
+
+      error = pam_end (pamh, error);
+      if (logging && error != PAM_SUCCESS)
+	syslog (LOG_ERR, "pam_end: %s", pam_strerror (pamh, error));
+
+      pamh = NULL;
+    }
+}
 #endif /* WITH_LINUX_PAM */

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


commit 5f1d3b85b5db26495b42d333d6ab9e4313fa21ba
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed Jun 6 16:42:31 2012 +0200

    ftpd: Only allow Linux-PAM.
    
    The existing code is only working with
    the variant Linux-PAM. Adapt to this fact.

diff --git a/ChangeLog b/ChangeLog
index 5504e7a..43c7c52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2012-06-06  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Restrict to Linux-PAM, which is only valid code.
+
+	* configure.ac (WITH_PAM): Add check for PAM_CONV_AGAIN.
+	(WITH_LINUX_PAM, FTPD_LIBPAM): New variables.
+	* ftpd/Makefile.am (LDADD): Replace LIBPAM by FTPD_LIBPAM.
+	* ftpd/auth.c (auth_user, auth_pass) [WITH_LINUX_PAM]:
+	Replace old WITH_PAM by correct WITH_LINUX_PAM.
+	* ftpd/extern.h [WITH_LINUX_PAM]: Likewise.
+	* ftpd/ftpd.c [WITH_LINUX_PAM]: Likewise.
+	* ftpd/pam.c [WITH_LINUX_PAM]: Likewise.
+	(PAM_CONV_AGAIN, PAM_INCOMPLETE): Removed macro definitions.
+	(PAM_conversation): Initialise second element to NULL.
+	(GET_MEM): Return PAM_BUF_ERR.
+	(PAM_conv) [!PAM_CONV_AGAIN]: Set RETVAL to PAM_CONV_ERR.
+	(pam_doit) [PAM_CONV_AGAIN]: Test `error == PAM_CONV_AGAIN'.
+	[PAM_INCOMPLETE]: Test `error == PAM_INCOMPLETE'.
+	(pam_doit): Return PAM_SUCCESS, not 0.
+	(pam_user): Initialise `PAM_conversation.appdata_ptr'.
+
 2012-06-02  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Long passive transfer request.
diff --git a/configure.ac b/configure.ac
index 6b474c1..eaa68dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,15 +176,22 @@ AC_SUBST(LIBUTIL)
 # Check if they want support for PAM.  Certain daemons like ftpd have
 # support for it.
 
-# See if we have libpam.a this is for ftpd.
+# See if we have libpam.a.  Investigate PAM versus Linux-PAM.
 if test "$with_pam" = yes ; then
   AC_CHECK_LIB(dl, dlopen)
   AC_CHECK_LIB(pam, pam_authenticate, LIBPAM=-lpam)
   if test "$ac_cv_lib_pam_pam_authenticate" = yes ; then
-     AC_DEFINE([WITH_PAM], 1, [Define to one if you have -lpam.])
+    AC_DEFINE([WITH_PAM], 1, [Define to one if you have -lpam.])
+    AC_CHECK_DECLS(PAM_CONV_AGAIN, , , [#include <security/pam_appl.h>])
+    if test "$ac_cv_have_decl_PAM_CONV_AGAIN" = yes ; then
+      AC_DEFINE([WITH_LINUX_PAM], 1, [Define to one if you use Linux-PAM.])
+      # Presently ftpd is coded for Linux-PAM only.
+      FTPD_LIBPAM=$LIBPAM
+    fi
   fi
 fi
 AC_SUBST(LIBPAM)
+AC_SUBST(FTPD_LIBPAM)
 
 # Can we use libls? but we must have fchdir()
 if test "$enable_libls" = yes && test "$ac_cv_func_fchdir" = yes ; then
diff --git a/ftpd/Makefile.am b/ftpd/Makefile.am
index 7f4c284..c9b4e8f 100644
--- a/ftpd/Makefile.am
+++ b/ftpd/Makefile.am
@@ -36,6 +36,6 @@ AM_CPPFLAGS = $(PATHDEF_FTPWELCOME) $(PATHDEF_FTPUSERS) \
            $(PATHDEF_FTPLOGINMESG) $(PATHDEF_FTPCHROOT) $(PATHDEF_FTPDPID) \
            $(PATHDEF_DEVNULL)  $(PATHDEF_NOLOGIN) $(PATHDEF_BSHELL)
 
-LDADD = $(LIBLS) $(LIBCRYPT) $(LIBWRAP) $(LIBPAM) $(iu_LIBRARIES)
+LDADD = $(LIBLS) $(LIBCRYPT) $(LIBWRAP) $(FTPD_LIBPAM) $(iu_LIBRARIES)
 
 EXTRA_DIST = ftpcmd.c
diff --git a/ftpd/auth.c b/ftpd/auth.c
index a6956c9..1270faa 100644
--- a/ftpd/auth.c
+++ b/ftpd/auth.c
@@ -51,7 +51,7 @@ auth_user (const char *name, struct credentials *pcred)
 
   switch (pcred->auth_type)
     {
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
     case AUTH_TYPE_PAM:
       return pam_user (name, pcred);
 #endif
@@ -143,7 +143,7 @@ auth_pass (const char *passwd, struct credentials *pcred)
 {
   switch (pcred->auth_type)
     {
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
     case AUTH_TYPE_PAM:
       return pam_pass (passwd, pcred);
 #endif
diff --git a/ftpd/extern.h b/ftpd/extern.h
index ed53cce..68dee1a 100644
--- a/ftpd/extern.h
+++ b/ftpd/extern.h
@@ -153,7 +153,7 @@ extern int auth_user (const char *, struct credentials *);
 extern int auth_pass (const char *, struct credentials *);
 
 /* Exported from pam.c */
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
 extern int pam_user (const char *, struct credentials *);
 extern int pam_pass (const char *, struct credentials *);
 #endif
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 9014a1e..1ea114d 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -296,7 +296,7 @@ static struct argp_option options[] = {
   { "  default", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
     "passwd authentication",
     GRID+3 },
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
   { "  pam", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
     "using pam 'ftp' module",
     GRID+3 },
@@ -342,7 +342,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
     case 'a':
       if (strcasecmp (arg, "default") == 0)
 	cred.auth_type = AUTH_TYPE_PASSWD;
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
       else if (strcasecmp (arg, "pam") == 0)
 	cred.auth_type = AUTH_TYPE_PAM;
 #endif
diff --git a/ftpd/pam.c b/ftpd/pam.c
index 9d04c2e..9608410 100644
--- a/ftpd/pam.c
+++ b/ftpd/pam.c
@@ -28,22 +28,21 @@
 # include <security/pam_appl.h>
 #endif
 
-#ifndef PAM_CONV_AGAIN
-# define PAM_CONV_AGAIN PAM_TRY_AGAIN
-#endif
-#ifndef PAM_INCOMPLETE
-# define PAM_INCOMPLETE PAM_TRY_AGAIN
-#endif
+/* June 3rd, 2012:
+ * The draft of A.G Morgan on behalf of the the Open-PAM
+ * working group has clearly not been able to get the
+ * additions PAM_INCOMPLETE and PAM_CONV_AGAIN accepted
+ * sufficiently well in order that the present code should
+ * force them upon BSD and Solaris.  They are thus protected
+ * by preprocessor conditionals for the time being.
+ */
 
-#ifdef WITH_PAM
+#ifdef WITH_LINUX_PAM
 
 static int PAM_conv (int num_msg, const struct pam_message **msg,
 		     struct pam_response **resp, void *appdata_ptr);
 
-/* FIXME: We still have a side effect since we use the global variable
-   cred.  A better approach would be to use the pcred parameter
-   in pam_user().  */
-static struct pam_conv PAM_conversation = { &PAM_conv, &cred };
+static struct pam_conv PAM_conversation = { &PAM_conv, NULL };
 
 /* PAM authentication, now using the PAM's async feature.  */
 static pam_handle_t *pamh;
@@ -59,7 +58,7 @@ PAM_conv (int num_msg, const struct pam_message **msg,
 
 # define GET_MEM \
         if (!(repl = realloc (repl, size))) \
-                return PAM_CONV_ERR; \
+                return PAM_BUF_ERR; \
         size += sizeof (struct pam_response)
 
   retval = PAM_SUCCESS;
@@ -78,10 +77,14 @@ PAM_conv (int num_msg, const struct pam_message **msg,
 	  break;
 	case PAM_PROMPT_ECHO_OFF:
 	  GET_MEM;
-	  if (pcred->pass == 0)
+	  if (pcred->pass == NULL)
 	    {
 	      savemsg = 1;
+# ifdef PAM_CONV_AGAIN
 	      retval = PAM_CONV_AGAIN;
+# else /* !PAM_CONV_AGAIN */
+	      retval = PAM_CONV_ERR;
+# endif
 	    }
 	  else
 	    {
@@ -163,8 +166,15 @@ pam_doit (struct credentials *pcred)
 
   error = pam_authenticate (pamh, 0);
 
-  /* Probably being call for the passwd.  */
-  if (error == PAM_CONV_AGAIN || error == PAM_INCOMPLETE)
+  /* Probably being called for the passwd.  */
+  if (0
+# ifdef PAM_CONV_AGAIN
+      || error == PAM_CONV_AGAIN
+# endif
+# ifdef PAM_INCOMPLETE
+      || error == PAM_INCOMPLETE
+# endif
+     )
     {
       /* Avoid overly terse passwd messages and let the people
          upstairs do something sane.  */
@@ -173,7 +183,7 @@ pam_doit (struct credentials *pcred)
 	  free (pcred->message);
 	  pcred->message = NULL;
 	}
-      return 0;
+      return PAM_SUCCESS;
     }
 
   if (error == PAM_SUCCESS)	/* Alright, we got it */
@@ -217,6 +227,9 @@ pam_user (const char *username, struct credentials *pcred)
   free (pcred->message);
   pcred->message = NULL;
 
+  /* Arrange our creditive.  */
+  PAM_conversation.appdata_ptr = (void *) pcred;
+
   error = pam_start ("ftp", pcred->name, &PAM_conversation, &pamh);
   if (error == PAM_SUCCESS)
     error = pam_set_item (pamh, PAM_RHOST, pcred->remotehost);
@@ -246,4 +259,4 @@ pam_pass (const char *passwd, struct credentials *pcred)
   return error != PAM_SUCCESS;
 }
 
-#endif /* WITH_PAM */
+#endif /* WITH_LINUX_PAM */

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

Summary of changes:
 ChangeLog        |   43 ++++++++++++++++++++++++++++++++
 configure.ac     |   11 ++++++-
 ftpd/Makefile.am |    2 +-
 ftpd/auth.c      |    4 +-
 ftpd/extern.h    |    3 +-
 ftpd/ftpd.c      |   12 ++++++--
 ftpd/pam.c       |   72 +++++++++++++++++++++++++++++++++++++++++------------
 src/rexecd.c     |   31 +++++++++++++++++------
 8 files changed, 144 insertions(+), 34 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Mon Jun 11 14:42:06 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Se9Z0-0006Gw-RP
	for mharc-commit-inetutils@gnu.org; Mon, 11 Jun 2012 14:42:06 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Se9Yx-0006Go-JM
	for commit-inetutils@gnu.org; Mon, 11 Jun 2012 14:42:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Se9Yu-0005WE-EA
	for commit-inetutils@gnu.org; Mon, 11 Jun 2012 14:42:03 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46651)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Se9Yu-0005Vu-9g
	for commit-inetutils@gnu.org; Mon, 11 Jun 2012 14:42:00 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Se9Ys-0007fY-SM
	for commit-inetutils@gnu.org; Mon, 11 Jun 2012 18:41:59 +0000
Date: Mon, 11 Jun 2012 18:41:59 +0000
Message-Id: <E1Se9Ys-0007fY-SM@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-112-ge3c1d1e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b65e343173354b58ae3f21bdf6d745c7be260bc4
X-Git-Newrev: e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0
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, 11 Jun 2012 18:42: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  e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0 (commit)
       via  cfc0538ce07973f543ed868a350506bb50893fef (commit)
      from  b65e343173354b58ae3f21bdf6d745c7be260bc4 (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=e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0


commit e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Jun 11 12:26:56 2012 +0200

    rexecd, rlogind: Review use of LOG_AUTH.

diff --git a/ChangeLog b/ChangeLog
index 4611d31..123b69a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-06-11  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rexecd, rlogind: Distinguish logging facility.
+	Use LOG_AUTH only for authentication messages.
+
+	* src/rexecd.c (doit): Add LOG_AUTH to syslog() in user
+	contexts.  Otherwise use default LOG_DAEMON in openlog().
+	* src/rlogind.c (main, do_rlogin, do_krb4_login)
+	(do_krb5_login, do_shishi_login): Likewise.
+
 2012-06-09  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Long address transfer request.
diff --git a/src/rexecd.c b/src/rexecd.c
index 0b39524..f8b1c55 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -357,7 +357,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 #endif /* HAVE_GETPWNAM_R */
     {
       if (logging)
-	syslog (LOG_WARNING, "no user named \"%s\"", user);
+	syslog (LOG_WARNING | LOG_AUTH, "no user named \"%s\"", user);
       die (EXIT_FAILURE, "Login incorrect.");
     }
 
@@ -372,7 +372,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
       if (strcmp (namep, pw_password))
 	{
 	  if (logging)
-	    syslog (LOG_WARNING, "password failure for \"%s\"", user);
+	    syslog (LOG_WARNING | LOG_AUTH, "password failure for \"%s\"", user);
 	  die (EXIT_FAILURE, "Password incorrect.");
 	}
     }
@@ -443,7 +443,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 #ifdef WITH_PAM
       pam_rc = PAM_ABORT;
 #endif
-      syslog (LOG_DEBUG, "setgid(gid = %d): %m", pwd->pw_gid);
+      syslog (LOG_DEBUG | LOG_AUTH, "setgid(gid = %d): %m", pwd->pw_gid);
       die (EXIT_FAILURE, "Failed group protections.");
     }
 
@@ -453,7 +453,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 # ifdef WITH_PAM
       pam_rc = PAM_ABORT;
 # endif
-      syslog (LOG_DEBUG, "initgroups(%s, %s): %m",
+      syslog (LOG_DEBUG | LOG_AUTH, "initgroups(%s, %s): %m",
 	      pwd->pw_name, pwd->pw_gid);
       die (EXIT_FAILURE, "Failed group protections.");
     }
@@ -463,7 +463,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   pam_rc = pam_setcred (pam_handle, PAM_SILENT | PAM_ESTABLISH_CRED);
   if (pam_rc != PAM_SUCCESS)
     {
-      syslog (LOG_ERR, "pam_setcred: %s",
+      syslog (LOG_ERR | LOG_AUTH, "pam_setcred: %s",
 	      pam_strerror (pam_handle, pam_rc));
       pam_rc = PAM_SUCCESS;	/* Only report the above anomaly.  */
     }
@@ -474,7 +474,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 #ifdef WITH_PAM
       pam_rc = PAM_ABORT;
 #endif
-      syslog (LOG_DEBUG, "setuid(uid = %d): %m", pwd->pw_uid);
+      syslog (LOG_DEBUG | LOG_AUTH, "setuid(uid = %d): %m", pwd->pw_uid);
       die (EXIT_FAILURE, "Failed user identity.");
     }
 
@@ -558,7 +558,8 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   if (chdir (pwd->pw_dir) < 0)
     {
       if (logging)
-	syslog (LOG_NOTICE, "\"%s\" uses invalid \"%s\"", user, pwd->pw_dir);
+	syslog (LOG_NOTICE | LOG_AUTH, "\"%s\" uses invalid \"%s\"",
+		user, pwd->pw_dir);
 #ifdef WITH_PAM
       pam_rc = PAM_ABORT;
 #endif
@@ -582,7 +583,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
   if (pwd == NULL)
 # endif /* HAVE_GETPWNAM_R */
     {
-      syslog (LOG_ERR, "no user named \"%s\"", user);
+      syslog (LOG_ERR | LOG_AUTH, "no user named \"%s\"", user);
       die (EXIT_FAILURE, "Login incorrect.");
     }
 #endif /* WITH_PAM */
diff --git a/src/rlogind.c b/src/rlogind.c
index 48f1bdc..19dd6ab 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -393,7 +393,7 @@ main (int argc, char *argv[])
   iu_argp_init ("rlogind", program_authors);
   argp_parse (&argp, argc, argv, 0, &index, NULL);
 
-  openlog ("rlogind", LOG_PID | LOG_CONS, LOG_AUTH);
+  openlog ("rlogind", LOG_PID | LOG_CONS, LOG_DAEMON);
   argc -= index;
   if (argc > 0)
     {
@@ -572,7 +572,7 @@ rlogind_auth (int fd, struct auth_data *ap)
 	}
       if (!match)
 	{
-	  syslog (LOG_ERR | LOG_AUTH, "cannot find matching IP for %s (%s)",
+	  syslog (LOG_ERR | LOG_AUTH, "cannot verify matching IP for %s (%s)",
 		  ap->hostname, inet_ntoa (ap->from.sin_addr));
 	  fatal (fd, "Permission denied", 0);
 	}
@@ -872,24 +872,27 @@ do_rlogin (int infd, struct auth_data *ap)
   pwd = getpwnam (ap->lusername);
   if (pwd == NULL)
     {
-      syslog (LOG_ERR, "no passwd entry for %s", ap->lusername);
+      syslog (LOG_ERR | LOG_AUTH, "no passwd entry for %s", ap->lusername);
       fatal (infd, "Permission denied", 0);
     }
   if (!allow_root && pwd->pw_uid == 0)
     {
-      syslog (LOG_ERR, "root logins not permitted");
+      syslog (LOG_ERR | LOG_AUTH, "root logins not permitted");
       fatal (infd, "Permission denied", 0);
     }
 
 #ifdef WITH_IRUSEROK
   rc = iruserok (ap->from.sin_addr.s_addr, 0, ap->rusername, ap->lusername);
   if (rc)
-    syslog (LOG_ERR, "iruserok failed: rusername=%s, lusername=%s",
+    syslog (LOG_ERR | LOG_AUTH,
+	    "iruserok failed: rusername=%s, lusername=%s",
 	    ap->rusername, ap->lusername);
 #elif defined WITH_RUSEROK
-  rc = ruserok (inet_ntoa (ap->from.sin_addr), 0, ap->rusername, ap->lusername);
+  rc = ruserok (inet_ntoa (ap->from.sin_addr), 0, ap->rusername,
+		ap->lusername);
   if (rc)
-    syslog (LOG_ERR, "ruserok failed: rusername=%s, lusername=%s",
+    syslog (LOG_ERR | LOG_AUTH,
+	    "ruserok failed: rusername=%s, lusername=%s",
 	    ap->rusername, ap->lusername);
 #else /* !WITH_IRUSEROK && !WITH_RUSEROK */
 #error Unable to use mandatory iruserok/ruserok.  This should not happen.
@@ -979,7 +982,7 @@ do_krb4_login (int infd, struct auth_data *ap, const char **err_msg)
   if (pwd == NULL)
     {
       *err_msg = "getpwnam failed";
-      syslog (LOG_ERR, "getpwnam failed: %m");
+      syslog (LOG_ERR | LOG_AUTH, "getpwnam failed: %m");
       return 1;
     }
   /* returns nonzero for no access */
@@ -1019,7 +1022,8 @@ do_krb5_login (int infd, struct auth_data *ap, const char **err_msg)
 
   if (status = krb5_init_context (&ap->context))
     {
-      syslog (LOG_ERR, "Error initializing krb5: %s", error_message (status));
+      syslog (LOG_ERR, "Error initializing krb5: %s",
+	      error_message (status));
       return status;
     }
 
@@ -1072,7 +1076,7 @@ do_krb5_login (int infd, struct auth_data *ap, const char **err_msg)
   if (pwd == NULL)
     {
       *err_msg = "getpwnam failed";
-      syslog (LOG_ERR, "getpwnam failed: %m");
+      syslog (LOG_ERR | LOG_AUTH, "getpwnam failed: %m");
       return 1;
     }
 
@@ -1196,7 +1200,7 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
      if (pwd == NULL)
      {
      *err_msg = "getpwnam failed";
-     syslog (LOG_ERR, "getpwnam failed: %m");
+     syslog (LOG_ERR | LOG_AUTH, "getpwnam failed: %m");
      return 1;
      }
 
@@ -1240,7 +1244,7 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
   rc = shishi_authorized_p (ad->h, shishi_ap_tkt (ad->ap), ad->lusername);
   if (!rc)
     {
-      syslog (LOG_ERR, "User is not authorized to log in as: %s",
+      syslog (LOG_ERR | LOG_AUTH, "User is not authorized to log in as: %s",
 	      ad->lusername);
       shishi_ap_done (ad->ap);
       return 1;

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


commit cfc0538ce07973f543ed868a350506bb50893fef
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Jun 9 14:35:00 2012 +0200

    ftpd: LPRT transfer request.

diff --git a/ChangeLog b/ChangeLog
index 0161e7a..4611d31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-06-09  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Long address transfer request.
+
+	* ftpd/ftpcmd.y (LPRT): New token.
+	(long_host_port): New value returning type.
+	* doc/inetutils.texi (ftpd invocation): Updated.
+
 2012-06-07  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd: Audit of PAM code.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index d048397..002c903 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -2901,6 +2901,7 @@ case of the requests is ignored.
 @item EPRT         @tab  specify data connection port
 @item HELP         @tab  give help information
 @item LIST         @tab  give list files in a directory (``ls -lgA'')
+@item LPRT         @tab  specify data connection port
 @item LPSV         @tab  long passive transfer request
 @item MKD          @tab  make a directory
 @item MDTM         @tab  show last modification time of file
@@ -2947,7 +2948,8 @@ the @code{SITE} request.
 The remaining FTP requests specified in RFC 959 are recognized, but
 not implemented.  The extensions @code{MDTM}, @code{REST},
 and @code{SIZE} are specified in RFC 3659, while @code{EPRT}
-and @code{EPSV} appear in RFC 2428, and @code{LPSV} in RFC 1639.
+and @code{EPSV} appear in RFC 2428, @code{LPRT} and @code{LPSV}
+in RFC 1639.
 
 The ftp server will abort an active file transfer only when the
 @code{ABOR} command is preceded by a Telnet @samp{Interrupt Process}
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index 1fd0ac6..1bfe92b 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -50,15 +50,15 @@
 /*
  * Grammar for FTP commands:
  *
- *   See RFC 959, RFC 1636 (LPSV), RFC 2428,
+ *   See RFC 959, RFC 1639, RFC 2428,
  *   and RFC 3659 (MDTM, REST, SIZE).
  *
  * TODO: Update with RFC 3659 (MLST, MLSD).
  *
- * TODO: RFC 1639 (LPRT).
- *
  * TODO: RFC 2389 (FEAT, OPTS).
  *
+ * TODO: RFC 2428 (EPSV ALL).
+ *
  * FIXME: Rewrite with GNU standard formatting.  Legacy code is changed!
  */
 
@@ -151,7 +151,7 @@ static void yyerror       (const char *s);
 	STAT	HELP	NOOP	MKD	RMD	PWD
 	CDUP	STOU	SMNT	SYST	SIZE	MDTM
 
-	EPRT	EPSV	LPSV
+	EPRT	EPSV	LPRT	LPSV
 
 	UMASK	IDLE	CHMOD
 
@@ -163,7 +163,7 @@ static void yyerror       (const char *s);
 %type	<i> check_login octal_number byte_size
 %type	<i> struct_code mode_code type_code form_code
 %type	<s> pathstring pathname password username
-%type	<i> host_port net_proto tcp_port
+%type	<i> host_port net_proto tcp_port long_host_port
 %type	<s> net_addr
 
 %start	cmd_list
@@ -723,6 +723,48 @@ cmd
 		}
 
 		/*
+		 * LPRT is in RFC 1639.
+		 */
+	| LPRT check_login SP long_host_port CRLF
+		{
+			if ($2)
+			  {
+			    if ($4 &&
+				( his_addr.ss_family == AF_INET
+				  && memcmp (&((struct sockaddr_in *) &his_addr)->sin_addr,
+					     &((struct sockaddr_in *) &data_dest)->sin_addr,
+					     sizeof (struct in_addr)) == 0
+				  && ntohs (((struct sockaddr_in *) &data_dest)->sin_port)
+					> IPPORT_RESERVED
+				  ||
+				  his_addr.ss_family == AF_INET6
+				  && memcmp (&((struct sockaddr_in6 *) &his_addr)->sin6_addr,
+					     &((struct sockaddr_in6 *) &data_dest)->sin6_addr,
+					     sizeof (struct in6_addr)) == 0
+				  && ntohs (((struct sockaddr_in6 *) &data_dest)->sin6_port)
+					> IPPORT_RESERVED
+				)
+			       )
+			      {
+				usedefault = 0;
+				if (pdata >= 0)
+				  {
+				    close(pdata);
+				    pdata = -1;
+				  }
+				  reply (200, "LPRT command successful.");
+			      }
+			    else
+			      {
+				usedefault = 1;
+				memset (&data_dest, 0,
+					sizeof (data_dest));
+				reply(500, "Illegal LPRT Command");
+			      }
+			  } /* check_login */
+		}
+
+		/*
 		 * LPSV is in RFC 1639.
 		 */
 	| LPSV check_login CRLF
@@ -730,6 +772,7 @@ cmd
 			if ($2)
 				passive(PASSIVE_LPSV, 0 /* not used */);
 		}
+
 	| QUIT CRLF
 		{
 			reply(221, "Goodbye.");
@@ -847,6 +890,138 @@ host_port
 		}
 	;
 
+long_host_port
+	: NUMBER COMMA NUMBER COMMA /* af, hal */
+		NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA /* h */
+		NUMBER COMMA NUMBER COMMA NUMBER /* pal, p */
+		{
+			int err;
+			char a[INET6_ADDRSTRLEN], p[8];
+			struct addrinfo hints, *res;
+
+			/* Well formed input for IPv4?  */
+			if ($1 != 4 || $3 != 4 || $13 != 2
+			    || $5 < 0 || $5 > 255 || $7 < 0 || $7 > 255
+			    || $9 < 0 || $9 > 255 || $11 < 0 || $11 > 255
+			    || $15 < 0 || $15 > 255
+			    || $17 < 0 || $17 > 255)
+			  {
+			    reply (500, "Invalid address.");
+			    memset (&data_dest, 0, sizeof (data_dest));
+			    data_dest_len = 0;
+			    $$ = 0;
+			  }
+			else
+			  {
+			    snprintf (a, sizeof (a), "%jd.%jd.%jd.%jd",
+				      $5, $7, $9, $11);
+			    snprintf (p, sizeof (p), "%jd",
+				      ($15 << 8) + $17);
+
+			    memset (&hints, 0, sizeof (hints));
+			    hints.ai_family = his_addr.ss_family;
+			    hints.ai_socktype = SOCK_STREAM;
+			    hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
+
+			    if (his_addr.ss_family == AF_INET6)
+			      {
+				/* IPv4 mapped to IPv6.  */
+				hints.ai_family = AF_INET6;
+#ifdef AI_V4MAPPED
+				hints.ai_flags |= AI_V4MAPPED;
+#endif
+				snprintf (a, sizeof (a),
+					  "::ffff:%jd.%jd.%jd.%jd",
+					  $5, $7, $9, $11);
+			      }
+
+			    err = getaddrinfo (a, p, &hints, &res);
+			    if (err)
+			      {
+				reply (550, "LPRT address failure: %s,%s",
+				       a, p);
+				memset (&data_dest, 0, sizeof (data_dest));
+				data_dest_len = 0;
+				$$ = 0;
+			      }
+			    else
+			      {
+				memcpy (&data_dest, res->ai_addr,
+					res->ai_addrlen);
+				data_dest_len = res->ai_addrlen;
+				freeaddrinfo (res);
+				$$ = 1;
+			      }
+			  }
+		}
+	| NUMBER COMMA NUMBER COMMA /* af, hal */
+		NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA /* h */
+		NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+		NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+		NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+		NUMBER COMMA NUMBER COMMA NUMBER /* pal, p */
+		{
+			int err;
+			char a[INET6_ADDRSTRLEN], p[8];
+			struct addrinfo hints, *res;
+
+			/* Well formed input for IPv6?  */
+			if ($1 != 6 || $3 != 16 || $37 != 2
+			    || $5 < 0 || $5 > 255 || $7 < 0 || $7 > 255
+			    || $9 < 0 || $9 > 255 || $11 < 0 || $11 > 255
+			    || $13 < 0 || $13 > 255 || $15 < 0 || $15 > 255
+			    || $17 < 0 || $17 > 255 || $19 < 0 || $19 > 255
+			    || $21 < 0 || $21 > 255 || $23 < 0 || $23 > 255
+			    || $25 < 0 || $25 > 255 || $27 < 0 || $27 > 255
+			    || $29 < 0 || $29 > 255 || $31 < 0 || $31 > 255
+			    || $33 < 0 || $33 > 255 || $35 < 0 || $35 > 255
+			    || $39 < 0 || $39 > 255 || $41 < 0 || $41 > 255)
+			  {
+			    reply (500, "Invalid address.");
+			    memset (&data_dest, 0, sizeof (data_dest));
+			    data_dest_len = 0;
+			    $$ = 0;
+			  }
+			else
+			  {
+			    snprintf (a, sizeof (a),
+				     "%02jx%02jx:%02jx%02jx:"
+				     "%02jx%02jx:%02jx%02jx:"
+				     "%02jx%02jx:%02jx%02jx:"
+				     "%02jx%02jx:%02jx%02jx",
+				      $5, $7, $9, $11,
+				      $13, $15, $17, $19,
+				      $21, $23, $25, $27,
+				      $29, $31, $33, $35);
+			    snprintf (p, sizeof (p), "%jd",
+				      ($39 << 8) + $41);
+
+			    memset (&hints, 0, sizeof (hints));
+			    hints.ai_family = his_addr.ss_family;
+			    hints.ai_socktype = SOCK_STREAM;
+			    hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
+
+			    err = getaddrinfo (a, p, &hints, &res);
+			    if (err)
+			      {
+				reply (550, "LPRT address failure: %s,%s",
+				       a, p);
+				memset (&data_dest, 0, sizeof (data_dest));
+				data_dest_len = 0;
+				$$ = 0;
+			      }
+			    else
+			      {
+				memcpy (&data_dest, res->ai_addr,
+					res->ai_addrlen);
+				data_dest_len = res->ai_addrlen;
+				freeaddrinfo (res);
+				$$ = 1;
+			      }
+			  }
+		}
+	;
+
 form_code
 	: N
 		{
@@ -1077,6 +1252,7 @@ struct tab cmdtab[] = {		/* In order defined in RFC 765 */
 	{ "MDTM", MDTM, OSTR, 1,	"<sp> path-name" },
 	{ "EPRT", EPRT, DLIST, 1,	"<sp> <d> proto <d> addr <d> port <d>" },
 	{ "EPSV", EPSV, ARGS, 1,	"[ <sp> af ]" },
+	{ "LPRT", LPRT, ARGS, 1,	"<sp> af,hal,h0..hn,2,p0,p1" },
 	{ "LPSV", LPSV, ARGS, 1,	"(set server in long passive mode)" },
 	{ NULL,   0,    0,    0,	0 }
 };

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

Summary of changes:
 ChangeLog          |   18 +++++
 doc/inetutils.texi |    4 +-
 ftpd/ftpcmd.y      |  186 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/rexecd.c       |   17 +++--
 src/rlogind.c      |   28 +++++----
 5 files changed, 227 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Jun 15 03:40:32 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SfR8y-0003MT-As
	for mharc-commit-inetutils@gnu.org; Fri, 15 Jun 2012 03:40:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39398)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <simon@josefsson.org>) id 1SfR8q-0003M2-Bz
	for commit-inetutils@gnu.org; Fri, 15 Jun 2012 03:40:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <simon@josefsson.org>) id 1SfR8j-0006LB-GQ
	for commit-inetutils@gnu.org; Fri, 15 Jun 2012 03:40:23 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:50708)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <simon@josefsson.org>) id 1SfR8j-0006L6-CG
	for commit-inetutils@gnu.org; Fri, 15 Jun 2012 03:40:17 -0400
Received: from jas by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <simon@josefsson.org>) id 1SfR8h-00005B-JZ
	for commit-inetutils@gnu.org; Fri, 15 Jun 2012 07:40:16 +0000
Date: Fri, 15 Jun 2012 07:40:16 +0000
Message-Id: <E1SfR8h-00005B-JZ@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-113-gf0e5551
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0
X-Git-Newrev: f0e555181d3f58c28c815ceee1c95df7178c9f67
From: Simon Josefsson <simon@josefsson.org>
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, 15 Jun 2012 07:40: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  f0e555181d3f58c28c815ceee1c95df7178c9f67 (commit)
      from  e3c1d1eafcf5483ddedb94daad4aa5eb748df8a0 (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=f0e555181d3f58c28c815ceee1c95df7178c9f67


commit f0e555181d3f58c28c815ceee1c95df7178c9f67
Author: Simon Josefsson <simon@josefsson.org>
Date:   Fri Jun 15 09:35:27 2012 +0200

    bootstrap: Updated from gnulib.

diff --git a/ChangeLog b/ChangeLog
index 123b69a..4910d84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-15  Simon Josefsson  <simon@josefsson.org>
+
+	* bootstrap: Updated from gnulib.
+
 2012-06-11  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rexecd, rlogind: Distinguish logging facility.
diff --git a/bootstrap b/bootstrap
index 31eb651..ce37a2c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2012-02-11.09; # UTC
+scriptversion=2012-05-15.06; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -36,6 +36,10 @@ nl='
 LC_ALL=C
 export LC_ALL
 
+# Ensure that CDPATH is not set.  Otherwise, the output from cd
+# would cause trouble in at least one use below.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
 local_gl_dir=gl
 
 me=$0
@@ -126,7 +130,7 @@ extract_package_name='
      p
   }
 '
-package=`sed -n "$extract_package_name" configure.ac` || exit
+package=$(sed -n "$extract_package_name" configure.ac) || exit
 gnulib_name=lib$package
 
 build_aux=build-aux
@@ -252,7 +256,7 @@ do
     usage
     exit;;
   --gnulib-srcdir=*)
-    GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
+    GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
   --skip-po)
     SKIP_PO=t;;
   --force)
@@ -303,7 +307,7 @@ insert_sorted_if_absent() {
   file=$1
   str=$2
   test -f $file || touch $file
-  echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
+  echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
     || { echo "$str" | sort_patterns - $file > $file.bak \
       && mv $file.bak $file; } \
     || exit 1
@@ -319,7 +323,7 @@ insert_vc_ignore() {
     # A .gitignore entry that does not start with '/' applies
     # recursively to subdirectories, so prepend '/' to every
     # .gitignore entry.
-    pattern=`echo "$pattern" | sed s,^,/,`;;
+    pattern=$(echo "$pattern" | sed s,^,/,);;
   esac
   insert_sorted_if_absent "$vc_ignore_file" "$pattern"
 }
@@ -423,12 +427,28 @@ check_versions() {
       $use_git || continue
     fi
     # Honor $APP variables ($TAR, $AUTOCONF, etc.)
-    appvar=`echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
+    appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
     test "$appvar" = TAR && appvar=AMTAR
     case $appvar in
         GZIP) ;; # Do not use $GZIP:  it contains gzip options.
         *) eval "app=\${$appvar-$app}" ;;
     esac
+
+    # Handle the still-experimental Automake-NG programs specially.
+    # They remain named as the mainstream Automake programs ("automake",
+    # and "aclocal") to avoid gratuitous incompatibilities with
+    # pre-existing usages (by, say, autoreconf, or custom autogen.sh
+    # scripts), but correctly identify themselves (as being part of
+    # "GNU automake-ng") when asked their version.
+    case $app in
+      automake-ng|aclocal-ng)
+        app=${app%-ng}
+        ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
+          echo "$me: Error: '$app' not found or not from Automake-NG" >&2
+          ret=1
+          continue
+        } ;;
+    esac
     if [ "$req_ver" = "-" ]; then
       # Merely require app to exist; not all prereq apps are well-behaved
       # so we have to rely on $? rather than get_version.
@@ -492,10 +512,8 @@ esac
 
 # When we can deduce that gnulib-tool will require patch,
 # and when patch is not already listed as a prerequisite, add it, too.
-if test ! -d "$local_gl_dir" \
-    || find "$local_gl_dir" -name '*.diff' -exec false {} +; then
-  :
-else
+if test -d "$local_gl_dir" \
+    && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
   case $buildreq in
     *patch*) ;;
     *) buildreq="patch -
@@ -539,7 +557,7 @@ git_modules_config () {
   test -f .gitmodules && git config --file .gitmodules "$@"
 }
 
-gnulib_path=`git_modules_config submodule.gnulib.path`
+gnulib_path=$(git_modules_config submodule.gnulib.path)
 test -z "$gnulib_path" && gnulib_path=gnulib
 
 # Get gnulib files.
@@ -612,10 +630,10 @@ download_po_files() {
   subdir=$1
   domain=$2
   echo "$me: getting translations into $subdir for $domain..."
-  cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
+  cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
   eval "$cmd" && return
   # Fallback to HTTP.
-  cmd=`printf "$po_download_command_format2" "$subdir" "$domain"`
+  cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
   eval "$cmd"
 }
 
@@ -638,7 +656,7 @@ update_po_files() {
     && ls "$ref_po_dir"/*.po 2>/dev/null |
       sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
 
-  langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
+  langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
   test "$langs" = '*' && langs=x
   for po in $langs; do
     case $po in x) continue;; esac
@@ -675,18 +693,18 @@ symlink_to_dir()
 
     # If the destination directory doesn't exist, create it.
     # This is required at least for "lib/uniwidth/cjk.h".
-    dst_dir=`dirname "$dst"`
+    dst_dir=$(dirname "$dst")
     if ! test -d "$dst_dir"; then
       mkdir -p "$dst_dir"
 
       # If we've just created a directory like lib/uniwidth,
       # tell version control system(s) it's ignorable.
       # FIXME: for now, this does only one level
-      parent=`dirname "$dst_dir"`
+      parent=$(dirname "$dst_dir")
       for dot_ig in x $vc_ignore; do
         test $dot_ig = x && continue
         ig=$parent/$dot_ig
-        insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
+        insert_vc_ignore $ig "${dst_dir##*/}"
       done
     fi
 
@@ -710,10 +728,10 @@ symlink_to_dir()
       # so that broken tools aren't confused into skipping needed builds.  See
       # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
       test -h "$dst" &&
-      src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
-      dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
+      src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
+      dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
       test "$src_i" = "$dst_i" &&
-      both_ls=`ls -dt "$src" "$dst"` &&
+      both_ls=$(ls -dt "$src" "$dst") &&
       test "X$both_ls" = "X$dst$nl$src" || {
         dot_dots=
         case $src in
@@ -736,6 +754,22 @@ symlink_to_dir()
   }
 }
 
+version_controlled_file() {
+  parent=$1
+  file=$2
+  if test -d .git; then
+    git rm -n "$file" > /dev/null 2>&1
+  elif test -d .svn; then
+    svn log -r HEAD "$file" > /dev/null 2>&1
+  elif test -d CVS; then
+    grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
+             grep '^/[^/]*/[0-9]' > /dev/null
+  else
+    echo "$me: no version control for $file?" >&2
+    false
+  fi
+}
+
 # NOTE: we have to be careful to run both autopoint and libtoolize
 # before gnulib-tool, since gnulib-tool is likely to provide newer
 # versions of files "installed" by these two programs.
@@ -748,37 +782,54 @@ with_gettext=yes
 grep '^[	 ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
     with_gettext=no
 
-if test $with_gettext = yes; then
-  # Released autopoint has the tendency to install macros that have been
-  # obsoleted in current gnulib, so run this before gnulib-tool.
-  echo "$0: $AUTOPOINT --force"
-  $AUTOPOINT --force || exit
-fi
+if test $with_gettext = yes || test $use_libtool = 1; then
 
-# Autoreconf runs aclocal before libtoolize, which causes spurious
-# warnings if the initial aclocal is confused by the libtoolized
-# (or worse out-of-date) macro directory.
-if test $use_libtool = 1; then
-  echo "running: $LIBTOOLIZE --copy --install"
-  $LIBTOOLIZE --copy --install
-fi
+  tempbase=.bootstrap$$
+  trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
 
-version_controlled_file() {
-  dir=$1
-  file=$2
-  found=no
-  if test -d CVS; then
-    grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
-             grep '^/[^/]*/[0-9]' > /dev/null && found=yes
-  elif test -d .git; then
-    git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
-  elif test -d .svn; then
-    svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
-  else
-    echo "$me: no version control for $dir/$file?" >&2
+  > $tempbase.0 > $tempbase.1 &&
+  find . ! -type d -print | sort > $tempbase.0 || exit
+
+  if test $with_gettext = yes; then
+    # Released autopoint has the tendency to install macros that have been
+    # obsoleted in current gnulib, so run this before gnulib-tool.
+    echo "$0: $AUTOPOINT --force"
+    $AUTOPOINT --force || exit
   fi
-  test $found = yes
-}
+
+  # Autoreconf runs aclocal before libtoolize, which causes spurious
+  # warnings if the initial aclocal is confused by the libtoolized
+  # (or worse out-of-date) macro directory.
+  # libtoolize 1.9b added the --install option; but we support back
+  # to libtoolize 1.5.22, where the install action was default.
+  if test $use_libtool = 1; then
+    install=
+    case $($LIBTOOLIZE --help) in
+      *--install*) install=--install ;;
+    esac
+    echo "running: $LIBTOOLIZE $install --copy"
+    $LIBTOOLIZE $install --copy
+  fi
+
+  find . ! -type d -print | sort >$tempbase.1
+  old_IFS=$IFS
+  IFS=$nl
+  for file in $(comm -13 $tempbase.0 $tempbase.1); do
+    IFS=$old_IFS
+    parent=${file%/*}
+    version_controlled_file "$parent" "$file" || {
+      for dot_ig in x $vc_ignore; do
+        test $dot_ig = x && continue
+        ig=$parent/$dot_ig
+        insert_vc_ignore "$ig" "${file##*/}"
+      done
+    }
+  done
+  IFS=$old_IFS
+
+  rm -f $tempbase.0 $tempbase.1
+  trap - 1 2 13 15
+fi
 
 # Import from gnulib.
 
@@ -842,7 +893,7 @@ AUTOPOINT=true LIBTOOLIZE=true \
 for file in $gnulib_extra_files; do
   case $file in
   */INSTALL) dst=INSTALL;;
-  build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
+  build-aux/*) dst=$build_aux/${file#build-aux/};;
   *) dst=$file;;
   esac
   symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
@@ -863,6 +914,16 @@ if test $with_gettext = yes; then
     }
   ' po/Makevars.template >po/Makevars || exit 1
 
+  # If the 'gettext' module is in use, grab the latest Makefile.in.in.
+  # If only the 'gettext-h' module is in use, assume autopoint already
+  # put the correct version of this file into place.
+  case $gnulib_modules in
+  *gettext-h*) ;;
+  *gettext*)
+    cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
+    ;;
+  esac
+
   if test -d runtime-po; then
     # Similarly for runtime-po/Makevars, but not quite the same.
     rm -f runtime-po/Makevars

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

Summary of changes:
 ChangeLog |    4 ++
 bootstrap |  159 ++++++++++++++++++++++++++++++++++++++++++-------------------
 2 files changed, 114 insertions(+), 49 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Jun 21 15:17:53 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Shmt7-0007UM-QM
	for mharc-commit-inetutils@gnu.org; Thu, 21 Jun 2012 15:17:53 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39541)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Shmt0-0007Tn-Kq
	for commit-inetutils@gnu.org; Thu, 21 Jun 2012 15:17:51 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Shmsv-0004xy-6V
	for commit-inetutils@gnu.org; Thu, 21 Jun 2012 15:17:46 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57919)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Shmsv-0004xr-1b
	for commit-inetutils@gnu.org; Thu, 21 Jun 2012 15:17:41 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Shmst-0007jW-R7
	for commit-inetutils@gnu.org; Thu, 21 Jun 2012 19:17:40 +0000
Date: Thu, 21 Jun 2012 19:17:40 +0000
Message-Id: <E1Shmst-0007jW-R7@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-118-g164de7c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f0e555181d3f58c28c815ceee1c95df7178c9f67
X-Git-Newrev: 164de7caca05f8920e45c5a9b81e7a3069536b86
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, 21 Jun 2012 19:17:51 -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  164de7caca05f8920e45c5a9b81e7a3069536b86 (commit)
       via  4049b81b064d58eef082eb8baae21271b9f55d85 (commit)
       via  6890a2236f3aabd2642c9e19a6ada4d187d788d1 (commit)
       via  e8385098de6d9cd3b34a560b34938f2167dd556d (commit)
       via  a4390104731d33a746dd0e4243e75daeddfde8f1 (commit)
      from  f0e555181d3f58c28c815ceee1c95df7178c9f67 (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=164de7caca05f8920e45c5a9b81e7a3069536b86


commit 164de7caca05f8920e45c5a9b81e7a3069536b86
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue Jun 19 23:10:17 2012 +0200

    rshd: Add PAM session code.

diff --git a/ChangeLog b/ChangeLog
index 7a8a6ba..c395d5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-06-19  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rshd: PAM session handling.
+
+	* src/rshd.c: Include <sys/wait.h>.
+	(doit) <port != 0 && parent> [WITH_PAM]: Call
+	pam_close_session(), pam_setcred(), and pam_end().
+	(doit) <without port> [WITH_PAM]: Call fork().  Parent
+	waits for child and properly closes PAM session.
+	(doit) <child> [WITH_PAM]: Call pam_open_session().
+
 2012-06-18  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	* configure.ac (WITH_ORCMD_AF, WITH_ORCMD, WITH_RCMD_AF)
diff --git a/src/rshd.c b/src/rshd.c
index 015bf8b..0979421 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -54,15 +54,35 @@
  *
  * Sample settings:
  *
- * auth      required    pam_rhosts.so
- * # auth      required    pam_rhosts_auth.so
- * auth      required    pam_nologin.so
- * # auth      required    pam_env.so
- * # auth      required    pam_group.so
+ *   GNU/Linux, et cetera:
  *
+ * auth      required    pam_nologin.so
+ * auth      required    pam_rhosts.so
+ * auth      required    pam_env.so
+ * auth      required    pam_group.so
+ * account   required    pam_nologin.so
  * account   required    pam_unix.so
- * # account   required    pam_unix_account.so
+ * session   required    pam_unix.so
+ * session   required    pam_lastlog.so silent
+ * password  required    pam_deny.so
+ *
+ *   OpenSolaris:
+ *
+ * auth      required    pam_rhosts_auth.so
+ * auth      required    pam_unix_cred.so
+ * account   required    pam_roles.so
+ * account   required    pam_unix_account.so
+ * session   required    pam_unix_session.so
+ * password  required    pam_deny.so
  *
+ *   BSD:
+ *
+ * auth      required    pam_nologin.so     # NetBSD
+ * auth      required    pam_rhosts.so
+ * account   required    pam_nologin.so     # FreeBSD
+ * account   required    pam_unix.so
+ * session   required    pam_lastlog.so
+ * password  required    pam_deny.so
  */
 
 /*
@@ -110,6 +130,7 @@
 #include <unistd.h>
 #include <grp.h>
 #include <sys/select.h>
+#include <sys/wait.h>
 #include <error.h>
 #include <progname.h>
 #include <argp.h>
@@ -1102,8 +1123,8 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 
   if (port)
     {
-      /* We nee a secondary channel,  Here's where we create
-       * the control process that'll handle this secondary
+      /* We need a secondary channel.  Here is where we create
+       * the control process that will handle this secondary
        * channel.
        * First create a pipe to use for communication between
        * the parent and child, then fork.
@@ -1314,6 +1335,20 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 	   * terminates.  The socket will terminate when the
 	   * client process terminates.
 	   */
+#ifdef WITH_PAM
+	  /* The child opened the session; now it
+	   * should be closed down properly.  */
+	  pam_rc = pam_close_session (pam_handle, PAM_SILENT);
+	  if (pam_rc != PAM_SUCCESS)
+	    syslog (LOG_WARNING | LOG_AUTH, "pam_close_session: %s",
+		    pam_strerror (pam_handle, pam_rc));
+	  pam_rc = pam_setcred (pam_handle, PAM_SILENT | PAM_DELETE_CRED);
+	  if (pam_rc != PAM_SUCCESS)
+	    syslog (LOG_WARNING | LOG_AUTH, "pam_setcred: %s",
+		    pam_strerror (pam_handle, pam_rc));
+	  pam_end (pam_handle, pam_rc);
+#endif /* WITH_PAM */
+
 	  exit (EXIT_SUCCESS);
 	}
 
@@ -1365,6 +1400,40 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 					   pipe to control process */
       close (pv[1]);
     }
+#ifdef WITH_PAM
+    /* Session handling must end also in this case.  */
+  else
+    {
+      pid = fork ();
+      if (pid < 0)
+	{
+	  rshd_error ("Can't fork; try again.\n");
+	  exit (EXIT_FAILURE);
+	}
+      if (pid)
+	{
+	  /* Parent: Wait for child and tear down
+	   * the PAM session.  */
+	  int status;
+
+	  while (wait (&status) < 0 && errno == EINTR)
+	    ;
+
+	  pam_rc = pam_close_session (pam_handle, PAM_SILENT);
+	  if (pam_rc != PAM_SUCCESS)
+	    syslog (LOG_WARNING | LOG_AUTH, "pam_close_session: %s",
+		    pam_strerror (pam_handle, pam_rc));
+	  pam_rc = pam_setcred (pam_handle, PAM_SILENT | PAM_DELETE_CRED);
+	  if (pam_rc != PAM_SUCCESS)
+	    syslog (LOG_WARNING | LOG_AUTH, "pam_setcred: %s",
+		    pam_strerror (pam_handle, pam_rc));
+	  pam_end (pam_handle, pam_rc);
+
+	  exit (WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE);
+	}
+    }
+#endif /* WITH_PAM */
+
   if (*pwd->pw_shell == '\0')
     pwd->pw_shell = PATH_BSHELL;
 #if BSD > 43
@@ -1387,6 +1456,13 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 	      pam_strerror (pam_handle, pam_rc));
       pam_rc = PAM_SUCCESS;	/* Only report the above anomaly.  */
     }
+  pam_rc = pam_open_session (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_ERR | LOG_AUTH, "pam_open_session: %s",
+	      pam_strerror (pam_handle, pam_rc));
+      pam_rc = PAM_SUCCESS;	/* Only report the above anomaly.  */
+    }
 #endif /* WITH_PAM */
 
   setuid ((uid_t) pwd->pw_uid);

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


commit 4049b81b064d58eef082eb8baae21271b9f55d85
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Jun 18 23:32:46 2012 +0200

    rcp, rsh, rshd: Alternate r-calls.
    
    Prefer address independent rcmd_af(), et cetera.

diff --git a/ChangeLog b/ChangeLog
index 182faf8..7a8a6ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2012-06-18  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	* configure.ac (WITH_ORCMD_AF, WITH_ORCMD, WITH_RCMD_AF)
+	(WITH_RRESVPORT_AF, WITH_IRUSEROK_AF, WITH_IRUSEROK_SA)
+	(WITH_RUSEROK_AF): New macros.
+	* src/rcp.c (toremote, tolocal, kerberos)
+	[WITH_ORCMD_AF || WITH_RCMD_AF || WITH_ORCMD]:
+	Replace rcmd() by orcmd_af(), rcmd_af(), or orcmd().
+	* src/rsh.c (main)
+	[WITH_ORCMD_AF || WITH_RCMD_AF || WITH_ORCMD]: Likewise.
+	* src/rshd.c (doit) [WITH_RRESVPORT_AF]: Use rresvport_af()
+	instead of rresvport().
+	[WITH_IRUSEROK_SA || WITH_IRUSEROK_AF]: Replace iruserok()
+	with iruserok_sa() or iruserok_af().
+	[WITH_RUSEROK_AF]: Use ruserok_af(), not ruserok().
+
+2012-06-18  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	* src/rshd.c (doit): New signature
 	`(int, struct sockaddr_in *, socklen_t)'.
 	(main): Pass FROMLEN to doit().
diff --git a/configure.ac b/configure.ac
index eaa68dd..376a063 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,17 +232,54 @@ else
   talk_BUILD=''
 fi
 
+# NetBSD offers orcmd() and orcmd_af() for getting
+# exactly the functionality that rcmd() and rcmd_af()
+# offer on all other targetted systems.
+AC_CHECK_FUNC(rcmd_af, , , [#include <netdb.h>])
+if test "$ac_cv_func_rcmd_af" = yes; then
+  AC_DEFINE([WITH_RCMD_AF], 1, [Define to one if you can use rcmd_af.])
+fi
+AC_CHECK_FUNC(orcmd, , , [#include <unistd.h>])
+if test "$ac_cv_func_orcmd" = yes; then
+  AC_DEFINE([WITH_ORCMD], 1, [Define to one if you can use orcmd.])
+fi
+AC_CHECK_FUNC(orcmd_af, , , [#include <unistd.h>])
+if test "$ac_cv_func_orcmd_af" = yes; then
+  AC_DEFINE([WITH_ORCMD_AF], 1, [Define to one if you can use orcmd_af.])
+fi
+AC_CHECK_FUNC(rresvport_af, , , [#include <netdb.h>])
+if test "$ac_cv_func_rresvport_af" = yes; then
+  AC_DEFINE([WITH_RRESVPORT_AF], 1,
+	    [Define to one if you can use rresvport_af.])
+fi
+
 # FIXME: Presently rshd and rlogind prefer iruserok(3), which is not
 # universally available.  Replacement code?  A fallback is being built
-# from ruserok(3) and inet_ntoa(3).
+# from ruserok(3) and inet_ntoa(3).  Calls using iruserok/rusersok are
+# used for non-PAM configured executables rshd/rlogind.
 AC_CHECK_FUNC(iruserok, , , [#include <netdb.h>])
+AC_CHECK_FUNC(iruserok_af, , , [#include <netdb.h>])
+AC_CHECK_FUNC(iruserok_sa, , , [#include <netdb.h>])
 AC_CHECK_FUNC(ruserok, , , [#include <netdb.h>])
+AC_CHECK_FUNC(ruserok_af, , , [#include <netdb.h>])
 if test "$ac_cv_func_iruserok" = yes; then
   AC_DEFINE([WITH_IRUSEROK], 1, [Define to one if you can use iruserok.])
+  if test "$ac_cv_func_iruserok_af" = yes; then
+    AC_DEFINE([WITH_IRUSEROK_AF], 1,
+	      [Define to one if you can use iruserok_af.])
+  fi
+  if test "$ac_cv_func_iruserok_sa" = yes; then
+    AC_DEFINE([WITH_IRUSEROK_SA], 1,
+	      [Define to one if you can use iruserok_sa.])
+  fi
 else
   if test "$ac_cv_func_ruserok" = yes; then
     AC_DEFINE([WITH_RUSEROK], 1, [Define to one if you can use ruserok.])
     AC_MSG_WARN([iruserok is not available, falling back to ruserok.])
+    if test "$ac_cv_func_ruserok_af" = yes; then
+      AC_DEFINE([WITH_RUSEROK_AF], 1,
+		[Define to on if you can use ruserok_af.])
+    fi
   else
     AC_MSG_WARN([Disabling rlogind and rshd, since no iruserok and no ruserok.])
     enable_rlogind=no
diff --git a/src/rcp.c b/src/rcp.c
index 3907c53..0f8c114 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -429,8 +429,21 @@ toremote (char *targ, int argc, char *argv[])
 				tuser ? tuser : pwd->pw_name);
 	      else
 #endif
+#ifdef WITH_ORCMD_AF
+		rem = orcmd_af (&host, port, pwd->pw_name,
+				tuser ? tuser : pwd->pw_name,
+				bp, 0, AF_INET);
+#elif defined WITH_RCMD_AF
+		rem = rcmd_af (&host, port, pwd->pw_name,
+			       tuser ? tuser : pwd->pw_name,
+			       bp, 0, AF_INET);
+#elif defined WITH_ORCMD
+		rem = orcmd (&host, port, pwd->pw_name,
+			     tuser ? tuser : pwd->pw_name, bp, 0);
+#else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
 		rem = rcmd (&host, port, pwd->pw_name,
 			    tuser ? tuser : pwd->pw_name, bp, 0);
+#endif
 	      if (rem < 0)
 		exit (EXIT_FAILURE);
 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
@@ -495,7 +508,15 @@ tolocal (int argc, char *argv[])
 #ifdef KERBEROS
 	use_kerberos ? kerberos (&host, bp, pwd->pw_name, suser) :
 #endif
+#ifdef WITH_ORCMD_AF
+	orcmd_af (&host, port, pwd->pw_name, suser, bp, 0, AF_INET);
+#elif defined WITH_RCMD_AF
+	rcmd_af (&host, port, pwd->pw_name, suser, bp, 0, AF_INET);
+#elif defined WITH_ORCMD
+	orcmd (&host, port, pwd->pw_name, suser, bp, 0);
+#else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
 	rcmd (&host, port, pwd->pw_name, suser, bp, 0);
+#endif
       free (bp);
       if (rem < 0)
 	{
@@ -1042,7 +1063,15 @@ again:
       if (doencrypt)
 	error (EXIT_FAILURE, 0, "the -x option requires Kerberos authentication");
 # endif
+#ifdef WITH_ORCMD_AF
+      rem = orcmd_af (host, port, locuser, user, bp, 0, AF_INET);
+#elif defined WITH_RCMD_AF
+      rem = rcmd_af (host, port, locuser, user, bp, 0, AF_INET);
+#elif defined WITH_ORCMD
+      rem = orcmd (host, port, locuser, user, bp, 0);
+#else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
       rem = rcmd (host, port, locuser, user, bp, 0);
+#endif
     }
   return rem;
 }
diff --git a/src/rsh.c b/src/rsh.c
index d7d164a..da3306f 100644
--- a/src/rsh.c
+++ b/src/rsh.c
@@ -445,13 +445,29 @@ try_connect:
 	user = pw->pw_name;
       if (doencrypt)
 	error (EXIT_FAILURE, 0, "the -x flag requires Kerberos authentication");
+# ifdef WITH_ORCMD_AF
+      rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+# elif defined WITH_RCMD_AF
+      rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+# elif defined WITH_ORCMD
+      rem = orcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
+# else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
       rem = rcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
+# endif
     }
-#else
+#else /* !KERBEROS && !SHISHI */
   if (!user)
     user = pw->pw_name;
+# ifdef WITH_ORCMD_AF
+  rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+# elif defined WITH_RCMD_AF
+  rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+# elif defined WITH_ORCMD
+  rem = orcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
+# else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
   rem = rcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
-#endif
+# endif
+#endif /* !KERBEROS && !SHISHI */
 
   if (rem < 0)
     exit (EXIT_FAILURE);
diff --git a/src/rshd.c b/src/rshd.c
index 131b3b2..015bf8b 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -553,7 +553,11 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
        * to it, plus.
        */
       int lport = IPPORT_RESERVED - 1;
+#ifdef WITH_RRESVPORT_AF
+      s = rresvport_af (&lport, fromp->sin_family);
+#else
       s = rresvport (&lport);
+#endif
       if (s < 0)
 	{
 	  syslog (LOG_ERR, "can't get stderr port: %m");
@@ -1021,17 +1025,29 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 #endif /* KERBEROS || SHISHI */
 
 #ifndef WITH_PAM
-# ifdef WITH_IRUSEROK
+# ifdef WITH_IRUSEROK_SA
+    if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
+                     && (iruserok_sa ((void *) fromp, fromlen,
+				      pwd->pw_uid == 0, remuser, locuser)) < 0))
+# elif defined WITH_IRUSEROK_AF
+    if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
+                     && (iruserok_af (&fromp->sin_addr, pwd->pw_uid == 0,
+                                   remuser, locuser, fromp->sin_family)) < 0))
+# elif defined WITH_IRUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (iruserok (fromp->sin_addr.s_addr, pwd->pw_uid == 0,
                                    remuser, locuser)) < 0))
+# elif defined WITH_RUSEROK_AF
+    if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
+                     && (ruserok_af (addrstr, pwd->pw_uid == 0,
+				  remuser, locuser, fromp->sin_family)) < 0))
 # elif defined WITH_RUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (ruserok (addrstr, pwd->pw_uid == 0,
 				  remuser, locuser)) < 0))
-# else /* !WITH_IRUSEROK && !WITH_RUSEROK */
+# else /* !WITH_IRUSEROK* && !WITH_RUSEROK* */
 # error Unable to use mandatory iruserok/ruserok.  This should not happen.
-# endif /* !WITH_IRUSEROK && !WITH_RUSEROK */
+# endif /* !WITH_IRUSEROK* && !WITH_RUSEROK* */
 #else /* WITH_PAM */
     if (0)	/* Wrapper for `fail' jump label.  */
 #endif /* !WITH_PAM */

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


commit 6890a2236f3aabd2642c9e19a6ada4d187d788d1
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Jun 18 23:29:21 2012 +0200

    rshd: Host resolver changes.
    
    Prefer resolver code based on getnameinfo()
    and getaddrinfo(), aiming at address indep.

diff --git a/ChangeLog b/ChangeLog
index 6d7b897..182faf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-06-18  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* src/rshd.c (doit): New signature
+	`(int, struct sockaddr_in *, socklen_t)'.
+	(main): Pass FROMLEN to doit().
+	(doit): New variables INPORT, RC, PORTSTR, ADDRSTR.
+	(doit) [HAVE_DECL_GETNAMEINFO]: New variable ADDRNAME.
+	(doit): Put numeric info in ADDRSTR, INPORT, PORTSTR
+	early on, later replacing multiple inet_ntoa().  Do not
+	overwrite `fromp->sin_port', but use INPORT, PORTSTR.
+	Prefer using getnameinfo().
+	(doit) <address verification> [HAVE_DECL_GETNAMEINFO]:
+	New alternate code.
+
 2012-06-15  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rshd: Duplicate static memory results.  Consistently
diff --git a/src/rshd.c b/src/rshd.c
index 35e4b37..131b3b2 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -142,7 +142,7 @@ int check_all;
 int log_success;		/* If TRUE, log all successful accesses */
 int sent_null;
 
-void doit (int, struct sockaddr_in *);
+void doit (int, struct sockaddr_in *, socklen_t);
 void rshd_error (const char *, ...);
 char *getstr (const char *);
 int local_domain (const char *);
@@ -333,7 +333,7 @@ main (int argc, char *argv[])
   if (setsockopt (sockfd, SOL_SOCKET, SO_LINGER, (char *) &linger,
 		  sizeof linger) < 0)
     syslog (LOG_WARNING, "setsockopt (SO_LINGER): %m");
-  doit (sockfd, &from);
+  doit (sockfd, &from, fromlen);
   return 0;
 }
 
@@ -350,7 +350,7 @@ char *envinit[] = { homedir, shell, path, logname, username, rhost, NULL };
 extern char **environ;
 
 void
-doit (int sockfd, struct sockaddr_in *fromp)
+doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 {
 #ifdef HAVE___RCMD_ERRSTR
   extern char *__rcmd_errstr;	/* syslog hook from libc/net/rcmd.c. */
@@ -363,10 +363,14 @@ doit (int sockfd, struct sockaddr_in *fromp)
 #else /* !HAVE_GETPWNAM_R */
   struct passwd *pwd;
 #endif
-  unsigned short port;
+  unsigned short port, inport;
   fd_set ready, readfrom;
   int cc, nfd, pv[2], pid, s = sockfd;
-  int one = 1;
+  int rc, one = 1;
+  char portstr[8], addrstr[INET6_ADDRSTRLEN];
+#ifdef HAVE_DECL_GETNAMEINFO
+  char addrname[NI_MAXHOST];
+#endif
   const char *hostname, *errorstr, *errorhost = NULL;
   char *cp, sig, buf[BUFSIZ];
   char *cmdbuf, *locuser, *remuser;
@@ -376,7 +380,6 @@ doit (int sockfd, struct sockaddr_in *fromp)
   KTEXT ticket = (KTEXT) NULL;
   char instance[INST_SZ], version[VERSION_SIZE];
   struct sockaddr_in fromaddr;
-  int rc;
   long authopts;
   int pv1[2], pv2[2];
   fd_set wready, writeto;
@@ -412,6 +415,24 @@ doit (int sockfd, struct sockaddr_in *fromp)
       }
   }
 #endif
+
+#ifdef HAVE_DECL_GETNAMEINFO
+  rc = getnameinfo ((struct sockaddr *) fromp, fromlen,
+		    addrstr, sizeof (addrstr),
+		    portstr, sizeof (portstr),
+		    NI_NUMERICHOST | NI_NUMERICSERV);
+  if (rc != 0)
+    {
+      syslog (LOG_WARNING, "getnameinfo: %s", gai_strerror (rc));
+      exit (EXIT_FAILURE);
+    }
+  inport = atoi (portstr);
+#else /* !HAVE_DECL_GETNAMEINFO */
+  strncpy (addrstr, inet_ntoa (fromp->sin_addr), sizeof (addrstr));
+  inport = ntohs (fromp->sin_port);
+  snprintf (portstr, sizeof (portstr), "%u", inport);
+#endif
+
   /* Verify that the client's address is an Internet adress. */
   if (fromp->sin_family != AF_INET)
     {
@@ -451,7 +472,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		 */
 		syslog (LOG_NOTICE,
 			"Discarding connection from %s with set source routing",
-			inet_ntoa (fromp->sin_addr));
+			addrstr);
 		exit (EXIT_FAILURE);
 	      }
 	    if (*cp == IPOPT_EOL)
@@ -472,7 +493,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	 * Make a report about them, erase them, and continue.  */
 	syslog (LOG_NOTICE,
 		"Connection received from %s using IP options (erased):%s",
-		inet_ntoa (fromp->sin_addr), lbuf);
+		addrstr, lbuf);
 
 	/* Turn off the options.  If this doesn't work, we quit.  */
 	if (setsockopt (sockfd, ipproto, IP_OPTIONS,
@@ -485,18 +506,15 @@ doit (int sockfd, struct sockaddr_in *fromp)
   }
 #endif
 
-  /* Need host byte ordered port# to compare */
-  fromp->sin_port = ntohs ((unsigned short) fromp->sin_port);
   /* Verify that the client's address was bound to a reserved port */
 #if defined KERBEROS || defined SHISHI
   if (!use_kerberos)
 #endif
-    if (fromp->sin_port >= IPPORT_RESERVED
-	|| fromp->sin_port < IPPORT_RESERVED / 2)
+    if (inport >= IPPORT_RESERVED || inport < IPPORT_RESERVED / 2)
       {
 	syslog (LOG_NOTICE | LOG_AUTH,
-		"Connection from %s on illegal port %u",
-		inet_ntoa (fromp->sin_addr), fromp->sin_port);
+		"Connection from %s on illegal port %s",
+		addrstr, portstr);
 	exit (EXIT_FAILURE);
       }
 
@@ -555,7 +573,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
        * as secondary port by the client.
        */
       fromp->sin_port = htons (port);
-      if (connect (s, (struct sockaddr *) fromp, sizeof (*fromp)) < 0)
+      if (connect (s, (struct sockaddr *) fromp, fromlen) < 0)
 	{
 	  syslog (LOG_INFO, "connect second port %d: %m", port);
 	  exit (EXIT_FAILURE);
@@ -582,6 +600,61 @@ doit (int sockfd, struct sockaddr_in *fromp)
    * used for the authentication below.
    */
   errorstr = NULL;
+#ifdef HAVE_DECL_GETNAMEINFO
+  rc = getnameinfo ((struct sockaddr *) fromp, fromlen,
+		    addrname, sizeof (addrname), NULL, 0, 0);
+  if (rc == 0)
+    {
+      hostname = addrname;
+# if defined KERBEROS || defined SHISHI
+      if (!use_kerberos)
+# endif
+	if (check_all || local_domain (addrname))
+	  {
+	    struct addrinfo hints, *ai, *res;
+
+	    errorhost = addrname;
+	    memset (&hints, 0, sizeof (hints));
+	    hints.ai_family = fromp->sin_family;
+	    hints.ai_socktype = SOCK_STREAM;
+
+	    rc = getaddrinfo (hostname, NULL, &hints, &res);
+	    if (rc != 0)
+	      {
+		syslog (LOG_INFO, "Could not resolve address for %s",
+			hostname);
+		errorstr = "Could not resolve address for your host (%s)\n";
+		hostname = addrstr;
+	      }
+	    else
+	      {
+		for (ai = res; ai; ai = ai->ai_next)
+		  {
+		    char astr[INET6_ADDRSTRLEN] = "";
+
+		    if (getnameinfo (ai->ai_addr, ai->ai_addrlen,
+				     astr, sizeof (astr),
+				     NULL, 0, NI_NUMERICHOST))
+		      continue;
+		    if (!strcmp (addrstr, astr))
+		      {
+			hostname = addrname;
+			break;	/* equal, OK */
+		      }
+		  }
+		freeaddrinfo (res);
+		if (ai == NULL)
+		  {
+		    syslog (LOG_NOTICE,
+			    "Host addr %s not listed for host %s",
+			    addrstr, hostname);
+		    errorstr = "Host address mismatch for %s\n";
+		    hostname = addrstr;
+		  }
+	      }
+	  }
+    }
+#else /* !HAVE_DECL_GETNAMEINFO */
   hp = gethostbyaddr ((char *) &fromp->sin_addr, sizeof (struct in_addr),
 		      fromp->sin_family);
   if (hp)
@@ -593,9 +666,9 @@ doit (int sockfd, struct sockaddr_in *fromp)
        * address corresponds to the name.
        */
       hostname = strdup (hp->h_name);
-#if defined KERBEROS || defined SHISHI
+# if defined KERBEROS || defined SHISHI
       if (!use_kerberos)
-#endif
+# endif
 	if (check_all || local_domain (hp->h_name))
 	  {
 	    char *remotehost = alloca (strlen (hostname) + 1);
@@ -612,7 +685,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 			    "Couldn't look up address for %s", remotehost);
 		    errorstr =
 		      "Couldn't look up address for your host (%s)\n";
-		    hostname = strdup (inet_ntoa (fromp->sin_addr));
+		    hostname = addrstr;
 		  }
 		else
 		  for (;; hp->h_addr_list++)
@@ -621,9 +694,9 @@ doit (int sockfd, struct sockaddr_in *fromp)
 			{
 			  syslog (LOG_NOTICE,
 				  "Host addr %s not listed for host %s",
-				  inet_ntoa (fromp->sin_addr), hp->h_name);
+				  addrstr, hp->h_name);
 			  errorstr = "Host address mismatch for %s\n";
-			  hostname = strdup (inet_ntoa (fromp->sin_addr));
+			  hostname = addrstr;
 			  break;
 			}
 		      if (!memcmp (hp->h_addr_list[0],
@@ -637,8 +710,9 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	      }
 	  }
     }
+#endif /* !HAVE_DECL_GETNAMEINFO */
   else
-    errorhost = hostname = strdup (inet_ntoa (fromp->sin_addr));
+    errorhost = hostname = addrstr;
 
 #ifdef	KERBEROS
   if (use_kerberos)
@@ -953,8 +1027,8 @@ doit (int sockfd, struct sockaddr_in *fromp)
                                    remuser, locuser)) < 0))
 # elif defined WITH_RUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
-                     && (ruserok (inet_ntoa (fromp->sin_addr),
-				  pwd->pw_uid == 0, remuser, locuser)) < 0))
+                     && (ruserok (addrstr, pwd->pw_uid == 0,
+				  remuser, locuser)) < 0))
 # else /* !WITH_IRUSEROK && !WITH_RUSEROK */
 # error Unable to use mandatory iruserok/ruserok.  This should not happen.
 # endif /* !WITH_IRUSEROK && !WITH_RUSEROK */

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


commit e8385098de6d9cd3b34a560b34938f2167dd556d
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Jun 15 12:07:33 2012 +0200

    rshd: Support PAM.

diff --git a/ChangeLog b/ChangeLog
index fae35bf..6d7b897 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,39 @@
 2012-06-15  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	rshd: Duplicate static memory results.  Consistently
+	needed on systems running DragonFlyBSD.
+
+	* src/rshd.c (doit): When assigning HOSTNAME, apply
+	strdup() to results of inet_ntoa() and `hp->h_name'
+	in order to avoid loss of its contents later on.
+
+	rshd: Implement PAM support.
+
+	* src/Makefile.am (rshd_LDADD): Add also $(LIBPAM).
+	* src/rshd.c [HAVE_SECURITY_PAM_APPL_H]: Include
+	<security/pam_appl.h>.
+	(pam_rc, pam_handle, pam_conv) [WITH_PAM]: New variables.
+	(rsh_conv) [WITH_PAM]: New function.
+	(iruserok) [!WITH_PAM && __GLIBC__ && WITH_IRUSEROK]:
+	Set prototype only in absence of WITH_PAM.
+	(doc) [WITH_PAM]: Expand string content.
+	(username, logname, homedir, shell, path): Increase lengths,
+	including a preamble like `SHELL='.
+	(rhost): New variable used for environment variable RHOST.
+	(envinit) [!WITH_PAM]: Use only in absence of PAM support.
+	(doit) [WITH_PAM]: New code.
+	[!WITH_PAM && WITH_IRUSEROK]: Call iruserok() only in
+	absence of PAM.
+	[!WITH_PAM && !WITH_IRUSEROK && WITH_RUSEROK]: Likewise
+	for ruserok().
+	(doit) <fail label> [WITH_PAM]: Report errors via syslog.
+	(doit): Replace numerical offset by key string size when
+	setting `homedir', `path', `shell', and `username'.
+	Really assign a value to `logname', for portability.
+	(doit) <failed execl>: Report to syslog.
+
+2012-06-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	* src/rshd.c (doit) [HAVE_GETPWNAM_R]: New variables
 	PWBUF, PWBUFLEN, PWSTOR, and RET.  Call getpwnam_r(),
 	checking both `ret' and `pwd == NULL' for failure.
diff --git a/src/Makefile.am b/src/Makefile.am
index 75d5e6c..c108668 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,7 +84,7 @@ EXTRA_PROGRAMS += rlogind
 
 inetdaemon_PROGRAMS += $(rshd_BUILD)
 rshd_SOURCES = rshd.c
-rshd_LDADD = $(LDADD) $(LIBAUTH)
+rshd_LDADD = $(LDADD) $(LIBAUTH) $(LIBPAM)
 EXTRA_PROGRAMS += rshd
 
 inetdaemon_PROGRAMS += $(syslogd_BUILD)
diff --git a/src/rshd.c b/src/rshd.c
index a65c812..35e4b37 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -48,6 +48,24 @@
  */
 
 /*
+ * PAM implementation by Mats Erik Andersson.
+ *
+ * TODO: Check cooperation between PAM and Shishi/Kerberos.
+ *
+ * Sample settings:
+ *
+ * auth      required    pam_rhosts.so
+ * # auth      required    pam_rhosts_auth.so
+ * auth      required    pam_nologin.so
+ * # auth      required    pam_env.so
+ * # auth      required    pam_group.so
+ *
+ * account   required    pam_unix.so
+ * # account   required    pam_unix_account.so
+ *
+ */
+
+/*
  * remote shell server exchange protocol:
  *	[port]\0
  *	remuser\0
@@ -98,6 +116,9 @@
 #include <libinetutils.h>
 #include "xalloc.h"
 
+#ifdef HAVE_SECURITY_PAM_APPL_H
+# include <security/pam_appl.h>
+#endif
 #ifdef KERBEROS
 # ifdef HAVE_KERBEROSIV_DES_H
 #  include <kerberosIV/des.h>
@@ -127,6 +148,15 @@ char *getstr (const char *);
 int local_domain (const char *);
 const char *topdomain (const char *);
 
+#ifdef WITH_PAM
+static int pam_rc = PAM_AUTH_ERR;
+
+static pam_handle_t *pam_handle = NULL;
+static int rsh_conv (int, const struct pam_message **,
+		     struct pam_response **, void *);
+static struct pam_conv pam_conv = { rsh_conv, NULL };
+#endif /* WITH_PAM */
+
 #if defined KERBEROS || defined SHISHI
 # ifdef KERBEROS
 Key_schedule schedule;
@@ -172,10 +202,12 @@ static struct argp_option options[] = {
 extern int __check_rhosts_file;	/* hook in rcmd(3) */
 #endif
 
-#if defined __GLIBC__ && defined WITH_IRUSEROK
+#ifndef WITH_PAM
+# if defined __GLIBC__ && defined WITH_IRUSEROK
 extern int iruserok (uint32_t raddr, int superuser,
                      const char *ruser, const char *luser);
-#endif
+# endif
+#endif /* WITH_PAM */
 
 static error_t
 parse_opt (int key, char *arg, struct argp_state *state)
@@ -224,7 +256,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
 }
 
 
-const char doc[] = "Remote shell server";
+const char doc[] =
+#ifdef WITH_PAM
+		   "Remote shell server, using PAM service 'rsh'.";
+#else /* !WITH_PAM */
+		   "Remote shell server.";
+#endif
 static struct argp argp = { options, parse_opt, NULL, doc};
 
 
@@ -300,12 +337,16 @@ main (int argc, char *argv[])
   return 0;
 }
 
-char username[20] = "USER=";
-char logname[23] = "LOGNAME=";
-char homedir[64] = "HOME=";
-char shell[64] = "SHELL=";
-char path[100] = "PATH=";
-char *envinit[] = { homedir, shell, path, logname, username, 0 };
+char username[32 + sizeof ("USER=")] = "USER=";
+char logname[32 + sizeof ("LOGNAME=")] = "LOGNAME=";
+char homedir[256 + sizeof ("HOME=")] = "HOME=";
+char shell[64 + sizeof ("SHELL=")] = "SHELL=";
+char path[sizeof (PATH_DEFPATH) + sizeof ("PATH=")] = "PATH=";
+char rhost[128 + sizeof ("RHOST=")] = "RHOST=";
+
+#ifndef WITH_PAM
+char *envinit[] = { homedir, shell, path, logname, username, rhost, NULL };
+#endif
 extern char **environ;
 
 void
@@ -374,7 +415,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
   /* Verify that the client's address is an Internet adress. */
   if (fromp->sin_family != AF_INET)
     {
-      syslog (LOG_ERR, "malformed \"from\" address (af %d)\n",
+      syslog (LOG_ERR, "malformed originating address (af %d)\n",
 	      fromp->sin_family);
       exit (EXIT_FAILURE);
     }
@@ -571,7 +612,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 			    "Couldn't look up address for %s", remotehost);
 		    errorstr =
 		      "Couldn't look up address for your host (%s)\n";
-		    hostname = inet_ntoa (fromp->sin_addr);
+		    hostname = strdup (inet_ntoa (fromp->sin_addr));
 		  }
 		else
 		  for (;; hp->h_addr_list++)
@@ -582,14 +623,14 @@ doit (int sockfd, struct sockaddr_in *fromp)
 				  "Host addr %s not listed for host %s",
 				  inet_ntoa (fromp->sin_addr), hp->h_name);
 			  errorstr = "Host address mismatch for %s\n";
-			  hostname = inet_ntoa (fromp->sin_addr);
+			  hostname = strdup (inet_ntoa (fromp->sin_addr));
 			  break;
 			}
 		      if (!memcmp (hp->h_addr_list[0],
 				   (caddr_t) & fromp->sin_addr,
 				   sizeof fromp->sin_addr))
 			{
-			  hostname = hp->h_name;
+			  hostname = strdup (hp->h_name);
 			  break;	/* equal, OK */
 			}
 		    }
@@ -597,7 +638,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	  }
     }
   else
-    errorhost = hostname = inet_ntoa (fromp->sin_addr);
+    errorhost = hostname = strdup (inet_ntoa (fromp->sin_addr));
 
 #ifdef	KERBEROS
   if (use_kerberos)
@@ -798,6 +839,81 @@ doit (int sockfd, struct sockaddr_in *fromp)
       goto fail;
     }
 
+#ifdef WITH_PAM
+  pam_rc = pam_start ("rsh", locuser, &pam_conv, &pam_handle);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RHOST, hostname);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RUSER, remuser);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_TTY, "rsh");
+  if (pam_rc != PAM_SUCCESS)
+    {
+      errorstr = "Try again.\n";
+      goto fail;
+    }
+
+  pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_ABORT:
+	  pam_end (pam_handle, pam_rc);
+	  exit (EXIT_FAILURE);
+	default:
+	  errorstr = "Password incorrect.\n";
+	  goto fail;
+	}
+    }
+
+  pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_NEW_AUTHTOK_REQD:
+	case PAM_AUTH_ERR:
+	  errorstr = "Password incorrect.\n";
+	  goto fail;
+	  break;
+	case PAM_ACCT_EXPIRED:
+	case PAM_PERM_DENIED:
+	case PAM_USER_UNKNOWN:
+	default:
+	  errorstr = "Permission denied.";
+	  goto fail;
+	  break;
+	}
+    }
+
+  /* Renew client information, since the PAM stack may have
+   * mapped the request onto another identity.
+   */
+  free (locuser);
+  locuser = NULL;
+  pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &locuser);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_NOTICE | LOG_AUTH, "pam_get_item(PAM_USER): %s",
+	      pam_strerror (pam_handle, pam_rc));
+      /* Intentionally let `locuser' be ill defined.  */
+    }
+# ifdef HAVE_GETPWNAM_R
+  ret = getpwnam_r (locuser, &pwstor, pwbuf, pwbuflen, &pwd);
+  if (ret || pwd == NULL)
+# else /* !HAVE_GETPWNAM_R */
+  pwd = getpwnam (locuser);
+  if (pwd == NULL)
+# endif /* HAVE_GETPWNAM_R */
+    {
+      syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: unknown login. cmd='%.80s'",
+	      remuser, hostname, locuser, cmdbuf);
+      errorstr = "Login incorrect.\n";
+      goto fail;
+    }
+#endif /* WITH_PAM */
+
 #ifdef	KERBEROS
   if (use_kerberos)
     {
@@ -829,17 +945,22 @@ doit (int sockfd, struct sockaddr_in *fromp)
     }
   else
 #endif /* KERBEROS || SHISHI */
-#ifdef WITH_IRUSEROK
+
+#ifndef WITH_PAM
+# ifdef WITH_IRUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (iruserok (fromp->sin_addr.s_addr, pwd->pw_uid == 0,
                                    remuser, locuser)) < 0))
-#elif defined WITH_RUSEROK
+# elif defined WITH_RUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (ruserok (inet_ntoa (fromp->sin_addr),
 				  pwd->pw_uid == 0, remuser, locuser)) < 0))
-#else /* !WITH_IRUSEROK && !WITH_RUSEROK */
-#error Unable to use mandatory iruserok/ruserok.  This should not happen.
-#endif /* !WITH_IRUSEROK && !WITH_RUSEROK */
+# else /* !WITH_IRUSEROK && !WITH_RUSEROK */
+# error Unable to use mandatory iruserok/ruserok.  This should not happen.
+# endif /* !WITH_IRUSEROK && !WITH_RUSEROK */
+#else /* WITH_PAM */
+    if (0)	/* Wrapper for `fail' jump label.  */
+#endif /* !WITH_PAM */
     {
 #ifdef HAVE___RCMD_ERRSTR
       if (__rcmd_errstr)
@@ -852,6 +973,16 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		"%s@%s as %s: permission denied. cmd='%.80s'",
 		remuser, hostname, locuser, cmdbuf);
     fail:
+#ifdef WITH_PAM
+      if (pam_handle)
+	{
+	  if (pam_rc != PAM_SUCCESS)
+	    syslog (LOG_NOTICE | LOG_AUTH, "%s@%s as %s, PAM: %s",
+		    remuser, hostname, locuser,
+		    pam_strerror (pam_handle, pam_rc));
+	  pam_end (pam_handle, pam_rc);
+	}
+#endif /* WITH_PAM */
       if (errorstr == NULL)
 	errorstr = "Permission denied.\n";
       rshd_error (errorstr, errorhost);
@@ -1151,13 +1282,23 @@ doit (int sockfd, struct sockaddr_in *fromp)
     syslog (LOG_ERR, "setlogin() failed: %m");
 #endif
 
-  /* Set the fid, then uid to become the user specified by "locuser" */
+  /* Set the gid, then uid to become the user specified by "locuser" */
   setegid ((gid_t) pwd->pw_gid);
   setgid ((gid_t) pwd->pw_gid);
 #ifdef HAVE_INITGROUPS
   initgroups (pwd->pw_name, pwd->pw_gid);	/* BSD groups */
 #endif
 
+#ifdef WITH_PAM
+  pam_rc = pam_setcred (pam_handle, PAM_SILENT | PAM_ESTABLISH_CRED);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_ERR | LOG_AUTH, "pam_setcred: %s",
+	      pam_strerror (pam_handle, pam_rc));
+      pam_rc = PAM_SUCCESS;	/* Only report the above anomaly.  */
+    }
+#endif /* WITH_PAM */
+
   setuid ((uid_t) pwd->pw_uid);
 
   /* We'll execute the client's command in the home directory
@@ -1175,14 +1316,35 @@ doit (int sockfd, struct sockaddr_in *fromp)
     }
 
   /* Set up an initial environment for the shell that we exec() */
+  strncat (homedir, pwd->pw_dir, sizeof (homedir) - sizeof ("HOME=") - 1);
+  strncat (path, PATH_DEFPATH, sizeof (path) - sizeof ("PATH=") - 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 (rhost, hostname, sizeof (rhost) - 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, rhost);
+
+  environ = pam_getenvlist (pam_handle);
+#else /* !WITH_PAM */
   environ = envinit;
-  strncat (homedir, pwd->pw_dir, sizeof (homedir) - 6);
-  strcat (path, PATH_DEFPATH);
-  strncat (shell, pwd->pw_shell, sizeof (shell) - 7);
-  strncat (username, pwd->pw_name, sizeof (username) - 6);
+#endif /* WITH_PAM */
+
   cp = strrchr (pwd->pw_shell, '/');
   if (cp)
-    cp++;			/* step past first slash */
+    cp++;			/* step past last slash */
   else
     cp = pwd->pw_shell;		/* no slash in shell string */
   endpwent ();
@@ -1205,6 +1367,11 @@ doit (int sockfd, struct sockaddr_in *fromp)
   else
 #endif /* SHISHI */
     execl (pwd->pw_shell, cp, "-c", cmdbuf, NULL);
+
+#ifdef WITH_PAM
+  pam_end (pam_handle, PAM_SUCCESS);
+#endif
+  syslog (LOG_ERR, "execl failed for \"%s\": %m", pwd->pw_name);
   error (EXIT_FAILURE, errno, "cannot execute %s", pwd->pw_shell);
 }
 
@@ -1327,3 +1494,34 @@ topdomain (const char *h)
     }
   return maybe;
 }
+
+#ifdef WITH_PAM
+/* Call back function for passing user's information
+ * to any PAM module requesting this information.
+ */
+static int
+rsh_conv (int num, const struct pam_message **pam_msg,
+	    struct pam_response **pam_resp, void *data)
+{
+  struct pam_response *resp;
+
+  /* Reject composite calls at the time being.  */
+  if (num <= 0 || num > 1)
+    return PAM_CONV_ERR;
+
+  /* Ensure an empty response.  */
+  *pam_resp = NULL;
+
+  switch ((*pam_msg)->msg_style)
+    {
+    case PAM_PROMPT_ECHO_OFF:	/* Return an empty password.  */
+      return PAM_SUCCESS;
+    case PAM_TEXT_INFO:		/* Not yet supported.  */
+    case PAM_ERROR_MSG:		/* Likewise.  */
+    case PAM_PROMPT_ECHO_ON:	/* Interactivity is not supported.  */
+    default:
+      return PAM_CONV_ERR;
+    }
+  return PAM_CONV_ERR;	/* Never reached.  */
+}
+#endif /* WITH_PAM */

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


commit a4390104731d33a746dd0e4243e75daeddfde8f1
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Jun 15 11:45:49 2012 +0200

    rshd: Prefer use of getpwnam_r.

diff --git a/ChangeLog b/ChangeLog
index 4910d84..fae35bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* src/rshd.c (doit) [HAVE_GETPWNAM_R]: New variables
+	PWBUF, PWBUFLEN, PWSTOR, and RET.  Call getpwnam_r(),
+	checking both `ret' and `pwd == NULL' for failure.
+
 2012-06-15  Simon Josefsson  <simon@josefsson.org>
 
 	* bootstrap: Updated from gnulib.
diff --git a/src/rshd.c b/src/rshd.c
index c0cd7db..a65c812 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -139,12 +139,12 @@ Shishi_key *enckey;
 shishi_ivector iv1, iv2, iv3, iv4;
 shishi_ivector *ivtab[4];
 int protocol;
-# endif
+# endif /* SHISHI */
 # define VERSION_SIZE	9
 # define SECURE_MESSAGE  "This rsh session is using DES encryption for all transmissions.\r\n"
 int doencrypt, use_kerberos, vacuous;
 #else
-#endif
+#endif /* KERBEROS || SHISHI */
 
 static struct argp_option options[] = {
   { "verify-hostname", 'a', NULL, 0,
@@ -164,7 +164,7 @@ static struct argp_option options[] = {
   /* FIXME: Option name is misleading */
   { "vacuous", 'v', NULL, 0,
     "require Kerberos authentication" },
-#endif
+#endif /* KERBEROS */
   { NULL }
 };
 
@@ -210,7 +210,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
       doencrypt = 1;
       break;
 # endif
-#endif
+#endif /* KERBEROS || SHISHI */
 
     case 'L':
       log_success = 1;
@@ -264,8 +264,8 @@ main (int argc, char *argv[])
       syslog (LOG_ERR, "-k is required for -x");
       exit (EXIT_FAILURE);
     }
-# endif
-#endif
+# endif /* ENCRYPTION */
+#endif /* KERBEROS || SHISHI */
 
   /*
    * We assume we're invoked by inetd, so the socket that the
@@ -315,7 +315,13 @@ doit (int sockfd, struct sockaddr_in *fromp)
   extern char *__rcmd_errstr;	/* syslog hook from libc/net/rcmd.c. */
 #endif
   struct hostent *hp;
+#ifdef HAVE_GETPWNAM_R
+  char *pwbuf;
+  int ret, pwbuflen;
+  struct passwd *pwd, pwstor;
+#else /* !HAVE_GETPWNAM_R */
   struct passwd *pwd;
+#endif
   unsigned short port;
   fd_set ready, readfrom;
   int cc, nfd, pv[2], pid, s = sockfd;
@@ -335,14 +341,22 @@ doit (int sockfd, struct sockaddr_in *fromp)
   fd_set wready, writeto;
 
   fromaddr = *fromp;
-#elif defined SHISHI
+#elif defined SHISHI /* !KERBEROS */
   int n;
   int pv1[2], pv2[2];
   fd_set wready, writeto;
   int keytype, keylen;
   int cksumtype, cksumlen;
   char *cksum = NULL;
-#endif
+#endif /* KERBEROS || SHISHI */
+
+#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);
@@ -513,7 +527,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
       rshd_error ("rshd: remote host requires Kerberos authentication\n");
       exit (EXIT_FAILURE);
     }
-#endif
+#endif /* KERBEROS || SHISHI */
 
   /* from inetd, socket is already on 0, 1, 2 */
   if (sockfd != STDIN_FILENO)
@@ -612,7 +626,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	  des_set_key (kdata->session, schedule);
 	}
       else
-# endif
+# endif /* ENCRYPTION */
 	rc = krb_recvauth (authopts, 0, ticket, "rcmd",
 			   instance, &fromaddr,
 			   (struct sockaddr_in *) 0,
@@ -625,7 +639,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	}
     }
   else
-#elif defined (SHISHI)
+#elif defined (SHISHI) /* !KERBEROS */
   if (use_kerberos)
     {
       int rc;
@@ -641,7 +655,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	}
     }
   else
-#endif
+#endif /* KERBEROS || SHISHI */
     remuser = getstr ("remuser");
 
   /* Read three strings from the client. */
@@ -717,7 +731,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	    }
 
 	}
-# endif
+# endif /* ENCRYPTION */
 
     remuser = getstr ("remuser");
     rc = read (STDIN_FILENO, &error, sizeof (int));
@@ -763,14 +777,19 @@ doit (int sockfd, struct sockaddr_in *fromp)
     shishi_ap_done (ap);
 
   }
-#endif
+#endif /* SHISHI */
 
-  /* Look up locuser in the passerd file.  The locuser has\* to be a
+  /* Look up locuser in the passwd file.  The locuser has to be a
    * valid account on this system.
    */
   setpwent ();
+#ifdef HAVE_GETPWNAM_R
+  ret = getpwnam_r (locuser, &pwstor, pwbuf, pwbuflen, &pwd);
+  if (ret || pwd == NULL)
+#else /* !HAVE_GETPWNAM_R */
   pwd = getpwnam (locuser);
   if (pwd == NULL)
+#endif /* HAVE_GETPWNAM_R */
     {
       syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: unknown login. cmd='%.80s'",
 	      remuser, hostname, locuser, cmdbuf);
@@ -794,7 +813,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	}
     }
   else
-#elif defined(SHISHI)
+#elif defined(SHISHI) /* !KERBEROS */
   if (use_kerberos)
     {				/*
 				   if (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0')
@@ -809,7 +828,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 				   } */
     }
   else
-#endif
+#endif /* KERBEROS || SHISHI */
 #ifdef WITH_IRUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (iruserok (fromp->sin_addr.s_addr, pwd->pw_uid == 0,
@@ -828,7 +847,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		"%s@%s as %s: permission denied (%s). cmd='%.80s'",
 		remuser, hostname, locuser, __rcmd_errstr, cmdbuf);
       else
-#endif
+#endif /* HAVE___RCMD_ERRSTR */
 	syslog (LOG_INFO | LOG_AUTH,
 		"%s@%s as %s: permission denied. cmd='%.80s'",
 		remuser, hostname, locuser, cmdbuf);
@@ -888,8 +907,8 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	      exit (EXIT_FAILURE);
 	    }
 	}
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
       pid = fork ();
       if (pid == -1)
 	{
@@ -913,15 +932,15 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	      des_write (s, msg, sizeof (msg) - 1);
 	    }
 	  else
-# elif defined(SHISHI)
+# elif defined(SHISHI) /* !KERBEROS */
 	  if (doencrypt)
 	    {
 	      close (pv1[1]);
 	      close (pv2[1]);
 	    }
 	  else
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 	    {
 	      /* child handles the original socket */
 	      close (STDIN_FILENO);
@@ -951,8 +970,8 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	      nfd = MAX (nfd, pv1[0]);
 	    }
 	  else
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 	    ioctl (pv[0], FIONBIO, (char *) &one);
 	  /* should set s nbio! */
 	  nfd++;
@@ -965,7 +984,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		{
 #  ifdef SHISHI
 		  wready = readfrom;
-#  else
+#  else /* KERBEROS && !SHISHI */
 		  wready = writeto;
 #  endif
 		  if (select (nfd, &ready, &wready, (fd_set *) 0,
@@ -973,11 +992,11 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		    break;
 		}
 	      else
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 	      if (select (nfd, &ready, (fd_set *) 0,
 			    (fd_set *) 0, (struct timeval *) 0) < 0)
-		/* wait until something to read */
+		/* wait until there is something to read */
 		break;
 	      if (FD_ISSET (s, &ready))
 		{
@@ -987,12 +1006,12 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		  if (doencrypt)
 		    ret = des_read (s, &sig, 1);
 		  else
-# elif defined(SHISHI)
+# elif defined(SHISHI) /* !KERBEROS */
 		  if (doencrypt)
 		    readenc (h, s, &sig, &ret, &iv2, enckey, protocol);
 		  else
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 		    ret = read (s, &sig, 1);
 		  if (ret <= 0)
 		    FD_CLR (s, &readfrom);
@@ -1015,12 +1034,12 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		      if (doencrypt)
 			des_write (s, buf, cc);
 		      else
-# elif defined(SHISHI)
+# elif defined(SHISHI) /* !KERBEROS */
 		      if (doencrypt)
 			writeenc (h, s, buf, cc, &n, &iv4, enckey, protocol);
 		      else
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 			write (s, buf, cc);
 		    }
 		}
@@ -1039,7 +1058,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 #  ifdef SHISHI
 		    writeenc (h, STDOUT_FILENO, buf, cc, &n, &iv3, enckey,
 			      protocol);
-#  else
+#  else /* KERBEROS */
 		    des_write (STDOUT_FILENO, buf, cc);
 #  endif
 		}
@@ -1049,7 +1068,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		  errno = 0;
 #  ifdef SHISHI
 		  readenc (h, STDIN_FILENO, buf, &cc, &iv1, enckey, protocol);
-#  else
+#  else /* KERBEROS */
 		  cc = des_read (STDIN_FILENO, buf, sizeof buf);
 #  endif
 		  if (cc <= 0)
@@ -1060,18 +1079,18 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		  else
 		    write (pv2[0], buf, cc);
 		}
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 	    }
 	  while (FD_ISSET (s, &readfrom) ||
 #ifdef ENCRYPTION
 # if defined KERBEROS || defined SHISHI
 		 (doencrypt && FD_ISSET (pv1[0], &readfrom)) ||
 # endif
-#endif
+#endif /* ENCRYPTION */
 		 FD_ISSET (pv[0], &readfrom));
-	  /* The pipe will generat an EOR whe the shell
-	   * terminates.  The socket will terninate whe the
+	  /* The pipe will generate an EOF when the shell
+	   * terminates.  The socket will terminate when the
 	   * client process terminates.
 	   */
 	  exit (EXIT_SUCCESS);
@@ -1097,8 +1116,8 @@ doit (int sockfd, struct sockaddr_in *fromp)
 	  close (pv1[1]);
 	  close (pv2[1]);
 	}
-# endif
-#endif
+# endif /* KERBEROS || SHISHI */
+#endif /* ENCRYPTION */
 
 #if defined SHISHI
       if (use_kerberos)
@@ -1116,10 +1135,10 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		  free (ivtab[i]->iv);
 		}
 	    }
-# endif
+# endif /* ENCRYPTION */
 	}
 
-#endif
+#endif /* SHISHI */
 
       dup2 (pv[1], STDERR_FILENO);	/* stderr of shell has to go
 					   pipe to control process */
@@ -1176,7 +1195,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
 		kdata->pname, kdata->pinst, kdata->prealm,
 		hostname, locuser, cmdbuf);
       else
-#endif
+#endif /* KERBEROS */
 	syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: cmd='%.80s'",
 		remuser, hostname, locuser, cmdbuf);
     }
@@ -1184,7 +1203,7 @@ doit (int sockfd, struct sockaddr_in *fromp)
   if (doencrypt)
     execl (pwd->pw_shell, cp, "-c", cmdbuf + 3, NULL);
   else
-#endif
+#endif /* SHISHI */
     execl (pwd->pw_shell, cp, "-c", cmdbuf, NULL);
   error (EXIT_FAILURE, errno, "cannot execute %s", pwd->pw_shell);
 }

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

Summary of changes:
 ChangeLog       |   81 ++++++++
 configure.ac    |   39 ++++-
 src/Makefile.am |    2 +-
 src/rcp.c       |   29 +++
 src/rsh.c       |   20 ++-
 src/rshd.c      |  573 ++++++++++++++++++++++++++++++++++++++++++++++---------
 6 files changed, 645 insertions(+), 99 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Tue Jun 26 13:31:26 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1SjZbq-000118-I6
	for mharc-commit-inetutils@gnu.org; Tue, 26 Jun 2012 13:31:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:38616)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SjZbi-0000bz-85
	for commit-inetutils@gnu.org; Tue, 26 Jun 2012 13:31:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SjZbX-0006RW-GV
	for commit-inetutils@gnu.org; Tue, 26 Jun 2012 13:31:17 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53326)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1SjZbX-0006R3-Cb
	for commit-inetutils@gnu.org; Tue, 26 Jun 2012 13:31:07 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1SjZbW-0004Ut-8h
	for commit-inetutils@gnu.org; Tue, 26 Jun 2012 17:31:07 +0000
Date: Tue, 26 Jun 2012 17:31:06 +0000
Message-Id: <E1SjZbW-0004Ut-8h@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-120-g3e80d3a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 164de7caca05f8920e45c5a9b81e7a3069536b86
X-Git-Newrev: 3e80d3ab10a603309fc51ac899361bd2dcf83bdf
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, 26 Jun 2012 17:31:24 -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  3e80d3ab10a603309fc51ac899361bd2dcf83bdf (commit)
       via  929d612adb27bc6a5aed4b4b5a3c5ba6ab975189 (commit)
      from  164de7caca05f8920e45c5a9b81e7a3069536b86 (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=3e80d3ab10a603309fc51ac899361bd2dcf83bdf


commit 3e80d3ab10a603309fc51ac899361bd2dcf83bdf
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Jun 25 23:43:06 2012 +0200

    rlogind: Address manipulations.

diff --git a/ChangeLog b/ChangeLog
index d88857c..01de26d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2012-06-25  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	rlogind: Prepare for address independence.
+	Update some coding techniques to simplify later
+	IPv6 migration.
+
+	* libinetutils/shishi_def.h (struct auth_data):
+	New members `socklen_t fromlen', `char *hostaddr'.
+	* src/rlogind.c (struct auth_data): Likewise.
+	(rlogin_daemon) [HAVE_STRUCT_SOCKADDR_IN_SIN_LEN]:
+	Assign missing value for `saddr.sin_len'.
+	(rlogind_auth): Use `ap->hostaddr' as address string.
+	[HAVE_DECL_GETNAMEINFO || HAVE_DECL_GETADDRINFO]:
+	New variables RC and HOSTSTR; delete HP in this case.
+	[HAVE_DECL_GETNAMEINFO]: Alternate code for finding
+	host name.
+	[HAVE_DECL_GETADDRINFO && HAVE_DECL_GETNAMEINFO]:
+	Alternate code for host name validation.
+	(rlogind_mainloop): Deleted variable SIZE.  New
+	variables ADDRSTR and REPLY.  Put socket address
+	size in `auth_data.fromlen'.  Determine host address
+	`auth_data.hostaddr' by calling inet_ntop() once.
+	[WITH_IRUSEROK_SA || WITH_IRUSEROK_AF || WITH_IRUSEROK]:
+	Choose the best available iruserok variant.
+	[WITH_RUSEROK_AF || WITH_RUSEROK]: Choose best variant.
+	(do_shishi_login): Compute SOCKLEN as `sizeof (sock)'.
+
+2012-06-25  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	rcp, rlogin, rsh, rshd: IPv6 ability.
 
 	* src/rcp.c (family) [WITH_ORCMD_AF || WITH_RCMD_AF]:
diff --git a/libinetutils/shishi_def.h b/libinetutils/shishi_def.h
index 8a43b10..2351d34 100644
--- a/libinetutils/shishi_def.h
+++ b/libinetutils/shishi_def.h
@@ -37,6 +37,8 @@ typedef struct shishi_iv shishi_ivector;
 struct auth_data
 {
   struct sockaddr_in from;
+  socklen_t fromlen;
+  char *hostaddr;
   char *hostname;
   char *lusername;
   char *rusername;
diff --git a/src/rlogind.c b/src/rlogind.c
index 19dd6ab..b3451ef 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -145,6 +145,8 @@ extern int __check_rhosts_file;
 struct auth_data
 {
   struct sockaddr_in from;
+  socklen_t fromlen;
+  char *hostaddr;
   char *hostname;
   char *lusername;
   char *rusername;
@@ -481,6 +483,9 @@ rlogin_daemon (int maxchildren, int port)
   size = sizeof saddr;
   memset (&saddr, 0, size);
   saddr.sin_family = AF_INET;
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+  saddr.sin_len = sizeof (struct sockaddr_in);
+#endif
   saddr.sin_addr.s_addr = htonl (INADDR_ANY);
   saddr.sin_port = htons (port);
 
@@ -534,7 +539,12 @@ rlogin_daemon (int maxchildren, int port)
 int
 rlogind_auth (int fd, struct auth_data *ap)
 {
+#if defined HAVE_DECL_GETNAMEINFO || defined HAVE_DECL_GETADDRINFO
+  int rc;
+  char hoststr[NI_MAXHOST];
+#else
   struct hostent *hp;
+#endif
   char *hostname;
   int authenticated = 0;
 
@@ -545,24 +555,55 @@ rlogind_auth (int fd, struct auth_data *ap)
   confirmed = 0;
 
   /* Check the remote host name */
+#ifdef HAVE_DECL_GETNAMEINFO
+  rc = getnameinfo ((struct sockaddr *) &ap->from, ap->fromlen,
+		    hoststr, sizeof (hoststr), NULL, 0, NI_NAMEREQD);
+  if (!rc)
+    hostname = hoststr;
+#else /* !HAVE_DECL_GETNAMEINFO */
   hp = gethostbyaddr ((char *) &ap->from.sin_addr, sizeof (struct in_addr),
 		      ap->from.sin_family);
   if (hp)
     hostname = hp->h_name;
+#endif /* !HAVE_DECL_GETNAMEINFO */
   else if (reverse_required)
     {
       syslog (LOG_CRIT, "can't resolve remote IP address");
       exit (EXIT_FAILURE);
     }
   else
-    hostname = inet_ntoa (ap->from.sin_addr);
+    hostname = ap->hostaddr;
 
   ap->hostname = strdup (hostname);
 
   if (verify_hostname || in_local_domain (ap->hostname))
     {
       int match = 0;
+#if defined HAVE_DECL_GETADDRINFO && defined HAVE_DECL_GETNAMEINFO
+      struct addrinfo hints, *ai, *res;
+      char astr[INET6_ADDRSTRLEN];
+
+      memset (&hints, 0, sizeof (hints));
+      hints.ai_family = ap->from.sin_family;
+      hints.ai_socktype = SOCK_STREAM;
 
+      rc = getaddrinfo (ap->hostname, NULL, &hints, &res);
+      if (!rc)
+	{
+	  for (ai = res; ai; ai = ai->ai_next)
+	    {
+	      rc = getnameinfo (ai->ai_addr, ai->ai_addrlen,
+				astr, sizeof (astr), NULL, 0,
+				NI_NUMERICHOST);
+	      if (rc)
+		continue;
+	      match = strcmp (astr, ap->hostaddr) == 0;
+	      if (match)
+		break;
+	    }
+	  freeaddrinfo (res);
+	}
+#else /* !HAVE_DECL_GETADDRINFO */
       for (hp = gethostbyname (ap->hostname); hp && !match; hp->h_addr_list++)
 	{
 	  if (hp->h_addr_list[0] == NULL)
@@ -570,10 +611,11 @@ rlogind_auth (int fd, struct auth_data *ap)
 	  match = memcmp (hp->h_addr_list[0], &ap->from.sin_addr,
 			  sizeof (ap->from.sin_addr)) == 0;
 	}
+#endif /* !HAVE_DECL_GETADDRINFO */
       if (!match)
 	{
 	  syslog (LOG_ERR | LOG_AUTH, "cannot verify matching IP for %s (%s)",
-		  ap->hostname, inet_ntoa (ap->from.sin_addr));
+		  ap->hostname, ap->hostaddr);
 	  fatal (fd, "Permission denied", 0);
 	}
     }
@@ -600,7 +642,7 @@ rlogind_auth (int fd, struct auth_data *ap)
 	  port >= IPPORT_RESERVED || port < IPPORT_RESERVED / 2)
 	{
 	  syslog (LOG_NOTICE, "Connection from %s on illegal port %d",
-		  inet_ntoa (ap->from.sin_addr), port);
+		  ap->hostaddr, port);
 	  fatal (fd, "Permission denied", 0);
 	}
 #ifdef IP_OPTIONS
@@ -629,7 +671,7 @@ rlogind_auth (int fd, struct auth_data *ap)
 		  {
 		    syslog (LOG_NOTICE,
 			    "Discarding connection from %s with set source routing",
-			    inet_ntoa (ap->from.sin_addr));
+			    ap->hostaddr);
 		    exit (EXIT_FAILURE);
 		  }
 		if (*cp == IPOPT_EOL)
@@ -751,24 +793,34 @@ exec_login (int authenticated, struct auth_data *ap)
 int
 rlogind_mainloop (int infd, int outfd)
 {
-  socklen_t size;
   struct auth_data auth_data;
+  char addrstr[INET6_ADDRSTRLEN];
+  const char *reply;
   int true;
   char c;
   int authenticated;
   pid_t pid;
   int master;
 
-  memset (&auth_data, 0, sizeof auth_data);
-  size = sizeof auth_data.from;
-  if (getpeername (infd, (struct sockaddr *) &auth_data.from, &size) < 0)
+  memset (&auth_data, 0, sizeof (auth_data));
+  auth_data.fromlen = sizeof (auth_data.from);
+  if (getpeername (infd, (struct sockaddr *) &auth_data.from,
+		   &auth_data.fromlen) < 0)
     {
       syslog (LOG_ERR, "Can't get peer name of remote host: %m");
       fatal (outfd, "Can't get peer name of remote host", 1);
     }
 
-  syslog (LOG_INFO, "Connect from %s:%d",
-	  inet_ntoa (auth_data.from.sin_addr),
+  reply = inet_ntop (auth_data.from.sin_family, &auth_data.from.sin_addr,
+		     addrstr, sizeof (addrstr));
+  if (reply == NULL)
+    {
+      syslog (LOG_ERR, "Get numerical address: %m");
+      fatal (outfd, "Cannot get numerical address of peer.", 1);
+    }
+  auth_data.hostaddr = xstrdup (addrstr);
+
+  syslog (LOG_INFO, "Connect from %s:%d", auth_data.hostaddr,
 	  ntohs (auth_data.from.sin_port));
 
   true = 1;
@@ -881,22 +933,35 @@ do_rlogin (int infd, struct auth_data *ap)
       fatal (infd, "Permission denied", 0);
     }
 
-#ifdef WITH_IRUSEROK
+#if defined WITH_IRUSEROK_SA || defined WITH_IRUSEROK_AF \
+    || defined WITH_IRUSEROK
+# ifdef WITH_IRUSEROK_SA
+  rc = iruserok_sa ((struct sockaddr *) &ap->from, ap->fromlen, 0,
+		    ap->rusername, ap->lusername);
+# elif defined WITH_IRUSEROK_AF
+  rc = iruserok_af (&ap->from.sin_addr, 0, ap->rusername, ap->lusername,
+		    ap->from.sin_family);
+# else /* WITH_IRUSEROK */
   rc = iruserok (ap->from.sin_addr.s_addr, 0, ap->rusername, ap->lusername);
+# endif /* WITH_IRUSEROK_SA || WITH_IRUSEROK_AF || WITH_IRUSEROK */
   if (rc)
     syslog (LOG_ERR | LOG_AUTH,
 	    "iruserok failed: rusername=%s, lusername=%s",
 	    ap->rusername, ap->lusername);
-#elif defined WITH_RUSEROK
-  rc = ruserok (inet_ntoa (ap->from.sin_addr), 0, ap->rusername,
-		ap->lusername);
+#elif defined WITH_RUSEROK_AF || defined WITH_RUSEROK
+# ifdef WITH_RUSEROK_AF
+  rc = ruserok_af (ap->hostaddr, 0, ap->rusername, ap->lusername,
+		   ap->from.sin_family);
+# else /* WITH_RUSEROK */
+  rc = ruserok (ap->hostaddr, 0, ap->rusername, ap->lusername);
+# endif /* WITH_RUSEROK_AF || WITH_RUSEROK */
   if (rc)
     syslog (LOG_ERR | LOG_AUTH,
 	    "ruserok failed: rusername=%s, lusername=%s",
 	    ap->rusername, ap->lusername);
-#else /* !WITH_IRUSEROK && !WITH_RUSEROK */
+#else /* !WITH_IRUSEROK* && !WITH_RUSEROK* */
 #error Unable to use mandatory iruserok/ruserok.  This should not happen.
-#endif /* !WITH_IRUSEROK && !WITH_RUSEROK */
+#endif /* !WITH_IRUSEROK* && !WITH_RUSEROK* */
 
   return rc;
 }
@@ -1116,7 +1181,7 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
   size_t compcksumlen;
   char cksumdata[100];
   struct sockaddr_in sock;
-  size_t socklen = sizeof (struct sockaddr_in);
+  size_t socklen = sizeof (sock);
 
 #  ifdef ENCRYPTION
   rc = get_auth (infd, &ad->h, &ad->ap, &ad->enckey, err_msg, &ad->protocol,

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


commit 929d612adb27bc6a5aed4b4b5a3c5ba6ab975189
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Jun 25 22:43:42 2012 +0200

    rcp, rlogin, rsh, rshd: IPv6 ability.

diff --git a/ChangeLog b/ChangeLog
index c395d5b..d88857c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,51 @@
+2012-06-25  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rcp, rlogin, rsh, rshd: IPv6 ability.
+
+	* src/rcp.c (family) [WITH_ORCMD_AF || WITH_RCMD_AF]:
+	New variable.
+	(options) [WITH_ORCMD_AF || WITH_RCMD_AF]: New options
+	`4/ipv4' and `6/ipv6'.
+	(parse_opt) [WITH_ORCMD_AF || WITH_RCMD_AF] <4, 6>:
+	Assign value AF_INET or AF_INET6 to `family'.
+	(toremote, kerberos) [WITH_ORCMD_AF || WITH_RCMD_AF]:
+	Replace AF_INET by `family' in orcmf_af() and rcmd_af().
+	(tolocal) [WITH_ORCMD_AF || WITH_RCMD_AF]: Likewise.
+	[!KERBEROS && WITH_ORCMD_AF]: Correction to conditional.
+	Call one of the rcmd() variants only if the macro KERBEROS
+	is not defined.
+
+	* src/rlogin.c (family) [WITH_ORCMD_AF || WITH_RCMD_AF]:
+	New variable.
+	(argp_options) [WITH_ORCMD_AF || WITH_RCMD_AF]: New
+	options `4/ipv4' and `6/ipv6'.
+	(parse_opt) [WITH_ORCMD_AF || WITH_RCMD_AF] <4, 6>:
+	Assign value AF_INET or AF_INET6 to `family'.
+	(main) [WITH_ORCMD_AF]: Call orcmd_af().
+	[WITH_RCMD_AF && !WITH_ORCMD_AF]: Call rcmd_af().
+	[WITH_ORCMD && !WITH_ORCMD_AF && !WITH_RCMD_AF]:
+	Call orcmd().
+
+	* src/rsh.c (family) [WITH_ORCMD_AF || WITH_RCMD_AF]:
+	New variable.
+	(options) [WITH_ORCMD_AF || WITH_RCMD_AF]: New options
+	`4/ipv4' and `6/ipv6'.
+	(parse_opt) [WITH_ORCMD_AF || WITH_RCMD_AF] <4, 6>:
+	Assign value AF_INET or AF_INET6 to `family'.
+	(main) [WITH_ORCMD_AF]: Use `family' in last argument
+	to orcmd_af().
+	[WITH_RCMD_AF]: Likewise for rcmd_af().
+
+	* src/rshd.c (main): New type `struct sockaddr_storage from'.
+	Cast &FROM as `struct sockaddr *' when calling doit().
+	(doit): New signature `(int, struct sockaddr *, socklen_t)'.
+	Adapt code to new parameter type `struct sockaddr * fromp',
+	using casts whenever needed.  Check `fromp->sa_family'.
+	[WITH_IRUSEROK_AF && !WITH_PAM]: New variable FROMADDRP.
+	[KERBEROS || SHISHI]: Check for IPv4 only in this case.
+	<hostname validation> [HAVE_DECL_GETNAMEINFO]: Use the
+	flag NI_NAMEREQD.
+
 2012-06-19  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rshd: PAM session handling.
diff --git a/src/rcp.c b/src/rcp.c
index 0f8c114..f5d5e67 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -128,6 +128,9 @@ const char arg_doc[] = "SOURCE DEST\n"
 int preserve_option;
 int from_option, to_option;
 int iamremote, iamrecursive, targetshouldbedirectory;
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+sa_family_t family = AF_UNSPEC;
+#endif
 
 static struct argp_option options[] = {
 #define GRID 0
@@ -162,6 +165,14 @@ static struct argp_option options[] = {
   { "to", 't', NULL, 0,
     "copying to remote host",
     GRID+1 },
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+  { "ipv4", '4', NULL, 0,
+    "use only IPv4",
+    GRID+1 },
+  { "ipv6", '6', NULL, 0,
+    "use only IPv6",
+    GRID+1 },
+#endif /* WITH_ORCMD_AF || WITH_RCMD_AF */
   { NULL }
 };
 
@@ -170,6 +181,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+    case '4':
+      family = AF_INET;
+      break;
+    case '6':
+      family = AF_INET6;
+      break;
+#endif /* WITH_ORCMD_AF || WITH_RCMD_AF */
+
 #ifdef KERBEROS
     case 'K':
       use_kerberos = 0;
@@ -432,11 +452,11 @@ toremote (char *targ, int argc, char *argv[])
 #ifdef WITH_ORCMD_AF
 		rem = orcmd_af (&host, port, pwd->pw_name,
 				tuser ? tuser : pwd->pw_name,
-				bp, 0, AF_INET);
+				bp, 0, family);
 #elif defined WITH_RCMD_AF
 		rem = rcmd_af (&host, port, pwd->pw_name,
 			       tuser ? tuser : pwd->pw_name,
-			       bp, 0, AF_INET);
+			       bp, 0, family);
 #elif defined WITH_ORCMD
 		rem = orcmd (&host, port, pwd->pw_name,
 			     tuser ? tuser : pwd->pw_name, bp, 0);
@@ -507,11 +527,10 @@ tolocal (int argc, char *argv[])
       rem =
 #ifdef KERBEROS
 	use_kerberos ? kerberos (&host, bp, pwd->pw_name, suser) :
-#endif
-#ifdef WITH_ORCMD_AF
-	orcmd_af (&host, port, pwd->pw_name, suser, bp, 0, AF_INET);
+#elif defined WITH_ORCMD_AF
+	orcmd_af (&host, port, pwd->pw_name, suser, bp, 0, family);
 #elif defined WITH_RCMD_AF
-	rcmd_af (&host, port, pwd->pw_name, suser, bp, 0, AF_INET);
+	rcmd_af (&host, port, pwd->pw_name, suser, bp, 0, family);
 #elif defined WITH_ORCMD
 	orcmd (&host, port, pwd->pw_name, suser, bp, 0);
 #else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
@@ -1063,15 +1082,15 @@ again:
       if (doencrypt)
 	error (EXIT_FAILURE, 0, "the -x option requires Kerberos authentication");
 # endif
-#ifdef WITH_ORCMD_AF
-      rem = orcmd_af (host, port, locuser, user, bp, 0, AF_INET);
-#elif defined WITH_RCMD_AF
-      rem = rcmd_af (host, port, locuser, user, bp, 0, AF_INET);
-#elif defined WITH_ORCMD
+# ifdef WITH_ORCMD_AF
+      rem = orcmd_af (host, port, locuser, user, bp, 0, family);
+# elif defined WITH_RCMD_AF
+      rem = rcmd_af (host, port, locuser, user, bp, 0, family);
+# elif defined WITH_ORCMD
       rem = orcmd (host, port, locuser, user, bp, 0);
-#else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
+# else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
       rem = rcmd (host, port, locuser, user, bp, 0);
-#endif
+# endif
     }
   return rem;
 }
diff --git a/src/rlogin.c b/src/rlogin.c
index 2e5c5ba..d4f0171 100644
--- a/src/rlogin.c
+++ b/src/rlogin.c
@@ -178,6 +178,9 @@ int noescape;
 char * host = NULL;
 char * user = NULL;
 unsigned char escapechar = '~';
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+sa_family_t family = AF_UNSPEC;
+#endif
 
 #ifdef OLDSUN
 
@@ -248,6 +251,10 @@ static struct argp_option argp_options[] = {
   {"realm", 'k', "REALM", 0, "obtain tickets for the remote host in REALM "
    "realm instead of the remote's realm", GRP+1},
 #endif
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+  { "ipv4", '4', NULL, 0, "use only IPv4" },
+  { "ipv6", '6', NULL, 0, "use only IPv6" },
+#endif
 #undef GRP
   {NULL}
 };
@@ -257,6 +264,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+    case '4':
+      family = AF_INET;
+      break;
+    case '6':
+      family = AF_INET6;
+      break;
+#endif
     /* 8-bit input Specifying this forces us to use RAW mode input from
        the user's terminal.  Also, in this mode we won't perform any
        local flow control.  */
@@ -550,14 +565,29 @@ try_connect:
       if (!user)
 	user = pw->pw_name;
 
+# ifdef WITH_ORCMD_AF
+      rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, term, 0, family);
+# elif defined WITH_RCMD_AF
+      rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, term, 0, family);
+# elif defined WITH_ORCMD
+      rem = orcmd (&host, sp->s_port, pw->pw_name, user, term, 0);
+# else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
       rem = rcmd (&host, sp->s_port, pw->pw_name, user, term, 0);
+# endif
     }
-#else
+#else /* !KERBEROS && !SHISHI */
   if (!user)
     user = pw->pw_name;
 
+# ifdef WITH_ORCMD_AF
+  rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, term, 0, family);
+# elif defined WITH_RCMD_AF
+  rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, term, 0, family);
+# elif defined WITH_ORCMD
+  rem = orcmd (&host, sp->s_port, pw->pw_name, user, term, 0);
+# else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
   rem = rcmd (&host, sp->s_port, pw->pw_name, user, term, 0);
-
+# endif
 #endif /* KERBEROS */
 
   if (rem < 0)
diff --git a/src/rsh.c b/src/rsh.c
index da3306f..aabc88f 100644
--- a/src/rsh.c
+++ b/src/rsh.c
@@ -96,6 +96,9 @@
 int debug_option = 0;
 int null_input_option = 0;
 char *user = NULL;
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+sa_family_t family = AF_UNSPEC;
+#endif
 
 #if defined KERBEROS || defined SHISHI
 int use_kerberos = 1, doencrypt;
@@ -154,6 +157,10 @@ static struct argp_option options[] = {
   { "encrypt", 'x', NULL, 0,
     "encrypt all data using DES" },
 #endif
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+  { "ipv4", '4', NULL, 0, "use only IPv4" },
+  { "ipv6", '6', NULL, 0, "use only IPv6" },
+#endif
   { NULL }
 };
 
@@ -162,6 +169,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
+#if defined WITH_ORCMD_AF || defined WITH_RCMD_AF
+    case '4':
+      family = AF_INET;
+      break;
+    case '6':
+      family = AF_INET6;
+      break;
+#endif
     case 'L':		/* -8Lew are ignored to allow rlogin aliases */
     case 'e':
     case 'w':
@@ -446,9 +461,9 @@ try_connect:
       if (doencrypt)
 	error (EXIT_FAILURE, 0, "the -x flag requires Kerberos authentication");
 # ifdef WITH_ORCMD_AF
-      rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+      rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, family);
 # elif defined WITH_RCMD_AF
-      rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+      rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, family);
 # elif defined WITH_ORCMD
       rem = orcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
 # else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
@@ -459,9 +474,9 @@ try_connect:
   if (!user)
     user = pw->pw_name;
 # ifdef WITH_ORCMD_AF
-  rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+  rem = orcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, family);
 # elif defined WITH_RCMD_AF
-  rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, AF_INET);
+  rem = rcmd_af (&host, sp->s_port, pw->pw_name, user, args, &rfd2, family);
 # elif defined WITH_ORCMD
   rem = orcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);
 # else /* !WITH_ORCMD_AF && !WITH_RCMD_AF && !WITH_ORCMD */
diff --git a/src/rshd.c b/src/rshd.c
index 0979421..fe361cd 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -163,7 +163,7 @@ int check_all;
 int log_success;		/* If TRUE, log all successful accesses */
 int sent_null;
 
-void doit (int, struct sockaddr_in *, socklen_t);
+void doit (int, struct sockaddr *, socklen_t);
 void rshd_error (const char *, ...);
 char *getstr (const char *);
 int local_domain (const char *);
@@ -294,7 +294,7 @@ main (int argc, char *argv[])
   struct linger linger;
   int on = 1;
   socklen_t fromlen;
-  struct sockaddr_in from;
+  struct sockaddr_storage from;
   int sockfd;
 
   set_program_name (argv[0]);
@@ -354,7 +354,7 @@ main (int argc, char *argv[])
   if (setsockopt (sockfd, SOL_SOCKET, SO_LINGER, (char *) &linger,
 		  sizeof linger) < 0)
     syslog (LOG_WARNING, "setsockopt (SO_LINGER): %m");
-  doit (sockfd, &from, fromlen);
+  doit (sockfd, (struct sockaddr *) &from, fromlen);
   return 0;
 }
 
@@ -371,12 +371,11 @@ char *envinit[] = { homedir, shell, path, logname, username, rhost, NULL };
 extern char **environ;
 
 void
-doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
+doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 {
 #ifdef HAVE___RCMD_ERRSTR
   extern char *__rcmd_errstr;	/* syslog hook from libc/net/rcmd.c. */
 #endif
-  struct hostent *hp;
 #ifdef HAVE_GETPWNAM_R
   char *pwbuf;
   int ret, pwbuflen;
@@ -391,10 +390,15 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
   char portstr[8], addrstr[INET6_ADDRSTRLEN];
 #ifdef HAVE_DECL_GETNAMEINFO
   char addrname[NI_MAXHOST];
+#else /* !HAVE_DECL_GETNAMEINFO */
+  struct hostent *hp;
 #endif
   const char *hostname, *errorstr, *errorhost = NULL;
   char *cp, sig, buf[BUFSIZ];
   char *cmdbuf, *locuser, *remuser;
+#if defined WITH_IRUSEROK_AF && !defined WITH_PAM
+  void * fromaddrp;	/* Pointer to remote address.  */
+#endif
 
 #ifdef	KERBEROS
   AUTH_DAT *kdata = (AUTH_DAT *) NULL;
@@ -438,7 +442,7 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 #endif
 
 #ifdef HAVE_DECL_GETNAMEINFO
-  rc = getnameinfo ((struct sockaddr *) fromp, fromlen,
+  rc = getnameinfo (fromp, fromlen,
 		    addrstr, sizeof (addrstr),
 		    portstr, sizeof (portstr),
 		    NI_NUMERICHOST | NI_NUMERICSERV);
@@ -449,18 +453,21 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
     }
   inport = atoi (portstr);
 #else /* !HAVE_DECL_GETNAMEINFO */
-  strncpy (addrstr, inet_ntoa (fromp->sin_addr), sizeof (addrstr));
-  inport = ntohs (fromp->sin_port);
+  strncpy (addrstr, inet_ntoa (((struct sockaddr_in *) fromp)->sin_addr),
+	   sizeof (addrstr));
+  inport = ntohs (((struct sockaddr_in *) fromp)->sin_port);
   snprintf (portstr, sizeof (portstr), "%u", inport);
 #endif
 
   /* Verify that the client's address is an Internet adress. */
-  if (fromp->sin_family != AF_INET)
+#if defined KERBEROS || defined SHISHI
+  if (fromp->sa_family != AF_INET)
     {
       syslog (LOG_ERR, "malformed originating address (af %d)\n",
-	      fromp->sin_family);
+	      fromp->sa_family);
       exit (EXIT_FAILURE);
     }
+#endif
 #ifdef IP_OPTIONS
   {
     unsigned char optbuf[BUFSIZ / 3], *cp;
@@ -575,7 +582,7 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
        */
       int lport = IPPORT_RESERVED - 1;
 #ifdef WITH_RRESVPORT_AF
-      s = rresvport_af (&lport, fromp->sin_family);
+      s = rresvport_af (&lport, fromp->sa_family);
 #else
       s = rresvport (&lport);
 #endif
@@ -597,8 +604,16 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
        * client; just change the port# to the one specified
        * as secondary port by the client.
        */
-      fromp->sin_port = htons (port);
-      if (connect (s, (struct sockaddr *) fromp, fromlen) < 0)
+      switch (fromp->sa_family)
+	{
+	case AF_INET6:
+	  ((struct sockaddr_in6 *) fromp)->sin6_port = htons (port);
+	  break;
+	case AF_INET:
+	default:
+	  ((struct sockaddr_in *) fromp)->sin_port = htons (port);
+	}
+      if (connect (s, fromp, fromlen) < 0)
 	{
 	  syslog (LOG_INFO, "connect second port %d: %m", port);
 	  exit (EXIT_FAILURE);
@@ -626,8 +641,8 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
    */
   errorstr = NULL;
 #ifdef HAVE_DECL_GETNAMEINFO
-  rc = getnameinfo ((struct sockaddr *) fromp, fromlen,
-		    addrname, sizeof (addrname), NULL, 0, 0);
+  rc = getnameinfo (fromp, fromlen, addrname, sizeof (addrname),
+		    NULL, 0, NI_NAMEREQD);
   if (rc == 0)
     {
       hostname = addrname;
@@ -640,7 +655,7 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 
 	    errorhost = addrname;
 	    memset (&hints, 0, sizeof (hints));
-	    hints.ai_family = fromp->sin_family;
+	    hints.ai_family = fromp->sa_family;
 	    hints.ai_socktype = SOCK_STREAM;
 
 	    rc = getaddrinfo (hostname, NULL, &hints, &res);
@@ -680,8 +695,17 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 	  }
     }
 #else /* !HAVE_DECL_GETNAMEINFO */
-  hp = gethostbyaddr ((char *) &fromp->sin_addr, sizeof (struct in_addr),
-		      fromp->sin_family);
+  switch (fromp->sa_family)
+    {
+    case AF_INET6:
+      hp = gethostbyaddr ((void *) &((struct sockaddr_in6 *) fromp)->sin6_addr,
+			  sizeof (struct in6_addr), fromp->sa_family);
+      break;
+    case AF_INET:
+    default:
+      hp = gethostbyaddr ((void *) &((struct sockaddr_in *) fromp)->sin_addr,
+			  sizeof (struct in_addr), fromp->sa_family);
+    }
   if (hp)
     {
       /*
@@ -725,8 +749,10 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
 			  break;
 			}
 		      if (!memcmp (hp->h_addr_list[0],
-				   (caddr_t) & fromp->sin_addr,
-				   sizeof fromp->sin_addr))
+				   (fromp->sa_family == AF_INET6)
+				   ? (void *) & ((struct sockaddr_in6 *) fromp)->sin6_addr
+				   : (void *) & ((struct sockaddr_in *) fromp)->sin_addr,
+				   hp->h_length))
 			{
 			  hostname = strdup (hp->h_name);
 			  break;	/* equal, OK */
@@ -881,6 +907,7 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
     /* verify checksum */
 
     /* Doesn't give socket port ?
+       socklen = sizeof (sock);
        if (getsockname (STDIN_FILENO, (struct sockaddr *)&sock, &socklen) < 0)
        {
        syslog (LOG_ERR, "Can't get sock name");
@@ -1051,17 +1078,26 @@ doit (int sockfd, struct sockaddr_in *fromp, socklen_t fromlen)
                      && (iruserok_sa ((void *) fromp, fromlen,
 				      pwd->pw_uid == 0, remuser, locuser)) < 0))
 # elif defined WITH_IRUSEROK_AF
+    switch (fromp->sa_family)
+      {
+      case AF_INET6:
+	fromaddrp = (void *) &((struct sockaddr_in6 *) fromp)->sin6_addr;
+	break;
+      case AF_INET:
+      default:
+	fromaddrp = (void *) &((struct sockaddr_in *) fromp)->sin_addr;
+      }
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
-                     && (iruserok_af (&fromp->sin_addr, pwd->pw_uid == 0,
-                                   remuser, locuser, fromp->sin_family)) < 0))
+                     && (iruserok_af (fromaddrp, pwd->pw_uid == 0,
+				      remuser, locuser, fromp->sa_family)) < 0))
 # elif defined WITH_IRUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
-                     && (iruserok (fromp->sin_addr.s_addr, pwd->pw_uid == 0,
-                                   remuser, locuser)) < 0))
+                     && (iruserok (((struct sockaddr_in *) fromp)->sin_addr.s_addr,
+				   pwd->pw_uid == 0, remuser, locuser)) < 0))
 # elif defined WITH_RUSEROK_AF
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (ruserok_af (addrstr, pwd->pw_uid == 0,
-				  remuser, locuser, fromp->sin_family)) < 0))
+				  remuser, locuser, fromp->sa_family)) < 0))
 # elif defined WITH_RUSEROK
     if (errorstr || (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0'
                      && (ruserok (addrstr, pwd->pw_uid == 0,

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

Summary of changes:
 ChangeLog                 |   75 ++++++++++++++++++++++++++++++++++
 libinetutils/shishi_def.h |    2 +
 src/rcp.c                 |   45 ++++++++++++++------
 src/rlogin.c              |   34 ++++++++++++++-
 src/rlogind.c             |   99 +++++++++++++++++++++++++++++++++++++--------
 src/rsh.c                 |   23 +++++++++--
 src/rshd.c                |   86 +++++++++++++++++++++++++++-----------
 7 files changed, 303 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


