From MAILER-DAEMON Sat Mar 02 12:11:03 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UBpxe-0001Q9-Vj
	for mharc-commit-inetutils@gnu.org; Sat, 02 Mar 2013 12:11:02 -0500
Received: from eggs.gnu.org ([208.118.235.92]:50848)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UBpxc-0001NE-Mv
	for commit-inetutils@gnu.org; Sat, 02 Mar 2013 12:11:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UBpxb-0007Uf-Az
	for commit-inetutils@gnu.org; Sat, 02 Mar 2013 12:11:00 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39430)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UBpxb-0007UW-7L
	for commit-inetutils@gnu.org; Sat, 02 Mar 2013 12:10:59 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UBpxa-0003g7-AM
	for commit-inetutils@gnu.org; Sat, 02 Mar 2013 17:10:58 +0000
Date: Sat, 02 Mar 2013 17:10:58 +0000
Message-Id: <E1UBpxa-0003g7-AM@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-248-g4d922c0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a39da05e1a2eea026deda149d3be4d25d72dffee
X-Git-Newrev: 4d922c02defe791d49cf57209c9b61fd1803fd0a
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 02 Mar 2013 17:11:01 -0000

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

The branch, master has been updated
       via  4d922c02defe791d49cf57209c9b61fd1803fd0a (commit)
      from  a39da05e1a2eea026deda149d3be4d25d72dffee (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=4d922c02defe791d49cf57209c9b61fd1803fd0a


commit 4d922c02defe791d49cf57209c9b61fd1803fd0a
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Mar 2 17:43:34 2013 +0100

    Refine transfer sub-test for FTP.

diff --git a/ChangeLog b/ChangeLog
index dd2bca8..effd207 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-03-02  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Make the FTP transfer test somewhat robuster.
+
+	* tests/ftp-localhost.sh <set-up of DLDIR>:
+	Reset do_transfer as `false' before probing.
+	Add `/tmp' as a candidate subdirectory.
+	Set do_transfer to `true' only with a confirmed
+	writable directory.  Exit with status 99, should
+	TRANSFERTEST be set, but directory search fails.
+
 2013-02-24  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	syslogd: Log selectively on program name.
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index de13851..8c55283 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -155,20 +155,38 @@ fi
 # was found.
 
 if test -z "$DLDIR"; then
-    for DLDIR in /pub /download /downloads /dl / ; do
+    # We depend on detection of a usable subdirectory,
+    # so reactivate this sub-test only with DLDIR known
+    # to be functional.
+
+    do_transfer=false
+
+    for DLDIR in /pub /download /downloads /dl /tmp / ; do
 	test -d $FTPHOME$DLDIR || continue
 	set -- `ls -ld $FTPHOME$DLDIR`
 	# Check owner.
 	test "$3" = $FTPUSER || continue
 	# Check for write access.
-	test `expr $1 : 'drwx'` -eq 4 && break
+	test `expr $1 : 'drwx'` -eq 4 && do_transfer=true && break
 	DLDIR=	# Reset failed value
     done
 
-    test -z "$DLDIR" && do_transfer=false
     test x"$DLDIR" = x"/" && DLDIR=
 fi
 
+# Exit with a hard error, should transfer test be requested,
+# but a suitable subdirectory be missing.
+
+if test "${TRANSFERTEST+yes}" = "yes" && \
+    test $do_transfer = false
+then
+    cat >&2 <<-END
+	There is no writable subdirectory for transfer test.
+	Aborting FTP test completely.
+	END
+    exit 99
+fi
+
 # Note that inetd changes directory to / when --debug is not given so
 # all paths must be absolute for things to work.
 

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

Summary of changes:
 ChangeLog              |   11 +++++++++++
 tests/ftp-localhost.sh |   24 +++++++++++++++++++++---
 2 files changed, 32 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 08 10:21:09 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UDz6b-00070a-FW
	for mharc-commit-inetutils@gnu.org; Fri, 08 Mar 2013 10:21:09 -0500
Received: from eggs.gnu.org ([208.118.235.92]:54414)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UDz6T-000708-Dj
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 10:21:07 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UDz6M-0000M7-TX
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 10:21:01 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46878)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UDz6M-0000M2-Oa
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 10:20:54 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UDz6M-0001wl-BI
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 15:20:54 +0000
Date: Fri, 08 Mar 2013 15:20:54 +0000
Message-Id: <E1UDz6M-0001wl-BI@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-249-g2910ff7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4d922c02defe791d49cf57209c9b61fd1803fd0a
X-Git-Newrev: 2910ff783ad0d308e302da2d8cca5e4695c5dbd0
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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, 08 Mar 2013 15:21:07 -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  2910ff783ad0d308e302da2d8cca5e4695c5dbd0 (commit)
      from  4d922c02defe791d49cf57209c9b61fd1803fd0a (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=2910ff783ad0d308e302da2d8cca5e4695c5dbd0


commit 2910ff783ad0d308e302da2d8cca5e4695c5dbd0
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 7 22:16:39 2013 +0100

    Relax setuid demands.
    
    All former setuid executables are now
    content with system capabilities.

diff --git a/ChangeLog b/ChangeLog
index effd207..b7c0cca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2013-03-07  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Relax setuid demands.
+
+	* src/rcp.c (effuid): New variable.
+	(main): Set `effuid' by calling geteuid().
+	Remove test on non-zero geteuid().
+	(toremote): If `rem < 0' and `errno == EACCES',
+	then report failure to access privileged port.
+	(tolocal): Use argument `effuid' for seteuid().
+	* src/rlogin.c (main): Remove test on non-zero
+	geteuid().  If `rem < 0' and `errno == EACCES',
+	then report failure to access privileged port.
+	* src/rsh.c (main): Likewise.
+
+	* ping/libping.c (ping_init): Let error message
+	mention privileges, instead of non-root access.
+
+	Avoid assignment inside if-clauses, as per GCS.
+
+	* src/rcp.c (main, tolocal, source, rsource, sink)
+	(allocbuf): Assign to variables first, then test
+	their values in an if-clause.
+	* src/rlogin.c (main, get_window_size, getescape):
+	Likewise.
+	* src/rlogind.c (rlogind_auth, do_krb5_login)
+	(protocol): Likewise.
+	* src/rsh.c (main, talk, copyargs): Likewise.
+	* src/rshd.c (doit): Likewise.
+
 2013-03-02  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Make the FTP transfer test somewhat robuster.
diff --git a/README b/README
index 91cf5ac..760b18b 100644
--- a/README
+++ b/README
@@ -5,7 +5,7 @@ clients and servers of the GNU Operating System.
 
 The individual utilities were originally derived from the 4.4BSDLite2
 distribution.  Many features were integrated from NetBSD, OpenBSD,
-FreeBSD and GNU/Linux
+FreeBSD and GNU/Linux.
 
 The file `paths' contains a list of all paths used by programs in this
 distribution, and rules to find values for them.  To change a path
@@ -32,19 +32,28 @@ address.
 
 Notes:
 
-1) All of the r* commands clients, rcp, rlogin, rsh, need to be
-   install setuid root to work correctly because they use privileged
-   ports for communication.
+1) All of the r* client commands, 'rcp', 'rlogin', 'rsh', used to
+   need to be installed as setuid root to work correctly, since
+   they use privileged ports for communication.  However, some
+   modern operating systems now offer capabilities that avoid
+   the need for setuid settings, and this is accounted for in
+   our present code.  CAP_NET_BIND_SERVICE and PRIV_NET_PRIVADDR
+   are relevant for the above three programs.
+
+2) Similarly, 'ping', 'ping6', and 'traceroute', used to depend
+   on setuid installation, but also these are now content with
+   capabilities like CAP_NET_RAW, PRIV_NET_ICMPACCESS, and
+   PRIV_NET_RAWACCESS.
 
 Some known deficiencies:
 
  - Non-Shishi Kerberos support does not build.  Patches welcome.
 
- - Shishi Kerberos support is only implemented for 'rlogin',
+ - Shishi Kerberos support is only implemented for 'rcp', 'rlogin',
    'rlogind', 'rsh', 'rshd', 'telnet', and 'telnetd'.
 
  - Not all utilities are Kerberized even when built with Kerberos
-   libraries, including 'rcp'.
+   libraries, including 'rcp' for non-Shishi Kerberos.
 
  - InetUtils does not build on HP-UX 11.00, Cygwin, Minix, MinGW,
    MSCV, BeOS, Haiki (and probably other systems as well).  Patches
diff --git a/ping/libping.c b/ping/libping.c
index cd6c016..4339458 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -72,7 +72,7 @@ ping_init (int type, int ident)
   if (fd < 0)
     {
       if (errno == EPERM || errno == EACCES)
-	fprintf (stderr, "ping: ping must run as root\n");
+	fprintf (stderr, "ping: Lacking privilege for raw socket.\n");
       return NULL;
     }
 
diff --git a/src/rcp.c b/src/rcp.c
index 7bbe9ff..832dd45 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -273,7 +273,7 @@ static struct argp argp = {
 
 struct passwd *pwd;
 unsigned short port;
-uid_t userid;
+uid_t userid, effuid;
 int errs, rem;
 
 char *command;
@@ -314,7 +314,9 @@ main (int argc, char *argv[])
 # else /* SHISHI */
       shell = "kshell";		/* Libshishi uses a single service.  */
 # endif
-      if ((sp = getservbyname (shell, "tcp")) == NULL)
+
+      sp = getservbyname (shell, "tcp");
+      if (sp == NULL)
 	{
 	  use_kerberos = 0;
 	  oldw ("can't get entry for %s/tcp service", shell);
@@ -330,7 +332,10 @@ main (int argc, char *argv[])
     error (EXIT_FAILURE, 0, "%s/tcp: unknown service", shell);
   port = sp->s_port;
 
-  if ((pwd = getpwuid (userid = getuid ())) == NULL)
+  effuid = geteuid ();
+  userid = getuid ();
+  pwd = getpwuid (userid);
+  if (pwd == NULL)
     error (EXIT_FAILURE, 0, "unknown user %d", (int) userid);
 
   rem = STDIN_FILENO;		/* XXX */
@@ -361,14 +366,6 @@ main (int argc, char *argv[])
     error (EXIT_FAILURE, 0, "encryption must use Kerberos");
 #endif
 
-#if defined KERBEROS || defined SHISHI
-  if (!use_kerberos && geteuid ())
-#else
-  /* We must be setuid root.  */
-  if (geteuid ())
-#endif
-    error (EXIT_FAILURE, 0, "must be setuid root.");
-
   /* Command to be executed on remote system using "rsh". */
 #if defined KERBEROS || defined SHISHI
   rc = asprintf (&command, "rcp%s%s%s%s", iamrecursive ? " -r" : "",
@@ -515,7 +512,17 @@ toremote (char *targ, int argc, char *argv[])
 			    tuser ? tuser : pwd->pw_name, bp, 0);
 #endif
 	      if (rem < 0)
-		exit (EXIT_FAILURE);
+		{
+		  /* rcmd() provides its own error messages,
+		   * but we add a vital addition, caused by
+		   * insufficient capabilites.
+		   */
+		  if (errno == EACCES)
+		    error (EXIT_FAILURE, 0,
+			   "No access to privileged ports.");
+
+		  exit (EXIT_FAILURE);
+		}
 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
 	      sslen = sizeof (ss);
 	      (void) getpeername (rem, (struct sockaddr *) &ss, &sslen);
@@ -567,7 +574,8 @@ tolocal (int argc, char *argv[])
 
   for (i = 0; i < argc - 1; i++)
     {
-      if (!(src = colon (argv[i])))
+      src = colon (argv[i]);
+      if (!src)
 	{			/* Local to local. */
 	  len = strlen (PATH_CP) + strlen (argv[i]) +
 	    strlen (argv[argc - 1]) + 20;
@@ -585,7 +593,9 @@ tolocal (int argc, char *argv[])
       *src++ = 0;
       if (*src == 0)
 	src = ".";
-      if ((host = strchr (argv[i], '@')) == NULL)
+
+      host = strchr (argv[i], '@');
+      if (host == NULL)
 	{
 	  host = argv[i];
 	  suser = pwd->pw_name;
@@ -633,7 +643,7 @@ tolocal (int argc, char *argv[])
 	  error (0, errno, "TOS (ignored)");
 #endif
       sink (1, argv + argc - 1);
-      seteuid (0);
+      seteuid (effuid);
       close (rem);
       rem = -1;
 #ifdef SHISHI
@@ -695,7 +705,8 @@ source (int argc, char *argv[])
   for (indx = 0; indx < argc; ++indx)
     {
       name = argv[indx];
-      if ((fd = open (name, O_RDONLY, 0)) < 0)
+      fd = open (name, O_RDONLY, 0);
+      if (fd < 0)
 	goto syserr;
       if (fstat (fd, &stb))
 	{
@@ -718,7 +729,8 @@ source (int argc, char *argv[])
 	  run_err ("%s: not a regular file", name);
 	  goto next;
 	}
-      if ((last = strrchr (name, '/')) == NULL)
+      last = strrchr (name, '/');
+      if (last == NULL)
 	last = name;
       else
 	++last;
@@ -737,7 +749,9 @@ source (int argc, char *argv[])
       write (rem, buf, strlen (buf));
       if (response () < 0)
 	goto next;
-      if ((bp = allocbuf (&buffer, fd, BUFSIZ)) == NULL)
+
+      bp = allocbuf (&buffer, fd, BUFSIZ);
+      if (bp == NULL)
 	{
 	next:
 	  close (fd);
@@ -784,7 +798,8 @@ rsource (char *name, struct stat *statp)
   char *buf;
   int buf_len;
 
-  if (!(dirp = opendir (name)))
+  dirp = opendir (name);
+  if (!dirp)
     {
       run_err ("%s: %s", name, strerror (errno));
       return;
@@ -1039,14 +1054,16 @@ sink (int argc, char *argv[])
 	}
       omode = mode;
       mode |= S_IWRITE;
-      if ((ofd = open (np, O_WRONLY | O_CREAT, mode)) < 0)
+      ofd = open (np, O_WRONLY | O_CREAT, mode);
+      if (ofd < 0)
 	{
 	bad:
 	  run_err ("%s: %s", np, strerror (errno));
 	  continue;
 	}
       write (rem, "", 1);
-      if ((bp = allocbuf (&buffer, ofd, BUFSIZ)) == NULL)
+      bp = allocbuf (&buffer, ofd, BUFSIZ);
+      if (bp == NULL)
 	{
 	  close (ofd);
 	  continue;
@@ -1467,7 +1484,9 @@ allocbuf (BUF * bp, int fd, int blksize)
     size = blksize;
   if ((size_t) bp->cnt >= size)
     return (bp);
-  if ((bp->buf = realloc (bp->buf, size)) == NULL)
+
+  bp->buf = realloc (bp->buf, size);
+  if (bp->buf == NULL)
     {
       bp->cnt = 0;
       run_err ("%s", strerror (errno));
diff --git a/src/rlogin.c b/src/rlogin.c
index 97d94a5..b80aa90 100644
--- a/src/rlogin.c
+++ b/src/rlogin.c
@@ -365,16 +365,10 @@ main (int argc, char *argv[])
 
   argc -= index;
 
-#if defined KERBEROS || defined SHISHI
-  if (!use_kerberos && geteuid ())
-#else
-  /* We must be uid root to access rcmd().  */
-  if (geteuid ())
-#endif
-    error (EXIT_FAILURE, 0, "must be setuid root.");
-
   /* Get the name of the user invoking us: the client-user-name.  */
-  if (!(pw = getpwuid (uid = getuid ())))
+  uid = getuid ();
+  pw = getpwuid (uid);
+  if (!pw)
     error (EXIT_FAILURE, 0, "unknown user id.");
 
   /* Accept user1@host format, though "-l user2" overrides user1 */
@@ -619,6 +613,13 @@ try_connect:
   if (rem < 0)
     {
       puts ("");	/* Glibc does not close all error strings in rcmd().  */
+      /* rcmd() provides its own error messages,
+       * but we add a vital addition, caused by
+       * insufficient capabilites.
+       */
+      if (errno == EACCES)
+	error (EXIT_FAILURE, 0, "No access to privileged ports.");
+
       exit (EXIT_FAILURE);
     }
 
@@ -1430,8 +1431,10 @@ get_window_size (int fd, struct winsize *wp)
   struct ttysize ts;
   int error;
 
-  if ((error = ioctl (0, TIOCGSIZE, &ts)) != 0)
+  error = ioctl (0, TIOCGSIZE, &ts);
+  if (error != 0)
     return error;
+
   wp->ws_row = ts.ts_lines;
   wp->ws_col = ts.ts_cols;
   wp->ws_xpixel = 0;
@@ -1446,8 +1449,10 @@ getescape (register char *p)
   long val;
   int len;
 
-  if ((len = strlen (p)) == 1)	/* use any single char, including '\'.  */
+  len = strlen (p);
+  if (len == 1)		/* use any single char, including '\'.  */
     return ((u_int) * p);
+
   /* otherwise, \nnn */
   if (*p == '\\' && len >= 2 && len <= 4)
     {
diff --git a/src/rlogind.c b/src/rlogind.c
index 04a1721..dd759b3 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -928,7 +928,8 @@ rlogind_auth (int fd, struct auth_data *ap)
 	int ipproto;
 	struct protoent *ip;
 
-	if ((ip = getprotobyname ("ip")) != NULL)
+	ip = getprotobyname ("ip");
+	if (ip != NULL)
 	  ipproto = ip->p_proto;
 	else
 	  ipproto = IPPROTO_IP;
@@ -1377,7 +1378,8 @@ do_krb5_login (int infd, struct auth_data *ap, const char **err_msg)
   struct passwd *pwd;
   char *name;
 
-  if (status = krb5_init_context (&ap->context))
+  status = krb5_init_context (&ap->context);
+  if (status)
     {
       syslog (LOG_ERR, "Error initializing krb5: %s",
 	      error_message (status));
@@ -1422,8 +1424,9 @@ do_krb5_login (int infd, struct auth_data *ap, const char **err_msg)
   if (status)
     return status;
 
-  if ((status = krb5_auth_con_getauthenticator (ap->context, auth_ctx,
-						&authenticator)))
+  status = krb5_auth_con_getauthenticator (ap->context, auth_ctx,
+					   &authenticator);
+  if (status)
     return status;
 
   getstr (infd, &ap->lusername, NULL);
@@ -1439,8 +1442,9 @@ do_krb5_login (int infd, struct auth_data *ap, const char **err_msg)
 
   getstr (infd, &ap->rusername, NULL);
 
-  if ((status = krb5_copy_principal (ap->context,
-				     ticket->enc_part2->client, &ap->client)))
+  status = krb5_copy_principal (ap->context, ticket->enc_part2->client,
+				&ap->client);
+  if (status)
     return status;
 
   /*OK:: */
@@ -1759,7 +1763,8 @@ protocol (int f, int p, struct auth_data *ap)
 
       FD_SET (p, &ebits);
 
-      if ((n = select (nfd, &ibits, omask, &ebits, 0)) < 0)
+      n = select (nfd, &ibits, omask, &ebits, 0);
+      if (n < 0)
 	{
 	  if (errno == EINTR)
 	    continue;
diff --git a/src/rsh.c b/src/rsh.c
index 1621fa2..94827c6 100644
--- a/src/rsh.c
+++ b/src/rsh.c
@@ -289,15 +289,9 @@ main (int argc, char **argv)
   argc -= index;
   argv += index;
 
-#if defined KERBEROS || defined SHISHI
-  if (!use_kerberos && geteuid ())
-#else
-  /* We must be setuid root.  */
-  if (geteuid ())
-#endif
-    error (EXIT_FAILURE, 0, "must be setuid root.");
-
-  if (!(pw = getpwuid (uid = getuid ())))
+  uid = getuid ();
+  pw = getpwuid (uid);
+  if (!pw)
     error (EXIT_FAILURE, 0, "unknown user id");
 
   /* Accept user1@host format, though "-l user2" overrides user1 */
@@ -512,7 +506,16 @@ try_connect:
 #endif /* !KERBEROS && !SHISHI */
 
   if (rem < 0)
-    exit (EXIT_FAILURE);
+    {
+      /* rcmd() provides its own error messages,
+       * but we add a vital addition, caused by
+       * insufficient capabilites.
+       */
+      if (errno == EACCES)
+	error (EXIT_FAILURE, 0, "No access to privileged ports.");
+
+      exit (EXIT_FAILURE);
+    }
 
   if (rfd2 < 0)
     error (EXIT_FAILURE, 0, "can't establish stderr");
@@ -605,7 +608,8 @@ talk (int null_input_option, sigset_t * osigs, pid_t pid, int rem)
 
     reread:
       errno = 0;
-      if ((cc = read (STDIN_FILENO, buf, sizeof buf)) <= 0)
+      cc = read (STDIN_FILENO, buf, sizeof buf);
+      if (cc <= 0)
 	goto done;
       bp = buf;
 
@@ -766,7 +770,8 @@ copyargs (char **argv)
   cc = 0;
   for (ap = argv; *ap; ++ap)
     cc += strlen (*ap) + 1;
-  if (!(args = malloc ((u_int) cc)))
+  args = malloc ((u_int) cc);
+  if (!args)
     error (EXIT_FAILURE, errno, "copyargs");
   for (p = args, ap = argv; *ap; ++ap)
     {
diff --git a/src/rshd.c b/src/rshd.c
index 4ba6c09..2684d03 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -501,7 +501,8 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
     int ipproto;
     struct protoent *ip;
 
-    if ((ip = getprotobyname ("ip")) != NULL)
+    ip = getprotobyname ("ip");
+    if (ip != NULL)
       ipproto = ip->p_proto;
     else
       ipproto = IPPROTO_IP;
@@ -581,7 +582,9 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
   for (;;)
     {
       char c;
-      if ((cc = read (sockfd, &c, 1)) != 1)
+
+      cc = read (sockfd, &c, 1);
+      if (cc != 1)
 	{
 	  if (cc < 0)
 	    syslog (LOG_NOTICE, "read: %m");

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

Summary of changes:
 ChangeLog      |   30 ++++++++++++++++++++++++++
 README         |   21 +++++++++++++-----
 ping/libping.c |    2 +-
 src/rcp.c      |   63 ++++++++++++++++++++++++++++++++++++-------------------
 src/rlogin.c   |   27 ++++++++++++++---------
 src/rlogind.c  |   19 ++++++++++------
 src/rsh.c      |   29 +++++++++++++++----------
 src/rshd.c     |    7 ++++-
 8 files changed, 137 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 08 13:37:49 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UE2Av-0004gQ-Aw
	for mharc-commit-inetutils@gnu.org; Fri, 08 Mar 2013 13:37:49 -0500
Received: from eggs.gnu.org ([208.118.235.92]:56502)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE2An-0004gB-WF
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 13:37:48 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE2Ai-00013d-B7
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 13:37:41 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53250)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE2Ai-00013Z-7h
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 13:37:36 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UE2Ah-0003HK-CZ
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 18:37:35 +0000
Date: Fri, 08 Mar 2013 18:37:35 +0000
Message-Id: <E1UE2Ah-0003HK-CZ@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-250-g4a5da0c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2910ff783ad0d308e302da2d8cca5e4695c5dbd0
X-Git-Newrev: 4a5da0cab332f9ba3e7df5ef5d34916a465edbec
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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, 08 Mar 2013 18:37:48 -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  4a5da0cab332f9ba3e7df5ef5d34916a465edbec (commit)
      from  2910ff783ad0d308e302da2d8cca5e4695c5dbd0 (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=4a5da0cab332f9ba3e7df5ef5d34916a465edbec


commit 4a5da0cab332f9ba3e7df5ef5d34916a465edbec
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Mar 8 19:06:26 2013 +0100

    bootstrap: Updated from gnulib

diff --git a/ChangeLog b/ChangeLog
index b7c0cca..ddaf0f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-03-08  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* bootstrap: Updated from gnulib.
+
 2013-03-07  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Relax setuid demands.
diff --git a/bootstrap b/bootstrap
index e3e270b..96f1e76 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2012-07-19.14; # UTC
+scriptversion=2013-03-08.16; # UTC
 
 # Bootstrap this package from checked-out sources.
 
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -306,34 +306,34 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
   die "Bootstrapping from a non-checked-out distribution is risky."
 fi
 
-# Ensure that lines starting with ! sort last, per gitignore conventions
-# for whitelisting exceptions after a more generic blacklist pattern.
-sort_patterns() {
-  sort -u "$@" | sed '/^!/ {
-    H
-    d
-  }
-  $ {
-    P
-    x
-    s/^\n//
-  }' | sed '/^$/d'
+# Strip blank and comment lines to leave significant entries.
+gitignore_entries() {
+  sed '/^#/d; /^$/d' "$@"
 }
 
-# If $STR is not already on a line by itself in $FILE, insert it,
-# sorting the new contents of the file and replacing $FILE with the result.
-insert_sorted_if_absent() {
+# If $STR is not already on a line by itself in $FILE, insert it at the start.
+# Entries are inserted at the start of the ignore list to ensure existing
+# entries starting with ! are not overridden.  Such entries support
+# whitelisting exceptions after a more generic blacklist pattern.
+insert_if_absent() {
   file=$1
   str=$2
   test -f $file || touch $file
-  echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \
-    || { echo "$str" | sort_patterns - $file > $file.bak \
-      && mv $file.bak $file; } \
-    || die "insert_sorted_if_absent $file $str: failed"
+  test -r $file || die "Error: failed to read ignore file: $file"
+  duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
+  if [ "$duplicate_entries" ] ; then
+    die "Error: Duplicate entries in $file: " $duplicate_entries
+  fi
+  linesold=$(gitignore_entries $file | wc -l)
+  linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l)
+  if [ $linesold != $linesnew ] ; then
+    { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
+      || die "insert_if_absent $file $str: failed"
+  fi
 }
 
 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
-# insert_sorted_if_absent.
+# insert_if_absent.
 insert_vc_ignore() {
   vc_ignore_file="$1"
   pattern="$2"
@@ -344,7 +344,7 @@ insert_vc_ignore() {
     # .gitignore entry.
     pattern=$(echo "$pattern" | sed s,^,/,);;
   esac
-  insert_sorted_if_absent "$vc_ignore_file" "$pattern"
+  insert_if_absent "$vc_ignore_file" "$pattern"
 }
 
 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
@@ -630,9 +630,13 @@ esac
 if $bootstrap_sync; then
   cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
     echo "$0: updating bootstrap and restarting..."
+    case $(sh -c 'echo "$1"' -- a) in
+      a) ignored=--;;
+      *) ignored=ignored;;
+    esac
     exec sh -c \
       'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
-      -- "$GNULIB_SRCDIR/build-aux/bootstrap" \
+      $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
       "$0" "$@" --no-bootstrap-sync
   }
 fi
@@ -889,20 +893,21 @@ find "$m4_base" "$source_base" \
   -depth \( -name '*.m4' -o -name '*.[ch]' \) \
   -type l -xtype l -delete > /dev/null 2>&1
 
+# Invoke autoreconf with --force --install to ensure upgrades of tools
+# such as ylwrap.
+AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
+
 # Some systems (RHEL 5) are using ancient autotools, for which the
 # --no-recursive option had not been invented.  Detect that lack and
 # omit the option when it's not supported.  FIXME in 2017: remove this
 # hack when RHEL 5 autotools are updated, or when they become irrelevant.
-no_recursive=
 case $($AUTORECONF --help) in
-  *--no-recursive*) no_recursive=--no-recursive;;
+  *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
 esac
 
 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
-echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
-    "$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS"
-AUTOPOINT=true LIBTOOLIZE=true \
-    $AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \
+echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
+AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
   || die "autoreconf failed"
 
 # Get some extra files from gnulib, overriding existing files.

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

Summary of changes:
 ChangeLog |    4 +++
 bootstrap |   65 ++++++++++++++++++++++++++++++++----------------------------
 2 files changed, 39 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 08 19:19:12 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UE7VI-0003Nc-9Y
	for mharc-commit-inetutils@gnu.org; Fri, 08 Mar 2013 19:19:12 -0500
Received: from eggs.gnu.org ([208.118.235.92]:41769)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE7VC-0003HY-AR
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 19:19:11 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE7V5-0004CK-MY
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 19:19:06 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48378)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UE7V5-0004CF-Jn
	for commit-inetutils@gnu.org; Fri, 08 Mar 2013 19:18:59 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UE7V5-0003i7-0Z
	for commit-inetutils@gnu.org; Sat, 09 Mar 2013 00:18:59 +0000
Date: Sat, 09 Mar 2013 00:18:59 +0000
Message-Id: <E1UE7V5-0003i7-0Z@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-251-gbaf8f5d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4a5da0cab332f9ba3e7df5ef5d34916a465edbec
X-Git-Newrev: baf8f5de12986c0d943ce012ea0b7e9e6d4c1940
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 09 Mar 2013 00:19:11 -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  baf8f5de12986c0d943ce012ea0b7e9e6d4c1940 (commit)
      from  4a5da0cab332f9ba3e7df5ef5d34916a465edbec (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=baf8f5de12986c0d943ce012ea0b7e9e6d4c1940


commit baf8f5de12986c0d943ce012ea0b7e9e6d4c1940
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Mar 9 00:20:08 2013 +0100

    rcp: Portability fixes.

diff --git a/ChangeLog b/ChangeLog
index ddaf0f7..cab6285 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-03-09  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rcp: Portability fixes.
+
+	* src/rcp.c: Include <stdint.h>.
+	(options): Make argument to `-d' optional, since
+	the remote server need that form of invocation.
+	(source): Use format "%jd" and cast as intmax_t
+	to work around buggy library modes, which otherwise
+	are missing the last string argument.
+
 2013-03-08  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	* bootstrap: Updated from gnulib.
diff --git a/src/rcp.c b/src/rcp.c
index 832dd45..37fb8e6 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -75,6 +75,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <stdint.h>		/* intmax_t */
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
@@ -162,7 +163,7 @@ static struct argp_option options[] = {
     "attempt to preserve (duplicate) in its copies the"
     " modification times and modes of the source files",
     GRID+1 },
-  { "target-directory", 'd', "DIRECTORY", 0,
+  { "target-directory", 'd', "DIRECTORY", OPTION_ARG_OPTIONAL,
     "copy all SOURCE arguments into DIRECTORY",
     GRID+1 },
   { "from", 'f', NULL, 0,
@@ -741,11 +742,8 @@ source (int argc, char *argv[])
 	    goto next;
 	}
 #define RCP_MODEMASK	(S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
-      snprintf (buf, sizeof buf,
-		(sizeof (stb.st_size) > sizeof (long)
-		 ? "C%04o %zd %s\n"
-		 : "C%04o %ld %s\n"),
-		stb.st_mode & RCP_MODEMASK, stb.st_size, last);
+      snprintf (buf, sizeof buf, "C%04o %jd %s\n",
+		stb.st_mode & RCP_MODEMASK, (intmax_t) stb.st_size, last);
       write (rem, buf, strlen (buf));
       if (response () < 0)
 	goto next;

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

Summary of changes:
 ChangeLog |   11 +++++++++++
 src/rcp.c |   10 ++++------
 2 files changed, 15 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed Mar 13 10:50:56 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UFn16-0003zr-C3
	for mharc-commit-inetutils@gnu.org; Wed, 13 Mar 2013 10:50:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33994)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFn0y-0003yN-8c
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 10:50:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFn0t-00089P-25
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 10:50:48 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38140)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFn0s-00089J-SM
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 10:50:42 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UFn0s-00007I-06
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 14:50:42 +0000
Date: Wed, 13 Mar 2013 14:50:42 +0000
Message-Id: <E1UFn0s-00007I-06@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-252-gca8585c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: baf8f5de12986c0d943ce012ea0b7e9e6d4c1940
X-Git-Newrev: ca8585c47b89e199b359e867854802faab5b4c74
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 13 Mar 2013 14:50:54 -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  ca8585c47b89e199b359e867854802faab5b4c74 (commit)
      from  baf8f5de12986c0d943ce012ea0b7e9e6d4c1940 (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=ca8585c47b89e199b359e867854802faab5b4c74


commit ca8585c47b89e199b359e867854802faab5b4c74
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Mar 11 00:43:02 2013 +0100

    rcp: Implement directory switch.

diff --git a/ChangeLog b/ChangeLog
index cab6285..6091d80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2013-03-11  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rcp: Functional option `--target-directory'.
+	Implement the missing case where `-d' is given
+	an argument.
+
+	* src/rcp.c (target): New variable.
+	(parse_opt) <'d'>: If `arg' has contents, copy it
+	to `target'.
+	(main): Only one command line argument is needed for
+	calls with set `target'.  If `target' is not set,
+	extract it from the very last command line argument,
+	and decrease `argc' to reflect this action.  Apply
+	colon() and verify() to `target'.
+	(toremote): Extract host and user name from `target'.
+	Let I loop until `argc', since `argc' no longer includes
+	the target directory.
+	(tolocal): New variable VECT.  Loop I until `argc'.
+	Exchange `target' for `argv[argc - 1]'.  Fix VECT to
+	be a short array with `target', and apply it to sink().
+
 2013-03-09  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rcp: Portability fixes.
diff --git a/src/rcp.c b/src/rcp.c
index 37fb8e6..6172804 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -145,6 +145,7 @@ const char arg_doc[] = "SOURCE DEST\n"
                        "SOURCE... DIRECTORY\n"
                        "--target-directory=DIRECTORY SOURCE...";
 
+char *target = NULL;
 int preserve_option;
 int from_option, to_option;
 int iamremote, iamrecursive, targetshouldbedirectory;
@@ -243,6 +244,8 @@ parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
       /* Server options. */
     case 'd':
       targetshouldbedirectory = 1;
+      if (arg && strlen (arg))
+	target = xstrdup (arg);	/* Client side use.  */
       break;
 
     case 'f':		/* "from" */
@@ -356,7 +359,7 @@ main (int argc, char *argv[])
       exit (errs);
     }
 
-  if (argc < 2)
+  if (argc < 1 || (argc < 2 && !(target && strlen (target))))
     error (EXIT_FAILURE, 0, "not enough arguments");
 
   if (argc > 2)
@@ -388,14 +391,23 @@ main (int argc, char *argv[])
   rem = -1;
   signal (SIGPIPE, lostconn);
 
-  targ = colon (argv[argc - 1]);
+  /* Without a specified target, the last argument
+   * is extracted to serve as target.
+   */
+  if (!target || !strlen (target))
+    {
+      target = xstrdup (argv[argc - 1]);
+      argc--;			/* Do not count target directory.  */
+    }
+
+  targ = colon (target);
   if (targ)			/* Dest is remote host. */
     toremote (targ, argc, argv);
   else
     {
       tolocal (argc, argv);	/* Dest is local host. */
       if (targetshouldbedirectory)
-	verifydir (argv[argc - 1]);
+	verifydir (target);
     }
   exit (errs);
 }
@@ -414,12 +426,12 @@ toremote (char *targ, int argc, char *argv[])
   if (*targ == 0)
     targ = ".";
 
-  thost = strchr (argv[argc - 1], '@');
+  thost = strchr (target, '@');
   if (thost)
     {
       /* user@host */
       *thost++ = 0;
-      tuser = argv[argc - 1];
+      tuser = target;
       if (*tuser == '\0')
 	tuser = NULL;
       else if (!okname (tuser))
@@ -427,11 +439,11 @@ toremote (char *targ, int argc, char *argv[])
     }
   else
     {
-      thost = argv[argc - 1];
+      thost = target;
       tuser = NULL;
     }
 
-  for (i = 0; i < argc - 1; i++)
+  for (i = 0; i < argc; i++)
     {
       src = colon (argv[i]);
       if (src)
@@ -567,24 +579,24 @@ void
 tolocal (int argc, char *argv[])
 {
   int i, len, tos;
-  char *bp, *host, *src, *suser;
+  char *bp, *host, *src, *suser, *vect[1];
 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
   struct sockaddr_storage ss;
   socklen_t sslen;
 #endif
 
-  for (i = 0; i < argc - 1; i++)
+  for (i = 0; i < argc; i++)
     {
       src = colon (argv[i]);
       if (!src)
 	{			/* Local to local. */
 	  len = strlen (PATH_CP) + strlen (argv[i]) +
-	    strlen (argv[argc - 1]) + 20;
+		strlen (target) + 20;
 	  if (asprintf (&bp, "exec %s%s%s %s %s",
 			PATH_CP,
 			iamrecursive ? " -R" : "",
 			preserve_option ? " -p" : "",
-			argv[i], argv[argc - 1]) < 0)
+			argv[i], target) < 0)
 	    xalloc_die ();
 	  if (susystem (bp, userid))
 	    ++errs;
@@ -643,7 +655,8 @@ tolocal (int argc, char *argv[])
 	if (errno != ENOPROTOOPT)
 	  error (0, errno, "TOS (ignored)");
 #endif
-      sink (1, argv + argc - 1);
+      vect[0] = target;
+      sink (1, vect);
       seteuid (effuid);
       close (rem);
       rem = -1;

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

Summary of changes:
 ChangeLog |   21 +++++++++++++++++++++
 src/rcp.c |   37 +++++++++++++++++++++++++------------
 2 files changed, 46 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed Mar 13 16:28:58 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UFsID-0000ws-Rf
	for mharc-commit-inetutils@gnu.org; Wed, 13 Mar 2013 16:28:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:43330)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFsI7-0000ol-AT
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 16:28:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFsHz-0001pK-S3
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 16:28:51 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:47856)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFsHz-0001pE-M9
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 16:28:43 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UFsHy-00021l-Os
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 20:28:43 +0000
Date: Wed, 13 Mar 2013 20:28:42 +0000
Message-Id: <E1UFsHy-00021l-Os@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-253-g3389ecc
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ca8585c47b89e199b359e867854802faab5b4c74
X-Git-Newrev: 3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 13 Mar 2013 20:28:56 -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  3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082 (commit)
      from  ca8585c47b89e199b359e867854802faab5b4c74 (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=3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082


commit 3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Wed Mar 13 19:57:18 2013 +0100

    rlogind: Initial PAM support.

diff --git a/ChangeLog b/ChangeLog
index 6091d80..8339f92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2013-03-13  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rlogind: Initial PAM support.
+	New code for plain authentication only.
+
+	* configure.ac <rlogind summary>: Report PAM.
+	* src/Makefile.am (rlogind_LDADD): Add $(LIBPAM)
+	and $(LIBDL).
+	* src/rlogind.c [HAVE_SECURITY_PAM_APPL_H]:
+	Include <security/pam_appl.h>.
+	(pam_rc, pam_handle, pam_conv) [WITH_PAM]:
+	New variables.
+	(rlogin_conv) [WITH_PAM]: New function.
+	(doc) [WITH_PAM]: Add info to string.
+	(do_rlogin) [WITH_PAM]: New variable USER.
+	New code block.
+	(fatal) [WITH_PAM]: Call pam_end().
+
+	* src/rlogind.c (rlogind_auth)
+	[!HAVE_DECL_GETADDRINFO || !HAVE_DECL_NAMEINFO]:
+	Use ADDRP only within this condition.
+
 2013-03-11  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rcp: Functional option `--target-directory'.
diff --git a/configure.ac b/configure.ac
index 176bc93..1ba889e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1037,7 +1037,7 @@ ${ftpd_BUILD:+${FTPD_LIBPAM:+PAM }$LIBWRAP}
     rexecd         ${enable_rexecd}  \
 ${rexecd_BUILD:+${LIBPAM:+PAM}}
     rlogind        ${enable_rlogind}  \
-${rlogind_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }$LIBWRAP}
+${rlogind_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }${LIBPAM:+PAM }$LIBWRAP}
     rshd           ${enable_rshd}  \
 ${rshd_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }${LIBPAM:+PAM}}
     syslogd        ${enable_syslogd}
diff --git a/src/Makefile.am b/src/Makefile.am
index 661612c..e8f6392 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -93,7 +93,7 @@ EXTRA_PROGRAMS += rexecd
 
 inetdaemon_PROGRAMS += $(rlogind_BUILD)
 rlogind_SOURCES = rlogind.c
-rlogind_LDADD = $(LDADD) $(LIBAUTH) $(LIBWRAP)
+rlogind_LDADD = $(LDADD) $(LIBAUTH) $(LIBPAM) $(LIBDL) $(LIBWRAP)
 EXTRA_PROGRAMS += rlogind
 
 inetdaemon_PROGRAMS += $(rshd_BUILD)
diff --git a/src/rlogind.c b/src/rlogind.c
index dd759b3..3922fb4 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -18,6 +18,47 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see `http://www.gnu.org/licenses/'. */
 
+/*
+ * PAM implementation by Mats Erik Andersson.
+ *
+ * The service name `rlogin' is regitered, and two modules
+ * `auth' and `account' are called for confirmation.
+ * These two modules suffice, since further verification
+ * is completed by login(1), which continues where `rlogind'
+ * hands off execution.
+ *
+ * Sample settings:
+ *
+ *   GNU/Linux, et cetera:
+ *
+ *     auth    required  pam_nologin.so
+ *     auth    required  pam_rhosts.so
+ *
+ *     account required  pam_nologin.so
+ *     account required  pam_unix.so
+ *
+ *   BSD:
+ *
+ *     auth    required  pam_nologin.so   # NetBSD
+ *     auth    required  pam_rhosts.so
+ *
+ *     account required  pam_nologin.so   # FreeBSD
+ *     account required  pam_unix.so
+ *
+ *   OpenSolaris:
+ *
+ *     auth    required  pam_rhosts_auth.so
+ *     auth    required  pam_unix_auth.so
+ *
+ *     account required  pam_unix_roles.so
+ *     account required  pam_unix_account.so
+ *
+ */
+
+/*
+ * TODO: Implement PAM also for Shishi/Kerberos.
+ */
+
 #include <config.h>
 
 #include <signal.h>
@@ -71,6 +112,10 @@
 # include <tcpd.h>
 #endif
 
+#ifdef HAVE_SECURITY_PAM_APPL_H
+# include <security/pam_appl.h>
+#endif
+
 #include <progname.h>
 #include <argp.h>
 #include <libinetutils.h>
@@ -186,6 +231,14 @@ int allow_root = 0;
 int verify_hostname = 0;
 int keepalive = 1;
 
+#ifdef WITH_PAM
+static int pam_rc = PAM_AUTH_ERR;
+static pam_handle_t *pam_handle = NULL;
+static int rlogin_conv (int, const struct pam_message **,
+		       struct pam_response **, void *);
+static struct pam_conv pam_conv = { rlogin_conv, NULL };
+#endif /* WITH_PAM */
+
 #if defined KERBEROS || defined SHISHI
 int kerberos = 0;
 char *servername = NULL;
@@ -358,7 +411,12 @@ check_host (struct sockaddr *sa, socklen_t len)
 #endif
 
 
-const char doc[] = "Remote login server";
+const char doc[] =
+#ifdef WITH_PAM
+  "Remote login server, using PAM service 'rlogin'.";
+#else /* !WITH_PAM */
+  "Remote login server";
+#endif
 const char *program_authors[] = {
   "Alain Magloire",
   "Sergey Poznyakoff",
@@ -795,10 +853,10 @@ rlogind_auth (int fd, struct auth_data *ap)
   char hoststr[NI_MAXHOST];
 #else
   struct hostent *hp;
+  void *addrp;
 #endif
   char *hostname;
   int authenticated = 0;
-  void * addrp;
   int port;
 
 #ifdef SHISHI
@@ -808,12 +866,16 @@ rlogind_auth (int fd, struct auth_data *ap)
   switch (ap->from.ss_family)
     {
     case AF_INET6:
+#if !HAVE_DECL_GETADDRINFO || !HAVE_DECL_GETNAMEINFO
       addrp = (void *) &((struct sockaddr_in6 *) &ap->from)->sin6_addr;
+#endif
       port = ntohs (((struct sockaddr_in6 *) &ap->from)->sin6_port);
       break;
     case AF_INET:
     default:
+#if !HAVE_DECL_GETADDRINFO || !HAVE_DECL_GETNAMEINFO
       addrp = (void *) &((struct sockaddr_in *) &ap->from)->sin_addr;
+#endif
       port = ntohs (((struct sockaddr_in *) &ap->from)->sin_port);
     }
 
@@ -1192,6 +1254,9 @@ do_rlogin (int infd, struct auth_data *ap)
 {
   struct passwd *pwd;
   int rc;
+#ifdef WITH_PAM
+  char *user;
+#endif
 #if defined WITH_IRUSEROK_AF || defined WITH_IRUSEROK
   void *addrp;
 
@@ -1222,6 +1287,118 @@ do_rlogin (int infd, struct auth_data *ap)
       fatal (infd, "Permission denied", 0);
     }
 
+#ifdef WITH_PAM
+  pam_rc = pam_start ("rlogin", ap->lusername, &pam_conv, &pam_handle);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RHOST, ap->hostname);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RUSER, ap->rusername);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_TTY, "rlogin");
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      if (pam_handle)
+	pam_end (pam_handle, pam_rc);
+
+      /* Failed set-up is deemed serious.  Abort!  */
+      syslog (LOG_ERR | LOG_AUTH, "PAM set-up failed.");
+      fatal (infd, "Permission denied", 0);
+    }
+
+  pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_ABORT:
+	  /* Serious enough to merit immediate abortion.  */
+	  pam_end (pam_handle, pam_rc);
+	  syslog (LOG_ERR | LOG_AUTH, "PAM authentication said PAM_ABORT.");
+	  exit (EXIT_FAILURE);
+
+	case PAM_NEW_AUTHTOK_REQD:
+	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+	  if (pam_rc == PAM_SUCCESS)
+	    pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
+	  break;
+
+	default:
+	  break;			/* Non-zero status.  */
+	}
+    }
+
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_NOTICE | LOG_AUTH,
+	      "PAM authentication of '%s' from %s(%s): %s",
+	      user, ap->hostname, ap->hostaddr,
+	      pam_strerror (pam_handle, pam_rc));
+      pam_end (pam_handle, pam_rc);
+
+      return pam_rc;
+    }
+
+  pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_NEW_AUTHTOK_REQD:
+	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+	  if (pam_rc == PAM_SUCCESS)
+	    pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
+	  break;
+
+	case PAM_ACCT_EXPIRED:
+	case PAM_AUTH_ERR:
+	case PAM_PERM_DENIED:
+	case PAM_USER_UNKNOWN:
+	default:
+	  break;			/* Non-zero status.  */
+	}
+    }
+
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_INFO | LOG_AUTH,
+	      "PAM accounting of '%s' from %s(%s): %s",
+	      user, ap->hostname, ap->hostaddr,
+	      pam_strerror (pam_handle, pam_rc));
+      pam_end (pam_handle, pam_rc);
+
+      return pam_rc;
+    }
+
+  /* Renew client information, since the PAM stack may have
+   * mapped the request onto another identity.
+   */
+  pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_NOTICE | LOG_AUTH, "pam_get_item(PAM_USER): %s",
+	      pam_strerror (pam_handle, pam_rc));
+      user = "<invalid>";
+    }
+
+  pwd = getpwnam (user);
+  free (ap->lusername);
+  ap->lusername = xstrdup (user);
+
+  if (pwd == NULL)
+    {
+      syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: unknown login.",
+	      ap->rusername, ap->hostname, ap->lusername);
+      pam_rc = PAM_AUTH_ERR;		/* Non-zero status.  */
+    }
+
+  pam_end (pam_handle, pam_rc);		/* PAM access is complete.  */
+
+  if (pam_rc != PAM_SUCCESS)
+    return pam_rc;
+#endif /* WITH_PAM */
+
 #if defined WITH_IRUSEROK_SA || defined WITH_IRUSEROK_AF \
     || defined WITH_IRUSEROK
 # ifdef WITH_IRUSEROK_SA
@@ -1995,5 +2172,58 @@ void
 fatal (int f, const char *msg, int syserr)
 {
   rlogind_error (f, syserr, (msg && *msg) ? msg : "unspecified error");
+#ifdef WITH_PAM
+  if (pam_handle)
+    pam_end (pam_handle, pam_rc);
+#endif
+
   exit (EXIT_FAILURE);
 }
+
+#ifdef WITH_PAM
+/* Call back function for passing user's information
+ * to any PAM module requesting this information.
+ */
+static int
+rlogin_conv (int num, const struct pam_message **pam_msg,
+	     struct pam_response **pam_resp,
+	     void *data _GL_UNUSED_PARAMETER)
+{
+  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.  */
+      resp = (struct pam_response *) malloc (sizeof (*resp));
+      if (!resp)
+	return PAM_BUF_ERR;
+      resp->resp_retcode = 0;
+      resp->resp = strdup ("");
+      if (!resp->resp)
+	{
+	  free (resp);
+	  return PAM_BUF_ERR;
+	}
+      syslog (LOG_NOTICE | LOG_AUTH, "PAM message \"%s\".",
+	      (*pam_msg)->msg);
+      *pam_resp = resp;
+      return PAM_SUCCESS;
+      break;
+
+    case PAM_TEXT_INFO:		/* Would break protocol.  */
+    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 */

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

Summary of changes:
 ChangeLog       |   22 +++++
 configure.ac    |    2 +-
 src/Makefile.am |    2 +-
 src/rlogind.c   |  234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 256 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed Mar 13 18:10:56 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UFtsu-0000iH-DM
	for mharc-commit-inetutils@gnu.org; Wed, 13 Mar 2013 18:10:56 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37980)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFtso-0000hz-Ht
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 18:10:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFtsj-0004JQ-KU
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 18:10:50 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:58992)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UFtsj-0004JG-CB
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 18:10:45 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UFtsh-0007FT-Jc
	for commit-inetutils@gnu.org; Wed, 13 Mar 2013 22:10:44 +0000
Date: Wed, 13 Mar 2013 22:10:43 +0000
Message-Id: <E1UFtsh-0007FT-Jc@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-254-g92a0155
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082
X-Git-Newrev: 92a015531592b9bb4ec83ea572f2d2288fed34e9
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 13 Mar 2013 22:10:54 -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  92a015531592b9bb4ec83ea572f2d2288fed34e9 (commit)
      from  3389ecc4c9aa5cf2e5ea2d152e83de7c4d9d9082 (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=92a015531592b9bb4ec83ea572f2d2288fed34e9


commit 92a015531592b9bb4ec83ea572f2d2288fed34e9
Author: Guillem Jover <guillem@hadrons.org>
Date:   Wed Mar 13 23:03:14 2013 +0100

    Use standard suid-mode.

diff --git a/ChangeLog b/ChangeLog
index 8339f92..b3fa23a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-13  Guillem Jover  <guillem@hadrons.org>
+
+	Use standard suid-mode for install.
+
+	* ping/Makefile.am (SUIDMODE): Change mode to `4755'.
+	* src/Makefile.am (SUIDMODE): Likewise.
+
 2013-03-13  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rlogind: Initial PAM support.
diff --git a/ping/Makefile.am b/ping/Makefile.am
index d8d5fc5..99e04a9 100644
--- a/ping/Makefile.am
+++ b/ping/Makefile.am
@@ -37,7 +37,7 @@ ping_SOURCES = ping.c ping_common.c ping_echo.c ping_address.c \
   ping_router.c ping_timestamp.c ping_common.h  ping_impl.h ping.h libping.c
 ping6_SOURCES = ping6.c ping_common.c ping_common.h ping6.h
 
-SUIDMODE = -o root -m 4775
+SUIDMODE = -o root -m 4755
 
 install-ping-hook:
 	-@for x in $(bin_PROGRAMS); do \
diff --git a/src/Makefile.am b/src/Makefile.am
index e8f6392..7cbcf98 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,7 +114,7 @@ uucpd_SOURCES = uucpd.c
 uucpd_LDADD = $(LDADD) $(LIBCRYPT)
 EXTRA_PROGRAMS += uucpd
 
-SUIDMODE = -o root -m 4775
+SUIDMODE = -o root -m 4755
 
 install-exec-hook: $(traceroute_INSTALL_HOOK) $(rsh_INSTALL_HOOK) $(rlogin_INSTALL_HOOK) $(rcp_INSTALL_HOOK)
 

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

Summary of changes:
 ChangeLog        |    7 +++++++
 ping/Makefile.am |    2 +-
 src/Makefile.am  |    2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Mar 14 21:24:28 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UGJNk-0000Xg-4s
	for mharc-commit-inetutils@gnu.org; Thu, 14 Mar 2013 21:24:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37584)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGJNe-0000RS-P2
	for commit-inetutils@gnu.org; Thu, 14 Mar 2013 21:24:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGJNb-0007tM-VG
	for commit-inetutils@gnu.org; Thu, 14 Mar 2013 21:24:22 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:32907)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGJNb-0007tH-Qv
	for commit-inetutils@gnu.org; Thu, 14 Mar 2013 21:24:19 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UGJNb-00047x-Eq
	for commit-inetutils@gnu.org; Fri, 15 Mar 2013 01:24:19 +0000
Date: Fri, 15 Mar 2013 01:24:19 +0000
Message-Id: <E1UGJNb-00047x-Eq@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-257-g43b50bb
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 92a015531592b9bb4ec83ea572f2d2288fed34e9
X-Git-Newrev: 43b50bb11e6aec4b92de64807967f1173eb4326b
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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 Mar 2013 01:24:26 -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  43b50bb11e6aec4b92de64807967f1173eb4326b (commit)
       via  45025971e1124701e522260850eb28cba51822d7 (commit)
       via  9a5bd6a12d74c10ce9654f702c6cce947e344074 (commit)
      from  92a015531592b9bb4ec83ea572f2d2288fed34e9 (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=43b50bb11e6aec4b92de64807967f1173eb4326b


commit 43b50bb11e6aec4b92de64807967f1173eb4326b
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Mar 15 01:14:04 2013 +0100

    rshd: Differentiate PAM services.

diff --git a/ChangeLog b/ChangeLog
index f8e9d6c..39256c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2013-03-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rshd: Differentiate PAM services.
+
+	* src/rshd.c (service) [WITH_PAM]: New variable.
+	(doc) [WITH_PAM && (KERBEROS || SHISHI)]:
+	Mention `krsh' in description.
+	(doit) [WITH_PAM && (KERBEROS || SHISHI)]:
+	Set PAM service type to "krsh" for kerberised action,
+	and "rsh" otherwise.
+	[WITH_PAM]: Pass `service' to pam_start() and to
+	pam_set_item(PAM_TTY).
+	(rsh_conv) [WITH_PAM]: Add _GL_UNUSED_PARAMETER to the
+	function parameter `data'.
+
 2013-03-14  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rlogind: PAM support with libshishi.
diff --git a/src/rshd.c b/src/rshd.c
index 2684d03..5ed460e 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -303,9 +303,13 @@ parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
 
 const char doc[] =
 #ifdef WITH_PAM
-		   "Remote shell server, using PAM service 'rsh'.";
+# if defined KERBEROS || defined SHISHI
+  "Remote shell server, using PAM services 'rsh' and 'krsh'.";
+# else
+  "Remote shell server, using PAM service 'rsh'.";
+# endif
 #else /* !WITH_PAM */
-		   "Remote shell server.";
+  "Remote shell server.";
 #endif
 static struct argp argp = { options, parse_opt, NULL, doc, NULL, NULL, NULL};
 
@@ -423,6 +427,9 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 #if defined WITH_IRUSEROK_AF && !defined WITH_PAM
   void * fromaddrp;	/* Pointer to remote address.  */
 #endif
+#ifdef WITH_PAM
+  char *service;
+#endif
 
 #ifdef	KERBEROS
   AUTH_DAT *kdata = (AUTH_DAT *) NULL;
@@ -1017,13 +1024,20 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
     }
 
 #ifdef WITH_PAM
-  pam_rc = pam_start ("rsh", locuser, &pam_conv, &pam_handle);
+# if defined KERBEROS || defined SHISHI
+  if (use_kerberos)
+    service = "krsh";
+  else
+# endif
+    service = "rsh";
+
+  pam_rc = pam_start (service, 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");
+    pam_rc = pam_set_item (pam_handle, PAM_TTY, service);
   if (pam_rc != PAM_SUCCESS)
     {
       errorstr = "Try again.\n";
@@ -1782,7 +1796,8 @@ topdomain (const char *h)
  */
 static int
 rsh_conv (int num, const struct pam_message **pam_msg,
-	    struct pam_response **pam_resp, void *data)
+	    struct pam_response **pam_resp,
+	    void *data _GL_UNUSED_PARAMETER)
 {
   struct pam_response *resp;
 

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


commit 45025971e1124701e522260850eb28cba51822d7
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Mar 15 00:40:15 2013 +0100

    rlogind: PAM support with libshishi.

diff --git a/ChangeLog b/ChangeLog
index 9e460ce..f8e9d6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2013-03-14  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	rlogind: PAM support with libshishi.
+
+	* src/rlogind.c (doc) [WITH_PAM && SHISHI]:
+	Mention `krlogin' in description.
+	(do_pam_check) [WITH_PAM]: New function,
+	refactored from previous code in do_rlogin().
+	(do_rlogin) [WITH_PAM]: Remove variable USER.
+	Replace code block by a call to do_pam_check()
+	for service `rlogin'.
+	(do_shishi_login) [SHISHI && WITH_PAM]:
+	Call do_pam_check() for service `krlogin'.
+
+2013-03-14  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	* src/rlogind.c (do_shishi_login) [SHISHI]:
 	Do not free the static pointer PWD!
 	Call getpwnam() for verification that local
diff --git a/src/rlogind.c b/src/rlogind.c
index c2e2abb..681d59e 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -21,9 +21,10 @@
 /*
  * PAM implementation by Mats Erik Andersson.
  *
- * The service name `rlogin' is regitered, and two modules
- * `auth' and `account' are called for confirmation.
- * These two modules suffice, since further verification
+ * The service names `rlogin' and `krlogin' are registered,
+ * the latter when Shishi support is included, and two
+ * facilities `auth' and `account' are used for confirmation.
+ * These two facilities suffice, since further verification
  * is completed by login(1), which continues where `rlogind'
  * hands off execution.
  *
@@ -55,10 +56,6 @@
  *
  */
 
-/*
- * TODO: Implement PAM also for Shishi/Kerberos.
- */
-
 #include <config.h>
 
 #include <signal.h>
@@ -294,6 +291,10 @@ char *topdomain (char *name, int max_dots);
 int do_shishi_login (int infd, struct auth_data *ad, const char **err_msg);
 #endif
 
+#ifdef WITH_PAM
+int do_pam_check (int infd, struct auth_data *ap, const char *service);
+#endif
+
 void
 rlogind_sigchld (int signo _GL_UNUSED_PARAMETER)
 {
@@ -413,7 +414,11 @@ check_host (struct sockaddr *sa, socklen_t len)
 
 const char doc[] =
 #ifdef WITH_PAM
+# ifdef SHISHI
+  "Remote login server, using PAM service 'rlogin' and 'krlogin'.";
+# else /* !SHISHI */
   "Remote login server, using PAM service 'rlogin'.";
+# endif
 #else /* !WITH_PAM */
   "Remote login server";
 #endif
@@ -1254,9 +1259,6 @@ do_rlogin (int infd, struct auth_data *ap)
 {
   struct passwd *pwd;
   int rc;
-#ifdef WITH_PAM
-  char *user;
-#endif
 #if defined WITH_IRUSEROK_AF || defined WITH_IRUSEROK
   void *addrp;
 
@@ -1288,115 +1290,9 @@ do_rlogin (int infd, struct auth_data *ap)
     }
 
 #ifdef WITH_PAM
-  pam_rc = pam_start ("rlogin", ap->lusername, &pam_conv, &pam_handle);
-  if (pam_rc == PAM_SUCCESS)
-    pam_rc = pam_set_item (pam_handle, PAM_RHOST, ap->hostname);
-  if (pam_rc == PAM_SUCCESS)
-    pam_rc = pam_set_item (pam_handle, PAM_RUSER, ap->rusername);
-  if (pam_rc == PAM_SUCCESS)
-    pam_rc = pam_set_item (pam_handle, PAM_TTY, "rlogin");
-  if (pam_rc == PAM_SUCCESS)
-    pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
-  if (pam_rc != PAM_SUCCESS)
-    {
-      if (pam_handle)
-	pam_end (pam_handle, pam_rc);
-
-      /* Failed set-up is deemed serious.  Abort!  */
-      syslog (LOG_ERR | LOG_AUTH, "PAM set-up failed.");
-      fatal (infd, "Permission denied", 0);
-    }
-
-  pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
-  if (pam_rc != PAM_SUCCESS)
-    {
-      switch (pam_rc)
-	{
-	case PAM_ABORT:
-	  /* Serious enough to merit immediate abortion.  */
-	  pam_end (pam_handle, pam_rc);
-	  syslog (LOG_ERR | LOG_AUTH, "PAM authentication said PAM_ABORT.");
-	  exit (EXIT_FAILURE);
-
-	case PAM_NEW_AUTHTOK_REQD:
-	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
-	  if (pam_rc == PAM_SUCCESS)
-	    pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
-	  break;
-
-	default:
-	  break;			/* Non-zero status.  */
-	}
-    }
-
-  if (pam_rc != PAM_SUCCESS)
-    {
-      syslog (LOG_NOTICE | LOG_AUTH,
-	      "PAM authentication of '%s' from %s(%s): %s",
-	      user, ap->hostname, ap->hostaddr,
-	      pam_strerror (pam_handle, pam_rc));
-      pam_end (pam_handle, pam_rc);
-
-      return pam_rc;
-    }
-
-  pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
-  if (pam_rc != PAM_SUCCESS)
-    {
-      switch (pam_rc)
-	{
-	case PAM_NEW_AUTHTOK_REQD:
-	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
-	  if (pam_rc == PAM_SUCCESS)
-	    pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
-	  break;
-
-	case PAM_ACCT_EXPIRED:
-	case PAM_AUTH_ERR:
-	case PAM_PERM_DENIED:
-	case PAM_USER_UNKNOWN:
-	default:
-	  break;			/* Non-zero status.  */
-	}
-    }
-
-  if (pam_rc != PAM_SUCCESS)
-    {
-      syslog (LOG_INFO | LOG_AUTH,
-	      "PAM accounting of '%s' from %s(%s): %s",
-	      user, ap->hostname, ap->hostaddr,
-	      pam_strerror (pam_handle, pam_rc));
-      pam_end (pam_handle, pam_rc);
-
-      return pam_rc;
-    }
-
-  /* Renew client information, since the PAM stack may have
-   * mapped the request onto another identity.
-   */
-  pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
-  if (pam_rc != PAM_SUCCESS)
-    {
-      syslog (LOG_NOTICE | LOG_AUTH, "pam_get_item(PAM_USER): %s",
-	      pam_strerror (pam_handle, pam_rc));
-      user = "<invalid>";
-    }
-
-  pwd = getpwnam (user);
-  free (ap->lusername);
-  ap->lusername = xstrdup (user);
-
-  if (pwd == NULL)
-    {
-      syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: unknown login.",
-	      ap->rusername, ap->hostname, ap->lusername);
-      pam_rc = PAM_AUTH_ERR;		/* Non-zero status.  */
-    }
-
-  pam_end (pam_handle, pam_rc);		/* PAM access is complete.  */
-
-  if (pam_rc != PAM_SUCCESS)
-    return pam_rc;
+  rc = do_pam_check (infd, ap, "rlogin");
+  if (rc != PAM_SUCCESS)
+    return rc;
 #endif /* WITH_PAM */
 
 #if defined WITH_IRUSEROK_SA || defined WITH_IRUSEROK_AF \
@@ -1716,7 +1612,7 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
 	    }
 	}
     }
-#  endif
+#  endif /* ENCRYPTION */
 
   getstr (infd, &ad->lusername, NULL);		/* Acting user.  */
   getstr (infd, &ad->term, "TERM=");
@@ -1787,6 +1683,12 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
 
   shishi_ap_done (ad->ap);
 
+#  ifdef WITH_PAM
+  rc = do_pam_check (infd, ad, "krlogin");
+  if (rc != PAM_SUCCESS)
+    return rc;
+#  endif /* WITH_PAM */
+
   syslog (LOG_INFO | LOG_AUTH,
 	  "Kerberos V %slogin from %s on %s as `%s'.\n",
 	  encrypt_io ? "encrypted " : "",
@@ -2175,6 +2077,128 @@ fatal (int f, const char *msg, int syserr)
 }
 
 #ifdef WITH_PAM
+int
+do_pam_check (int infd, struct auth_data *ap, const char *service)
+{
+  char *user;
+  struct passwd *pwd;
+
+  pam_rc = pam_start (service, ap->lusername, &pam_conv, &pam_handle);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RHOST, ap->hostname);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_RUSER, ap->rusername);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_set_item (pam_handle, PAM_TTY, service);
+  if (pam_rc == PAM_SUCCESS)
+    pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      if (pam_handle)
+	{
+	  pam_end (pam_handle, pam_rc);
+	  pam_handle = NULL;
+	}
+
+      /* Failed set-up is deemed serious.  Abort!  */
+      syslog (LOG_ERR | LOG_AUTH, "PAM set-up failed.");
+      fatal (infd, "Permission denied", 0);
+    }
+
+  pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_ABORT:
+	  /* Serious enough to merit immediate abortion.  */
+	  pam_end (pam_handle, pam_rc);
+	  syslog (LOG_ERR | LOG_AUTH, "PAM authentication said PAM_ABORT.");
+	  exit (EXIT_FAILURE);
+
+	case PAM_NEW_AUTHTOK_REQD:
+	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+	  if (pam_rc == PAM_SUCCESS)
+	    pam_rc = pam_authenticate (pam_handle, PAM_SILENT);
+	  break;
+
+	default:
+	  break;			/* Non-zero status.  */
+	}
+    }
+
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_NOTICE | LOG_AUTH,
+	      "PAM authentication of '%s' from %s(%s): %s",
+	      user, ap->hostname, ap->hostaddr,
+	      pam_strerror (pam_handle, pam_rc));
+      pam_end (pam_handle, pam_rc);
+      pam_handle = NULL;
+
+      return pam_rc;
+    }
+
+  pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      switch (pam_rc)
+	{
+	case PAM_NEW_AUTHTOK_REQD:
+	  pam_rc = pam_chauthtok (pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
+	  if (pam_rc == PAM_SUCCESS)
+	    pam_rc = pam_acct_mgmt (pam_handle, PAM_SILENT);
+	  break;
+
+	case PAM_ACCT_EXPIRED:
+	case PAM_AUTH_ERR:
+	case PAM_PERM_DENIED:
+	case PAM_USER_UNKNOWN:
+	default:
+	  break;			/* Non-zero status.  */
+	}
+    }
+
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_INFO | LOG_AUTH,
+	      "PAM accounting of '%s' from %s(%s): %s",
+	      user, ap->hostname, ap->hostaddr,
+	      pam_strerror (pam_handle, pam_rc));
+      pam_end (pam_handle, pam_rc);
+      pam_handle = NULL;
+
+      return pam_rc;
+    }
+
+  /* Renew client information, since the PAM stack may have
+   * mapped the request onto another identity.
+   */
+  pam_rc = pam_get_item (pam_handle, PAM_USER, (const void **) &user);
+  if (pam_rc != PAM_SUCCESS)
+    {
+      syslog (LOG_NOTICE | LOG_AUTH, "pam_get_item(PAM_USER): %s",
+	      pam_strerror (pam_handle, pam_rc));
+      user = "<invalid>";
+    }
+
+  pwd = getpwnam (user);
+  free (ap->lusername);
+  ap->lusername = xstrdup (user);
+
+  if (pwd == NULL)
+    {
+      syslog (LOG_INFO | LOG_AUTH, "%s@%s as %s: unknown login.",
+	      ap->rusername, ap->hostname, ap->lusername);
+      pam_rc = PAM_AUTH_ERR;		/* Non-zero status.  */
+    }
+
+  pam_end (pam_handle, pam_rc);		/* PAM access is complete.  */
+  pam_handle = NULL;
+
+  return pam_rc;
+}
+
 /* Call back function for passing user's information
  * to any PAM module requesting this information.
  */

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


commit 9a5bd6a12d74c10ce9654f702c6cce947e344074
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 14 19:23:07 2013 +0100

    rlogind: Additional user check.

diff --git a/ChangeLog b/ChangeLog
index b3fa23a..9e460ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-14  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* src/rlogind.c (do_shishi_login) [SHISHI]:
+	Do not free the static pointer PWD!
+	Call getpwnam() for verification that local
+	user exists.  Add check to prevent root access
+	unless the flag `allow_root' is set.
+	Call shishi_ap_done() before sending a log report.
+
 2013-03-13  Guillem Jover  <guillem@hadrons.org>
 
 	Use standard suid-mode for install.
diff --git a/src/rlogind.c b/src/rlogind.c
index 3922fb4..c2e2abb 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -1283,7 +1283,7 @@ do_rlogin (int infd, struct auth_data *ap)
     }
   if (!allow_root && pwd->pw_uid == 0)
     {
-      syslog (LOG_ERR | LOG_AUTH, "root logins not permitted");
+      syslog (LOG_ERR | LOG_AUTH, "root logins are not permitted");
       fatal (infd, "Permission denied", 0);
     }
 
@@ -1726,30 +1726,23 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
   if ((rc != sizeof (int)) || error)
     {
       *err_msg = "Authentication exchange failed.";
-      free (pwd);
       free (cksum);
       return EXIT_FAILURE;
     }
 
-  /*
-     getpwnam crash !!!!
-
-     pwd = getpwnam (ad->lusername);
-     if (pwd == NULL)
-     {
-     *err_msg = "getpwnam failed";
-     syslog (LOG_ERR | LOG_AUTH, "getpwnam failed: %m");
-     return 1;
-     }
-
-     syslog (LOG_INFO | LOG_AUTH,
-     "%sKerberos V login from %s on %s\n",
-     (pwd->pw_uid == 0) ? "ROOT " : "",
-     ad->lusername, ad->hostname);
-
-   */
-
-  free (pwd);
+  pwd = getpwnam (ad->lusername);
+  if (pwd == NULL)
+    {
+      *err_msg = "getpwnam failed";
+      free (cksum);
+      syslog (LOG_ERR | LOG_AUTH, "getpwnam failed: %m");
+      return 1;
+    }
+  if (!allow_root && pwd->pw_uid == 0)
+    {
+      syslog (LOG_ERR | LOG_AUTH, "root logins are not permitted");
+      fatal (infd, "Permission denied", 0);
+    }
 
   /* verify checksum */
 
@@ -1767,7 +1760,8 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
   rc = shishi_checksum (ad->h, ad->enckey, 0, cksumtype, cksumdata,
 			strlen (cksumdata), &compcksum, &compcksumlen);
   if (rc != SHISHI_OK
-      || compcksumlen != cksumlen || memcmp (compcksum, cksum, cksumlen) != 0)
+      || compcksumlen != cksumlen
+      || memcmp (compcksum, cksum, cksumlen) != 0)
     {
       *err_msg = "Authentication exchange failed.";
       syslog (LOG_ERR, "checksum verify failed: %s", shishi_error (ad->h));
@@ -1777,7 +1771,6 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
     }
 
   free (cksum);
-
   free (compcksum);
 
   rc = shishi_authorized_p (ad->h, shishi_ap_tkt (ad->ap), ad->lusername);
@@ -1787,17 +1780,18 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
 	      "User %s@%s is not authorized to log in as: %s.",
 	      ad->rusername, ad->hostname, ad->lusername);
       shishi_ap_done (ad->ap);
-      rlogind_error (infd, 0, "Failed to get authorized as `%s'.\n", ad->lusername);
+      rlogind_error (infd, 0, "Failed to get authorized as `%s'.\n",
+		     ad->lusername);
       return rc;
     }
 
+  shishi_ap_done (ad->ap);
+
   syslog (LOG_INFO | LOG_AUTH,
 	  "Kerberos V %slogin from %s on %s as `%s'.\n",
 	  encrypt_io ? "encrypted " : "",
 	  ad->rusername, ad->hostname, ad->lusername);
 
-  shishi_ap_done (ad->ap);
-
   return SHISHI_OK;
 }
 # endif /* SHISHI */

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

Summary of changes:
 ChangeLog     |   38 +++++++
 src/rlogind.c |  310 ++++++++++++++++++++++++++++++---------------------------
 src/rshd.c    |   25 ++++-
 3 files changed, 222 insertions(+), 151 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 15 11:23:30 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UGWTh-0003nO-QS
	for mharc-commit-inetutils@gnu.org; Fri, 15 Mar 2013 11:23:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45602)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGWTY-0003W3-4P
	for commit-inetutils@gnu.org; Fri, 15 Mar 2013 11:23:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGWTQ-00075G-9X
	for commit-inetutils@gnu.org; Fri, 15 Mar 2013 11:23:20 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56827)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UGWTQ-00074y-5e
	for commit-inetutils@gnu.org; Fri, 15 Mar 2013 11:23:12 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UGWTP-00052F-4H
	for commit-inetutils@gnu.org; Fri, 15 Mar 2013 15:23:11 +0000
Date: Fri, 15 Mar 2013 15:23:11 +0000
Message-Id: <E1UGWTP-00052F-4H@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-258-gdc951ef
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 43b50bb11e6aec4b92de64807967f1173eb4326b
X-Git-Newrev: dc951ef19cd5568ec15630a4c9ffd0decdb201af
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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 Mar 2013 15:23:28 -0000

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

The branch, master has been updated
       via  dc951ef19cd5568ec15630a4c9ffd0decdb201af (commit)
      from  43b50bb11e6aec4b92de64807967f1173eb4326b (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=dc951ef19cd5568ec15630a4c9ffd0decdb201af


commit dc951ef19cd5568ec15630a4c9ffd0decdb201af
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Mar 15 15:42:36 2013 +0100

    rlogind: Incomplete source route security.

diff --git a/ChangeLog b/ChangeLog
index 39256c1..4bb36a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2013-03-15  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	rlogind: Incomplete source route security.
+	The protection against IPOPT_LSRR was not
+	enforced during Kerberised execution.
+
+	* src/rlogind.c (prevent_routing) [IP_OPTIONS]:
+	New function, broken out of old code.  Replace
+	socket number 0 by a parameter `fd', which makes
+	certain that daemon-mode is examined correctly.
+	(rlogind_auth) [IP_OPTIONS]: Call prevent_routing()
+	early on, before code path separation for Kerberos.
+
+2013-03-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	rshd: Differentiate PAM services.
 
 	* src/rshd.c (service) [WITH_PAM]: New variable.
diff --git a/src/rlogind.c b/src/rlogind.c
index 681d59e..23e22fb 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -295,6 +295,10 @@ int do_shishi_login (int infd, struct auth_data *ad, const char **err_msg);
 int do_pam_check (int infd, struct auth_data *ap, const char *service);
 #endif
 
+#ifdef IP_OPTIONS
+void prevent_routing (int fd, struct auth_data *ap);
+#endif
+
 void
 rlogind_sigchld (int signo _GL_UNUSED_PARAMETER)
 {
@@ -960,6 +964,10 @@ rlogind_auth (int fd, struct auth_data *ap)
 	}
     }
 
+#ifdef IP_OPTIONS
+  prevent_routing (fd, ap);
+#endif
+
 #if defined KERBEROS || defined SHISHI
   if (kerberos)
     {
@@ -987,59 +995,7 @@ rlogind_auth (int fd, struct auth_data *ap)
 		  ap->hostaddr, port);
 	  fatal (fd, "Permission denied", 0);
 	}
-#ifdef IP_OPTIONS
-      {
-	unsigned char optbuf[BUFSIZ / 3], *cp;
-	char lbuf[BUFSIZ], *lp;
-	socklen_t optsize = sizeof (optbuf);
-	int ipproto;
-	struct protoent *ip;
-
-	ip = getprotobyname ("ip");
-	if (ip != NULL)
-	  ipproto = ip->p_proto;
-	else
-	  ipproto = IPPROTO_IP;
-	if (getsockopt (0, ipproto, IP_OPTIONS, (char *) optbuf,
-			&optsize) == 0 && optsize != 0)
-	  {
-	    lp = lbuf;
-	    for (cp = optbuf; optsize > 0; )
-	      {
-		sprintf (lp, " %2.2x", *cp);
-		lp += 3;
-
-		/* These two open an attack vector.  */
-		if (*cp == IPOPT_SSRR || *cp == IPOPT_LSRR)
-		  {
-		    syslog (LOG_NOTICE,
-			    "Discarding connection from %s with set source routing",
-			    ap->hostaddr);
-		    exit (EXIT_FAILURE);
-		  }
-		if (*cp == IPOPT_EOL)
-		  break;
-		if (*cp == IPOPT_NOP)
-		  cp++, optsize--;
-		else
-		  {
-		    /* Options using a length octet, see RFC 791.  */
-		    int inc = cp[1];
 
-		    optsize -= inc;
-		    cp += inc;
-		  }
-	      }
-
-	    syslog (LOG_NOTICE, "Ignoring IP options: %s", lbuf);
-	    if (setsockopt (0, ipproto, IP_OPTIONS, (char *) NULL, optsize))
-	      {
-		syslog (LOG_ERR, "setsockopt IP_OPTIONS NULL: %m");
-		exit (EXIT_FAILURE);
-	      }
-	  }
-      }
-#endif /* IP_OPTIONS */
       if (do_rlogin (fd, ap) == 0)
 	authenticated++;
     }
@@ -1060,6 +1016,66 @@ rlogind_auth (int fd, struct auth_data *ap)
   return authenticated;
 }
 
+#ifdef IP_OPTIONS
+void
+prevent_routing (int fd, struct auth_data *ap)
+{
+  unsigned char optbuf[BUFSIZ / 3], *cp;
+  char lbuf[BUFSIZ], *lp;
+  socklen_t optsize = sizeof (optbuf);
+  int ipproto;
+  struct protoent *ip;
+
+  ip = getprotobyname ("ip");
+  if (ip != NULL)
+    ipproto = ip->p_proto;
+  else
+    ipproto = IPPROTO_IP;
+
+  if (getsockopt (fd, ipproto, IP_OPTIONS, (char *) optbuf, &optsize) == 0
+      && optsize != 0)
+    {
+      lp = lbuf;
+      for (cp = optbuf; optsize > 0; )
+	{
+	  sprintf (lp, " %2.2x", *cp);
+	  lp += 3;
+
+	  /* These two open an attack vector.  */
+	  if (*cp == IPOPT_SSRR || *cp == IPOPT_LSRR)
+	    {
+	      syslog (LOG_NOTICE,
+		      "Discarding connection from %s with set source routing",
+		      ap->hostaddr);
+	      exit (EXIT_FAILURE);
+	    }
+
+	  if (*cp == IPOPT_EOL)
+	    break;
+
+	  if (*cp == IPOPT_NOP)
+	    cp++, optsize--;
+	  else
+	    {
+	      /* Options using a length octet, see RFC 791.  */
+	      int inc = cp[1];
+
+	      optsize -= inc;
+	      cp += inc;
+	    }
+	}
+
+      syslog (LOG_NOTICE, "Ignoring IP options: %s", lbuf);
+
+      if (setsockopt (fd, ipproto, IP_OPTIONS, (char *) NULL, optsize))
+	{
+	  syslog (LOG_ERR, "setsockopt IP_OPTIONS NULL: %m");
+	  exit (EXIT_FAILURE);
+	}
+    }
+}
+#endif /* IP_OPTIONS */
+
 void
 setup_tty (int fd, struct auth_data *ap)
 {

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

Summary of changes:
 ChangeLog     |   13 ++++++
 src/rlogind.c |  122 ++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 82 insertions(+), 53 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed Mar 20 16:10:10 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UIPKs-0006t8-32
	for mharc-commit-inetutils@gnu.org; Wed, 20 Mar 2013 16:10:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60065)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIPKm-0006pD-Du
	for commit-inetutils@gnu.org; Wed, 20 Mar 2013 16:10:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIPKh-0000df-LN
	for commit-inetutils@gnu.org; Wed, 20 Mar 2013 16:10:04 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55557)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIPKh-0000dZ-89
	for commit-inetutils@gnu.org; Wed, 20 Mar 2013 16:09:59 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UIPKg-0005Ey-LE
	for commit-inetutils@gnu.org; Wed, 20 Mar 2013 20:09:58 +0000
Date: Wed, 20 Mar 2013 20:09:58 +0000
Message-Id: <E1UIPKg-0005Ey-LE@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-259-g601105e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: dc951ef19cd5568ec15630a4c9ffd0decdb201af
X-Git-Newrev: 601105eae504371d873782596996c82899db897d
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 20 Mar 2013 20:10:09 -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  601105eae504371d873782596996c82899db897d (commit)
      from  dc951ef19cd5568ec15630a4c9ffd0decdb201af (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=601105eae504371d873782596996c82899db897d


commit 601105eae504371d873782596996c82899db897d
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue Mar 19 23:51:35 2013 +0100

    ftpd: Support PAM beyond Linux-PAM.

diff --git a/ChangeLog b/ChangeLog
index 4bb36a1..180b2de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2013-03-19  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Support PAM beyond Linux-PAM.
+
+	* configure.ac (FTPD_LIBPAM): Set to $LIBPAM
+	for all PAM implementations.
+	* ftpd/auth.c (auth_user) <default case>
+	[WITH_PAM && !WITH_LINUX_PAM]: Call pam_user()
+	if preceding tests were passed and if `auth_type'
+	is AUTH_TYPE_PAM.
+	(auth_pass) [WITH_PAM] <AUTH_TYPE_PAM>: Relax old
+	conditioning on WITH_LINUX_PAM.
+	* ftpd/extern.h (pam_user, pam_pass, pam_end_login)
+	[WITH_PAM]: Likewise.
+	* ftpd/ftpd.c (options) [WITH_PAM] <pam>: Likewise.
+	(parse_opt) <pam> [WITH_PAM]: Likewise.
+	(end_login) [WITH_PAM]: Likewise, use of pam_end_login().
+	* ftpd/pam.c [WITH_PAM]: Likewise, entire file.
+	(PAM_conv) <PAM_PROMPT_ECHO_OFF> [!WITH_LINUX_PAM]:
+	Return PAM_CRED_INSUFFICIENT.
+	(pam_doit) <failed pam_authenticate> [!WITH_LINUX_PAM]:
+	Check for status PAM_CRED_INSUFFICIENT with empty
+	password.
+
+	* ftpd/ftpd.c (doc) [WITH_PAM]: Mention PAM service
+	name 'ftp' in text.
+	(options) [WITH_KERBEROS5] <kerberos5>: Correct
+	misspelled authentication name.
+
 2013-03-15  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	rlogind: Incomplete source route security.
diff --git a/configure.ac b/configure.ac
index 1ba889e..4232703 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,11 +201,12 @@ if test "$with_pam" = yes ; then
   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.])
+    # ftpd was originally coded for Linux-PAM and was later
+    # adapted to go with OpenPAM and with Solaris-PAM.
+    FTPD_LIBPAM=$LIBPAM
     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
diff --git a/ftpd/auth.c b/ftpd/auth.c
index db9668d..8773a59 100644
--- a/ftpd/auth.c
+++ b/ftpd/auth.c
@@ -83,7 +83,13 @@ auth_user (const char *name, struct credentials *pcred)
 	if (pcred->message == NULL)
 	  return -1;
 
-	/* check for anonymous logging */
+	/* Check for anonymous log in.
+	 *
+	 * This code simulates part of `pam_ftp.so'
+	 * for PAM variants that are not Linux-PAM,
+	 * in addition to perform the original
+	 * default authentication checks.
+	 */
 	if (strcmp (name, "ftp") == 0 || strcmp (name, "anonymous") == 0)
 	  {
 	    if (checkuser (PATH_FTPUSERS, "ftp")
@@ -141,7 +147,14 @@ auth_user (const char *name, struct credentials *pcred)
     }
 
   if (err == 0)
-    pcred->dochroot = checkuser (PATH_FTPCHROOT, pcred->name);
+    {
+      pcred->dochroot = checkuser (PATH_FTPCHROOT, pcred->name);
+
+#if defined WITH_PAM && !defined WITH_LINUX_PAM
+      if (pcred->auth_type == AUTH_TYPE_PAM)
+	err = pam_user (name, pcred);
+#endif /* WITH_PAM && !WITH_LINUX_PAM */
+    }
 
   return err;
 }
@@ -151,7 +164,7 @@ auth_pass (const char *passwd, struct credentials *pcred)
 {
   switch (pcred->auth_type)
     {
-#ifdef WITH_LINUX_PAM
+#ifdef WITH_PAM
     case AUTH_TYPE_PAM:
       return pam_pass (passwd, pcred);
 #endif
diff --git a/ftpd/extern.h b/ftpd/extern.h
index a10317d..aa52530 100644
--- a/ftpd/extern.h
+++ b/ftpd/extern.h
@@ -154,8 +154,8 @@ extern int auth_user (const char *, struct credentials *);
 extern int auth_pass (const char *, struct credentials *);
 
 /* Exported from pam.c */
-#ifdef WITH_LINUX_PAM
+#ifdef WITH_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
+#endif /* WITH_PAM */
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 11a69fb..b333004 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -253,7 +253,12 @@ static int receive_data (FILE *, FILE *, off_t);
 static void send_data (FILE *, FILE *, off_t);
 static void sigquit (int);
 
-const char doc[] = "File Transfer Protocol Daemon";
+const char doc[] =
+#ifdef WITH_PAM
+  "File Transfer Protocol daemon, offering PAM service 'ftp'.";
+#else
+  "File Transfer Protocol daemon.";
+#endif
 
 static struct argp_option options[] = {
 #define GRID 0
@@ -297,9 +302,9 @@ static struct argp_option options[] = {
   { "  default", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
     "passwd authentication",
     GRID+3 },
-#ifdef WITH_LINUX_PAM
+#ifdef WITH_PAM
   { "  pam", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
-    "using pam 'ftp' module",
+    "using PAM service 'ftp'",
     GRID+3 },
 #endif
 #ifdef WITH_KERBEROS
@@ -308,7 +313,7 @@ static struct argp_option options[] = {
     GRID+3 },
 #endif
 #ifdef WITH_KERBEROS5
-  { "  kderberos5", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
+  { "  kerberos5", 0, NULL, OPTION_DOC|OPTION_NO_TRANS,
     "",
     GRID+3 },
 #endif
@@ -343,7 +348,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_LINUX_PAM
+#ifdef WITH_PAM
       else if (strcasecmp (arg, "pam") == 0)
 	cred.auth_type = AUTH_TYPE_PAM;
 #endif
@@ -835,7 +840,7 @@ end_login (struct credentials *pcred)
   if (pcred->logged_in)
     {
       logwtmp_keep_open (ttyline, "", "");
-#ifdef WITH_LINUX_PAM
+#ifdef WITH_PAM
       pam_end_login (pcred);
 #endif
     }
diff --git a/ftpd/pam.c b/ftpd/pam.c
index ff08a7c..3a970a4 100644
--- a/ftpd/pam.c
+++ b/ftpd/pam.c
@@ -30,6 +30,23 @@
 # include <security/pam_appl.h>
 #endif
 
+/*
+ * Mechanisms and prerequisites.
+ *
+ * The original code was tailored to rely on the side-effects
+ * of the Linux-PAM module `pam_ftp.so', with its peculiarities:
+ *
+ *  1. If PAM_USER is `ftp' or `anonymous', fetch PAM_AUTHTOK
+ *     and split it at `@' into PAM_RUSER and PAM_RHOST.
+ *     Return with success and set PAM_USER to `ftp'.
+ *
+ *  2. For other values of PAM_USER, keep the gotten PAM_AUTHTOK
+ *     unchanged, and fail.
+ *
+ * This module `pam_ftp.so' does not exist in OpenPAM, nor in
+ * Solaris-PAM.  Thus portability requires some care.
+ */
+
 /* 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
@@ -39,16 +56,16 @@
  * by preprocessor conditionals for the time being.
  */
 
-#ifdef WITH_LINUX_PAM
+#ifdef WITH_PAM
+
+/* PAM authentication, now using the PAM's async feature.  */
+static pam_handle_t *pamh;
 
 static int PAM_conv (int num_msg, const struct pam_message **msg,
 		     struct pam_response **resp, void *appdata_ptr);
 
 static struct pam_conv PAM_conversation = { &PAM_conv, NULL };
 
-/* PAM authentication, now using the PAM's async feature.  */
-static pam_handle_t *pamh;
-
 static int
 PAM_conv (int num_msg, const struct pam_message **msg,
 	  struct pam_response **resp, void *appdata_ptr)
@@ -83,8 +100,15 @@ PAM_conv (int num_msg, const struct pam_message **msg,
 	    {
 	      savemsg = 1;
 # ifdef PAM_CONV_AGAIN
-	      retval = PAM_CONV_AGAIN;
-# else /* !PAM_CONV_AGAIN */
+	      retval = PAM_CONV_AGAIN;		/* Linux-PAM */
+# elif !defined WITH_LINUX_PAM
+	      /*
+	       * Simulate PAM_CONV_AGAIN.
+	       * The alternate value PAM_TRY_AGAIN is not
+	       * an expected return value here, so it will
+	       * leave an audit trail.  */
+	      retval = PAM_CRED_INSUFFICIENT;
+# else /* !PAM_CONV_AGAIN && !WITH_LINUX_PAM */
 	      retval = PAM_CONV_ERR;
 # endif
 	    }
@@ -166,7 +190,7 @@ PAM_conv (int num_msg, const struct pam_message **msg,
   return PAM_SUCCESS;
 }
 
-/* Non-zero means failure. */
+/* Non-zero return status means failure. */
 static int
 pam_doit (struct credentials *pcred)
 {
@@ -175,7 +199,7 @@ pam_doit (struct credentials *pcred)
 
   error = pam_authenticate (pamh, 0);
 
-  /* Probably being called for the passwd.  */
+  /* Probably being called with empty passwd.  */
   if (0
 # ifdef PAM_CONV_AGAIN
       || error == PAM_CONV_AGAIN
@@ -183,6 +207,13 @@ pam_doit (struct credentials *pcred)
 # ifdef PAM_INCOMPLETE
       || error == PAM_INCOMPLETE
 # endif
+# ifndef WITH_LINUX_PAM
+      /*
+       * In absence of `pam_ftp.so', catch the simulated,
+       * incomplete state reported by our PAM_conv().
+       */
+      || (error == PAM_CRED_INSUFFICIENT && pcred->pass == NULL)
+# endif /* !WITH_LINUX_PAM */
      )
     {
       /* Avoid overly terse passwd messages and let the people
@@ -295,4 +326,4 @@ pam_end_login (struct credentials * pcred _GL_UNUSED_PARAMETER)
       pamh = NULL;
     }
 }
-#endif /* WITH_LINUX_PAM */
+#endif /* WITH_PAM */

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

Summary of changes:
 ChangeLog     |   29 +++++++++++++++++++++++++++++
 configure.ac  |    5 +++--
 ftpd/auth.c   |   19 ++++++++++++++++---
 ftpd/extern.h |    4 ++--
 ftpd/ftpd.c   |   17 +++++++++++------
 ftpd/pam.c    |   49 ++++++++++++++++++++++++++++++++++++++++---------
 6 files changed, 101 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Mar 21 09:49:26 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UIfry-0003ts-9w
	for mharc-commit-inetutils@gnu.org; Thu, 21 Mar 2013 09:49:26 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54046)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIfru-0003tT-5h
	for commit-inetutils@gnu.org; Thu, 21 Mar 2013 09:49:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIfrp-00012v-7i
	for commit-inetutils@gnu.org; Thu, 21 Mar 2013 09:49:22 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38402)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIfrp-00012R-3B
	for commit-inetutils@gnu.org; Thu, 21 Mar 2013 09:49:17 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UIfrn-0006Mc-Vh
	for commit-inetutils@gnu.org; Thu, 21 Mar 2013 13:49:16 +0000
Date: Thu, 21 Mar 2013 13:49:16 +0000
Message-Id: <E1UIfrn-0006Mc-Vh@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-260-g139b77d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 601105eae504371d873782596996c82899db897d
X-Git-Newrev: 139b77d07863a2620c63901681e6e20d2298a763
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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 Mar 2013 13:49:25 -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  139b77d07863a2620c63901681e6e20d2298a763 (commit)
      from  601105eae504371d873782596996c82899db897d (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=139b77d07863a2620c63901681e6e20d2298a763


commit 139b77d07863a2620c63901681e6e20d2298a763
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 21 14:47:12 2013 +0100

    ftpd: Portability of PAM to Solaris.

diff --git a/ChangeLog b/ChangeLog
index 180b2de..dc3c639 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-21  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftpd: Portability of PAM to Solaris.
+
+	* ftpd/pam.c: Include <unistd.h>.
+	(TTY_FORMAT): New macro.
+	(pam_user): New variable TTY_NAME.  Set PAM_TTY by calling
+	pam_set_item() with a value constructed from getpid().
+
 2013-03-19  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Support PAM beyond Linux-PAM.
diff --git a/ftpd/pam.c b/ftpd/pam.c
index 3a970a4..14ed2cb 100644
--- a/ftpd/pam.c
+++ b/ftpd/pam.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <syslog.h>
 #include <unused-parameter.h>
 #include "extern.h"
@@ -255,11 +256,14 @@ pam_doit (struct credentials *pcred)
   return (error != PAM_SUCCESS);
 }
 
+#define TTY_FORMAT "/dev/ftp%d"
+
 /* Non-zero return means failure. */
 int
 pam_user (const char *username, struct credentials *pcred)
 {
   int error;
+  char tty_name[strlen (TTY_FORMAT) + strlen ("9999999")];
 
   if (pamh != NULL)
     {
@@ -272,12 +276,16 @@ pam_user (const char *username, struct credentials *pcred)
   free (pcred->message);
   pcred->message = NULL;
 
+  (void) snprintf (tty_name, sizeof (tty_name), TTY_FORMAT, (int) getpid());
+
   /* 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);
+  if (error == PAM_SUCCESS)
+    error = pam_set_item (pamh, PAM_TTY, tty_name);
   if (error != PAM_SUCCESS)
     {
       pam_end (pamh, error);

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

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


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 22 05:36:28 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UIyOi-0007WO-Qf
	for mharc-commit-inetutils@gnu.org; Fri, 22 Mar 2013 05:36:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59689)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIyOe-0007Vb-7r
	for commit-inetutils@gnu.org; Fri, 22 Mar 2013 05:36:26 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIyOb-0004TK-O0
	for commit-inetutils@gnu.org; Fri, 22 Mar 2013 05:36:24 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38786)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1UIyOb-0004TC-KR
	for commit-inetutils@gnu.org; Fri, 22 Mar 2013 05:36:21 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1UIyOa-0003E3-Si
	for commit-inetutils@gnu.org; Fri, 22 Mar 2013 09:36:21 +0000
Date: Fri, 22 Mar 2013 09:36:20 +0000
Message-Id: <E1UIyOa-0003E3-Si@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-262-g2b21870
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 139b77d07863a2620c63901681e6e20d2298a763
X-Git-Newrev: 2b21870677d919c10c7a3fee1adf5b9ef03887ec
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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, 22 Mar 2013 09:36:27 -0000

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

The branch, master has been updated
       via  2b21870677d919c10c7a3fee1adf5b9ef03887ec (commit)
       via  18be9337a6af422b869b3e017852aa4a447ea1dd (commit)
      from  139b77d07863a2620c63901681e6e20d2298a763 (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=2b21870677d919c10c7a3fee1adf5b9ef03887ec


commit 2b21870677d919c10c7a3fee1adf5b9ef03887ec
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Mar 22 10:35:06 2013 +0100

    Detection of Kerberos5.

diff --git a/ChangeLog b/ChangeLog
index dc3c639..ea79052 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-03-22  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Detection of Kerberos5.
+
+	* configure.ac: Only search for Kerberos headers
+	if they were explicitly requested.
+	* telnet/utilities.c (printsub)
+	[AUTHENTICATION || ENCRYPTION]: Define BUF if
+	either macro is defined.
+	* telnetd/utility.c (printsub): Likewise.
+
 2013-03-21  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	ftpd: Portability of PAM to Solaris.
diff --git a/configure.ac b/configure.ac
index 4232703..2cdb1ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -339,6 +339,9 @@ if test "$enable_encryption" = yes \
       test "$enable_encryption" = yes \
       && test "$ac_cv_lib_des_des_key_sched" = yes \
       && AC_DEFINE([DES_ENCRYPTION])
+
+      AC_CHECK_HEADERS([com_err.h des.h kerberosIV/des.h \
+			kerberosIV/krb.h krb.h])
     fi
     ;;
   krb5)
@@ -348,6 +351,12 @@ if test "$enable_encryption" = yes \
     if test ".$LIBAUTH" != . ;then
       AC_DEFINE([KERBEROS])
       AC_DEFINE([KRB5])
+      save_CPPFLAGS=$CPPFLAGS
+      CPPFLAGS="$CPPFLAGS $INCAUTH"
+      AC_CHECK_HEADERS([com_err.h kerberosV/krb5.h krb5.h \
+			krb5/asn1.h krb5/crc-32.h krb5/ext-proto.h \
+			krb5/krb5.h krb5/los-proto.h])
+      CPPFLAGS=$save_CPPFLAGS
     fi
     ;;
   *)
@@ -599,16 +608,13 @@ AC_HEADER_STDC
 AC_HEADER_TIME
 AC_HEADER_DIRENT
 
-AC_CHECK_HEADERS([arpa/nameser.h com_err.h des.h errno.h fcntl.h features.h \
-		  glob.h kerberosIV/des.h kerberosIV/krb.h kerberosV/krb5.h \
-		  krb.h krb5.h krb5/asn1.h krb5/crc-32.h krb5/ext-proto.h \
-		  krb5/krb5.h krb5/los-proto.h \
-		  memory.h netinet/in_systm.h netinet/ip.h \
-                  netinet/ip_icmp.h netinet/ip_var.h \
-		  security/pam_appl.h \
-                  shadow.h stdarg.h stdlib.h string.h stropts.h sys/tty.h \
-                  sys/utsname.h sys/ptyvar.h sys/msgbuf.h sys/filio.h \
-                  sys/ioctl_compat.h sys/cdefs.h sys/stream.h sys/mkdev.h \
+AC_CHECK_HEADERS([arpa/nameser.h errno.h fcntl.h features.h \
+		  glob.h memory.h netinet/in_systm.h netinet/ip.h \
+		  netinet/ip_icmp.h netinet/ip_var.h \
+		  security/pam_appl.h shadow.h \
+		  stdarg.h stdlib.h string.h stropts.h sys/tty.h \
+		  sys/utsname.h sys/ptyvar.h sys/msgbuf.h sys/filio.h \
+		  sys/ioctl_compat.h sys/cdefs.h sys/stream.h sys/mkdev.h \
 		  sys/sockio.h sys/sysmacros.h sys/param.h sys/file.h \
 		  sys/proc.h sys/select.h sys/time.h sys/wait.h \
                   sys/resource.h \
diff --git a/telnet/utilities.c b/telnet/utilities.c
index 4da265a..f97646b 100644
--- a/telnet/utilities.c
+++ b/telnet/utilities.c
@@ -346,7 +346,7 @@ printsub (char direction, unsigned char *pointer, int length)
   register int i;
   extern int want_status_response;
 
-#if defined AUTHENTICATION && defined ENCRYPTION
+#if defined AUTHENTICATION || defined ENCRYPTION
   char buf[512];
 #endif
 
diff --git a/telnetd/utility.c b/telnetd/utility.c
index 5ca0430..3ef7962 100644
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -930,7 +930,7 @@ printsub (int direction, unsigned char *pointer, int length)
 {
   register int i = 0;
 
-#if defined AUTHENTICATION && defined ENCRYPTION
+#if defined AUTHENTICATION || defined ENCRYPTION
   unsigned char buf[512];
 #endif
 

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


commit 18be9337a6af422b869b3e017852aa4a447ea1dd
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 21 22:25:09 2013 +0100

    Documentation (silent change).

diff --git a/NEWS b/NEWS
index 2b814d9..8e8bcfb 100644
--- a/NEWS
+++ b/NEWS
@@ -21,15 +21,19 @@ Argument handling has been corrected to avoid some segfaults.
 * ping
 
 New switches `--ip-timestamp', `--mask', `-T/--tos' and `--ttl'.
+Can use file capabilities instead of suid-setting.
 
 * ping6
 
 New switches `--hoplimit/--ttl', `-T/--tos' and `-v/--verbose'.
+File capabilities are sufficient.
 
 * rcp
 
 Supports IPv6 and Shishi.  New switches `-4/--ipv4', `-6/--ipv6',
 `-k/--realm', `-K/--kerberos', and `-x/--encrypt'.
+A file capability like `cap_net_bind_service' can be applied
+instead of setuid installing the binary.
 
 * rexec
 
@@ -38,6 +42,8 @@ Supports IPv6.  New switches `-4/--ipv4', `-6/--ipv6', `-a/--ipany'
 * rlogin, rsh
 
 Support IPv6.  New switches `-4/--ipv4', `-6/--ipv6'.
+A file capability like `cap_net_bind_service' can be applied
+instead of setuid installing the binary.
 
 * syslogd
 
@@ -53,14 +59,17 @@ New switch `-k/--realm'.
 
 Default mode is now UDP, for better conformity with Unices.
 New switches `-f/--first-hop', `-g/--gateways', `-I/--icmp',
-`-m/--max-hop', `-t/--tos', and `-w/--wait'.
+`-m/--max-hop', `-t/--tos', and `-w/--wait'.  File capabilities
+suffice.
 
 * ftpd
 
-Full IPv6 support.  PAM support is restricted to Linux-PAM,
-since `pam_ftp.so' exists only there and our code depends on
-its response for handling anonymous users.  Server now accepts
-commands LPRT and LPSV.
+Full IPv6 support.  PAM support for Linux-PAM, OpenPAM,
+and Sun-PAM as service `ftp'.  Observe that the latter
+two implementations only affect non-anonymous access,
+since `pam_ftp.so' exists for Linux-PAM only, so the
+standard checks are enforced on `ftp/anonymous' as usual.
+Server now accepts commands LPRT and LPSV.
 
 * inetd
 
@@ -68,19 +77,21 @@ Service configuration now allows setting also the group.
 
 * rexecd
 
-Can be built with PAM support.  New option `-l/--logging'.
+Can be built with PAM support as service `rexec'.
+New option `-l/--logging'.
 
 * rlogind
 
-Support for IPv6.  Buildable with libwrap support for use in
-stand-alone daemon mode.  New switches `-4/--ipv4', `-6/--ipv6',
-and `-S/--server-principal'.
+Support for IPv6 and PAM as services `rlogin' and `krlogin'.
+Buildable with libwrap support for use in stand-alone daemon
+mode.  New switches `-4/--ipv4', `-6/--ipv6', and
+`-S/--server-principal'.
 
 * rshd
 
-Now has support for IPv6, PAM, and Shishi.  New switches
-`-k/--kerberos', `-S/--server-principal', `-v/--vacuous',
-and `-x/--encrypt'.
+Now has support for IPv6, PAM, and Shishi, with PAM services
+`rsh' and `krsh'.  New switches `-k/--kerberos',
+`-S/--server-principal', `-v/--vacuous', and `-x/--encrypt'.
 
 * talkd
 
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index 47ff6bf..33b779d 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -3414,10 +3414,11 @@ Only anonymous login is allowed.
 @opindex -a
 @opindex --auth
 Specify what authentication mechanism to use for incoming connections.
-Possible values are: @samp{kerberos}, @samp{kerberos5}, @samp{opie}
-and @samp{default}.
+Possible values are: @samp{kerberos}, @samp{kerberos5}, @samp{opie},
+@samp{pam}, and @samp{default}.
 
-Anonymous logins will continue to work when this option is used.
+Anonymous logins will continue to work when this option is used,
+unless the user @samp{ftp} is removed from the system.
 
 @item  -D
 @itemx --daemon
@@ -3484,8 +3485,20 @@ the file exists, @command{ftpd} displays it and exits.  If the file
 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
-case of the requests is ignored.
+If this server was compiled with PAM support, then any non-anonymous
+connection request will also be checked for settings pertaining to
+the PAM service @samp{ftp}, before finally being accepted.
+
+Linux-PAM is particular in that it also provides a module
+@samp{pam_ftp.so} influencing even anonymous access.
+By convention the present server relies on the functionality
+in that module when built on relevant systems.
+However, the module is known to be partially broken since
+ten years back, when one compares the claims in its manual page,
+so not all claimed trickery is available!
+
+The FTP server currently supports the following FTP requests.
+The letter case of any request is ignored.
 
 @multitable @columnfractions 0.3 0.7
 @headitem Request  @tab  Description
@@ -3964,6 +3977,11 @@ Fail any call asking for non-Kerberos authentication.
 @c Required  Require reverse resolving of a remote host IP.
 @end table
 
+Should @command{rshd} have been built with PAM support,
+it reads any setting specified for a service named either
+@samp{rsh} or @samp{krsh}, the latter name for clients
+seeking Kerberised authentication.
+
 @section Diagnostics
 
 Except for the last one listed below, all diagnostic messages are
@@ -4139,6 +4157,11 @@ This may impact response time and CPU utilization, but provides
 increased security.  Only for Kerberised mode of operation.
 @end table
 
+Should @command{rlogind} have been built with PAM support,
+it reads any setting specified for a service named either
+@samp{rlogin} or @samp{krlogin}, the latter name for clients
+using Kerberised authentication.
+
 @section Kerberos specific details
 
 The option @option{-k} is mandatory for Kerberised operation mode,

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

Summary of changes:
 ChangeLog          |   11 +++++++++++
 NEWS               |   35 +++++++++++++++++++++++------------
 configure.ac       |   26 ++++++++++++++++----------
 doc/inetutils.texi |   33 ++++++++++++++++++++++++++++-----
 telnet/utilities.c |    2 +-
 telnetd/utility.c  |    2 +-
 6 files changed, 80 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Mar 28 15:06:58 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ULIA6-0002zr-3X
	for mharc-commit-inetutils@gnu.org; Thu, 28 Mar 2013 15:06:58 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49665)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULIA1-0002zL-2q
	for commit-inetutils@gnu.org; Thu, 28 Mar 2013 15:06:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULI9y-0007yA-Ch
	for commit-inetutils@gnu.org; Thu, 28 Mar 2013 15:06:53 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56657)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULI9y-0007y5-7v
	for commit-inetutils@gnu.org; Thu, 28 Mar 2013 15:06:50 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1ULI9x-0002Bo-3W
	for commit-inetutils@gnu.org; Thu, 28 Mar 2013 19:06:49 +0000
Date: Thu, 28 Mar 2013 19:06:49 +0000
Message-Id: <E1ULI9x-0002Bo-3W@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-264-g3e5d87b
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2b21870677d919c10c7a3fee1adf5b9ef03887ec
X-Git-Newrev: 3e5d87b25b4c314a184a44489a61e776712e46f1
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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, 28 Mar 2013 19:06:56 -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  3e5d87b25b4c314a184a44489a61e776712e46f1 (commit)
       via  1054aa73549072527357795e6ac6fd641cc86c98 (commit)
      from  2b21870677d919c10c7a3fee1adf5b9ef03887ec (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=3e5d87b25b4c314a184a44489a61e776712e46f1


commit 3e5d87b25b4c314a184a44489a61e776712e46f1
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 28 18:29:57 2013 +0100

    telnet: Specify realm with Kerberos5.

diff --git a/ChangeLog b/ChangeLog
index ee6f6e4..398c7a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2013-03-28  Mats Erik Andersson  <gnu@gisladisker.se>
 
+	Let Telnet client override Kerberos5 realm.
+
+	* libtelnet/kerberos5.c (dest_realm): Rename from
+	previous `telnet_krb5_realm'.
+	* telnet/main.c (dest_realm) [KERBEROS || SHISHI]:
+	Expand scope from KRB4 to KERBEROS.
+	(argp_options) [KERBEROS || SHISHI] <-k/--realm>:
+	Likewise.
+	(parse_opt) [AUTHENTICATION && (KERBEROS || SHISHI)]
+	<case 'k'>: Likewise.
+
+2013-03-28  Mats Erik Andersson  <gnu@gisladisker.se>
+
 	Partial adaptions to Kerberos5, sufficient
 	to do some build and runtime testing, but
 	without encryption.
diff --git a/libtelnet/kerberos5.c b/libtelnet/kerberos5.c
index 1813806..7b41ae5 100644
--- a/libtelnet/kerberos5.c
+++ b/libtelnet/kerberos5.c
@@ -76,7 +76,7 @@ static krb5_ticket *ticket = NULL;	/* telnet matches the AP_REQ and
 
 krb5_keyblock *session_key = 0;
 char *telnet_srvtab = NULL;
-char *telnet_krb5_realm = NULL;
+char *dest_realm = NULL;
 
 # define DEBUG(c) if (auth_debug_mode) printf c
 
@@ -224,18 +224,18 @@ kerberos5_send (TN_Authenticator * ap)
       return 0;
     }
 
-  if (telnet_krb5_realm)
+  if (dest_realm)
     {
       krb5_data rdata;
 
-      rdata.length = strlen (telnet_krb5_realm);
+      rdata.length = strlen (dest_realm);
       rdata.data = malloc (rdata.length + 1);
       if (rdata.data == NULL)
 	{
 	  DEBUG (("telnet: Kerberos V5: could not allocate memory\r\n"));
 	  return 0;
 	}
-      strcpy (rdata.data, telnet_krb5_realm);
+      strcpy (rdata.data, dest_realm);
       krb5_princ_set_realm (telnet_context, creds.server, &rdata);
     }
 
diff --git a/telnet/main.c b/telnet/main.c
index 912090b..cda8edc 100644
--- a/telnet/main.c
+++ b/telnet/main.c
@@ -112,7 +112,7 @@ enum {
   OPTION_NOASYNCNET
 };
 
-#if defined KRB4 || defined SHISHI
+#if defined KERBEROS || defined SHISHI
 extern char *dest_realm;
 #endif
 
@@ -165,7 +165,7 @@ static struct argp_option argp_options[] = {
     "Authentication and Kerberos options:", GRID },
   { "disable-auth", 'X', "ATYPE", 0,
     "disable type ATYPE authentication", GRID+1 },
-# if defined KRB4 || defined SHISHI
+# if defined KERBEROS || defined SHISHI
   { "realm", 'k', "REALM", 0,
     "obtain tickets for the remote host in REALM "
     "instead of the remote host's realm", GRID+1 },
@@ -263,7 +263,7 @@ parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
 #endif
 
 #if defined AUTHENTICATION && \
-      ( defined KRB4 || defined SHISHI )
+      ( defined KERBEROS || defined SHISHI )
     case 'k':
       dest_realm = arg;
       break;

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


commit 1054aa73549072527357795e6ac6fd641cc86c98
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Mar 28 16:44:21 2013 +0100

    Partial adaptions to Kerberos5.

diff --git a/ChangeLog b/ChangeLog
index ea79052..ee6f6e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2013-03-28  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Partial adaptions to Kerberos5, sufficient
+	to do some build and runtime testing, but
+	without encryption.
+
+	* configure.ac <KERBEROS_VERSION == krb5>:
+	Disable `rcp', `rlogin', and `rsh'.
+	* libinetutils/des_rw.c [ENCRYPTION && KRB4]:
+	Replace KERBEROS by KRB4 in guard.
+	* libinetutils/kcmd.c, libinetutils/krcmd.c:
+	Likewise.
+	* src/rlogind.c [KRB5 && HAVE_COM_ERR_H]:
+	Include <com_err.h>.
+	(do_krb5_login) [KRB5]: Insert prototype.
+	* src/rshd.c [KRB4]: Replace previous KERBEROS
+	by KRB4 throughout.
+	[KRB5 && HAVE_KRB5_H]: Include <krb5.h>.
+	[KRB5 && HAVE_COM_ERR_H]: Include <com_err.h>.
+	(doit) [KRB5]: New partial template code and
+	related variables for later refinement.
+	[KERBEROS]: Set FROMADDR using memcpy().
+	[ENCRYPTION && (KERBEROS || SHISHI)]: Call dup2()
+	with macros STDIN_FILENO and STDOUT_FILENO.
+
+	Replace obsolete interfaces.
+
+	* libtelnet/kerberos5.c (encryption_init)
+	[ENCRYPTION]: Call krb5_auth_con_getsendsubkey().
+	(kerberos5_is_auth): New variable VALID.
+	Call krb5_auth_con_getrecvsubkey().
+
+	* src/rlogind.c (do_shishi_login) [SHISHI]:
+	Test macro ENCRYPT_IO when calling syslog().
+
+	* configure.ac <rsh summary>: Use $rsh_BUILD.
+
 2013-03-22  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Detection of Kerberos5.
diff --git a/configure.ac b/configure.ac
index 2cdb1ab..68579e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -357,6 +357,11 @@ if test "$enable_encryption" = yes \
 			krb5/asn1.h krb5/crc-32.h krb5/ext-proto.h \
 			krb5/krb5.h krb5/los-proto.h])
       CPPFLAGS=$save_CPPFLAGS
+      # We have no support for krcmd() with Kerberos5.
+      # Encryption must be sorted out as a first step.
+      IU_DISABLE_TARGET(rcp)
+      IU_DISABLE_TARGET(rlogin)
+      IU_DISABLE_TARGET(rsh)
     fi
     ;;
   *)
@@ -1026,7 +1031,7 @@ ${rcp_BUILD:+$KERBEROS_VERSION}
     rlogin         ${enable_rlogin}  \
 ${rlogin_BUILD:+$KERBEROS_VERSION}
     rsh            ${enable_rsh}  \
-${rshd_BUILD:+$KERBEROS_VERSION}
+${rsh_BUILD:+$KERBEROS_VERSION}
     talk           ${enable_talk}  \
 ${talk_BUILD:+$LIBCURSES}
     telnet         ${enable_telnet}  \
diff --git a/libinetutils/des_rw.c b/libinetutils/des_rw.c
index 464753e..9485f45 100644
--- a/libinetutils/des_rw.c
+++ b/libinetutils/des_rw.c
@@ -50,7 +50,7 @@
 #include <config.h>
 
 #ifdef ENCRYPTION
-# ifdef KERBEROS
+# ifdef KRB4
 #  include <sys/param.h>
 
 #  ifdef HAVE_KERBEROSIV_DES_H
@@ -208,5 +208,5 @@ des_write (fd, buf, len)
   write (fd, des_outbuf, roundup (len, 8));
   return (len);
 }
-# endif	/* KERBEROS */
+# endif	/* KRB4 */
 #endif /* CRYPT */
diff --git a/libinetutils/kcmd.c b/libinetutils/kcmd.c
index 0e280fe..325c92b 100644
--- a/libinetutils/kcmd.c
+++ b/libinetutils/kcmd.c
@@ -49,7 +49,7 @@
 
 #include <config.h>
 
-#if defined KERBEROS || defined SHISHI
+#if defined KRB4 || defined SHISHI
 
 # include <sys/param.h>
 # include <sys/file.h>
diff --git a/libinetutils/krcmd.c b/libinetutils/krcmd.c
index 4611273..76f28aa 100644
--- a/libinetutils/krcmd.c
+++ b/libinetutils/krcmd.c
@@ -49,7 +49,7 @@
 
 #include <config.h>
 
-#if defined KERBEROS || defined SHISHI
+#if defined KRB4 || defined SHISHI
 # include <sys/types.h>
 # ifdef ENCRYPTION
 #  include <sys/socket.h>
diff --git a/libtelnet/kerberos5.c b/libtelnet/kerberos5.c
index 3649c0c..1813806 100644
--- a/libtelnet/kerberos5.c
+++ b/libtelnet/kerberos5.c
@@ -154,7 +154,7 @@ encryption_init (krb5_creds * creds)
 {
   krb5_keyblock *newkey = 0;
 
-  krb5_auth_con_getlocalsubkey (telnet_context, auth_context, &newkey);
+  krb5_auth_con_getsendsubkey (telnet_context, auth_context, &newkey);
   if (session_key)
     {
       krb5_free_keyblock (telnet_context, session_key);
@@ -547,6 +547,7 @@ kerberos5_is_auth (TN_Authenticator * ap, unsigned char *data, int cnt,
       char type_check[2];
       krb5_checksum *cksum = authenticator->checksum;
       krb5_keyblock *key;
+      krb5_boolean valid;
 
       type_check[0] = ap->type;
       type_check[1] = ap->way;
@@ -559,9 +560,12 @@ kerberos5_is_auth (TN_Authenticator * ap, unsigned char *data, int cnt,
 	  return 1;
 	}
 
+#  if 1
+      /* XXX: Obsolete interface.  Remove after investigation.  */
       r = krb5_verify_checksum (telnet_context,
 				cksum->checksum_type, cksum,
 				&type_check, 2, key->contents, key->length);
+      krb5_free_keyblock (telnet_context, key);
 
       if (r)
 	{
@@ -569,7 +573,24 @@ kerberos5_is_auth (TN_Authenticator * ap, unsigned char *data, int cnt,
 		    "checksum verification failed: %s", error_message (r));
 	  return 1;
 	}
+#else
+      /* Incomplete call!
+       *
+       * XXX: Establish replacement for the preceding call.
+       *      It is no longer present in all implementations.
+       */
+      r = krb5_c_verify_checksum (telnet_context, key,
+				  /* usage */, /* data */,
+				  cksum, &valid);
       krb5_free_keyblock (telnet_context, key);
+
+      if (r || !valid)
+	{
+	  snprintf (errbuf, errbuflen,
+		    "checksum verification failed: %s", error_message (r));
+	  return 1;
+	}
+#endif
     }
 
   krb5_free_authenticator (telnet_context, authenticator);
@@ -594,7 +615,7 @@ kerberos5_is_auth (TN_Authenticator * ap, unsigned char *data, int cnt,
   auth_finished (ap, AUTH_USER);
 
   free (name);
-  krb5_auth_con_getremotesubkey (telnet_context, auth_context, &newkey);
+  krb5_auth_con_getrecvsubkey (telnet_context, auth_context, &newkey);
 
   if (session_key)
     {
diff --git a/src/rlogind.c b/src/rlogind.c
index 23e22fb..4772026 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -163,6 +163,9 @@
 #  ifdef HAVE_KRB5_H
 #   include <krb5.h>
 #  endif
+#  ifdef HAVE_COM_ERR_H
+#   include <com_err.h>
+#  endif
 #  ifdef HAVE_KERBEROSIV_KRB_H
 #   include <kerberosIV/krb.h>
 #  endif
@@ -243,10 +246,10 @@ char *servername = NULL;
 # ifdef ENCRYPTION
 int encrypt_io = 0;
 # endif	/* ENCRYPTION */
-#endif /* KERBEROS */
+#endif /* KERBEROS || SHISHI */
+
 int reverse_required = 0;
 int debug_level = 0;
-
 int numchildren;
 int netf;
 char line[1024];		/* FIXME */
@@ -287,6 +290,10 @@ void rlogind_error (int f, int syserr, const char *msg, ...);
 int in_local_domain (char *hostname);
 char *topdomain (char *name, int max_dots);
 
+#ifdef KRB5
+int do_krb5_login (int infd, struct auth_data *ap, const char **err_msg);
+#endif
+
 #ifdef SHISHI
 int do_shishi_login (int infd, struct auth_data *ad, const char **err_msg);
 #endif
@@ -1707,7 +1714,7 @@ do_shishi_login (int infd, struct auth_data *ad, const char **err_msg)
 
   syslog (LOG_INFO | LOG_AUTH,
 	  "Kerberos V %slogin from %s on %s as `%s'.\n",
-	  encrypt_io ? "encrypted " : "",
+	  ENCRYPT_IO ? "encrypted " : "",
 	  ad->rusername, ad->hostname, ad->lusername);
 
   return SHISHI_OK;
diff --git a/src/rshd.c b/src/rshd.c
index 5ed460e..5e0b54a 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -149,14 +149,22 @@
 #ifdef HAVE_SECURITY_PAM_APPL_H
 # include <security/pam_appl.h>
 #endif
-#ifdef KERBEROS
+
+#ifdef KRB4
 # ifdef HAVE_KERBEROSIV_DES_H
 #  include <kerberosIV/des.h>
 # endif
 # ifdef HAVE_KERBEROSIV_KRB_H
 #  include <kerberosIV/krb.h>
 # endif
-#endif /* KERBEROS */
+#elif defined KRB5	/* !KRB4 */
+# ifdef HAVE_KRB5_H
+#  include <krb5.h>
+# endif
+# ifdef HAVE_COM_ERR_H
+#  include <com_err.h>
+# endif
+#endif /* KRB4 || KRB5 */
 
 #ifdef SHISHI
 # include <shishi.h>
@@ -188,10 +196,11 @@ static struct pam_conv pam_conv = { rsh_conv, NULL };
 #endif /* WITH_PAM */
 
 #if defined KERBEROS || defined SHISHI
-# ifdef KERBEROS
+# ifdef KRB4
 Key_schedule schedule;
 char authbuf[sizeof (AUTH_DAT)];
 char tickbuf[sizeof (KTEXT_ST)];
+# elif defined KRB5
 # elif defined(SHISHI)
 Shishi *h;
 Shishi_ap *ap;
@@ -235,7 +244,7 @@ static struct argp_option options[] = {
     "fail for non-encrypted, Kerberized sessions", GRP },
 # endif
 # undef GRP
-#endif /* KERBEROS */
+#endif /* KERBEROS || SHISHI */
   { NULL, 0, NULL, 0, NULL, 0 }
 };
 
@@ -432,15 +441,23 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 #endif
 
 #ifdef	KERBEROS
+# ifdef KRB4
   AUTH_DAT *kdata = (AUTH_DAT *) NULL;
   KTEXT ticket = (KTEXT) NULL;
   char instance[INST_SZ], version[VERSION_SIZE];
+# elif defined KRB5	/* !KRB4 */
+  krb5_context context;
+  krb5_auth_context auth_ctx;
+  krb5_authenticator *author;
+  krb5_principal client;
+  krb5_rcache rcache;
+  krb5_keytab keytab;
+  krb5_ticket *ticket;
+# endif /* KRB4 || KRB5 */
   struct sockaddr_in fromaddr;
   long authopts;
   int pv1[2], pv2[2];
   fd_set wready, writeto;
-
-  fromaddr = *fromp;
 #elif defined SHISHI /* !KERBEROS */
   int n;
   int pv1[2], pv2[2];
@@ -451,6 +468,10 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
   char *cksum = NULL;
 #endif /* KERBEROS || SHISHI */
 
+#ifdef KERBEROS
+  memcpy (&fromaddr, fromp, sizeof (fromaddr));
+#endif
+
 #ifdef HAVE_GETPWNAM_R
   pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
   if (pwbuflen <= 0)
@@ -800,7 +821,7 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
   else
     errorhost = hostname = addrstr;
 
-#ifdef	KERBEROS
+#ifdef KRB4
   if (use_kerberos)
     {
       kdata = (AUTH_DAT *) authbuf;
@@ -840,7 +861,82 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 	}
     }
   else
-#elif defined (SHISHI) /* !KERBEROS */
+#elif defined KRB5
+  if (use_kerberos)
+    {
+      /* Set up context data.  */
+      rc = krb5_init_context (&context);
+      if (!rc)
+        rc = krb5_auth_con_init (context, &auth_ctx);
+      if (!rc)
+	rc = krb5_auth_con_genaddrs (context, auth_ctx, sockfd,
+			KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
+      if (!rc)
+	rc = krb5_auth_con_getrcache (context, auth_ctx, &rcache);
+
+      if (!rc && !rcache)
+	{
+	  krb5_principal server;
+
+	  rc = krb5_sname_to_principal (context, 0, 0,
+					KRB5_NT_SRV_HST, &server);
+	  if (!rc)
+	    {
+	      krb5_data *pdata;
+
+	      pdata = krb5_princ_component (context, server, 0);
+
+	      rc = krb5_get_server_rcache (context, pdata, &rcache);
+	      krb5_free_principal (context, server);
+
+	      if (!rc)
+		rc = krb5_auth_con_setrcache (context, auth_ctx, rcache);
+	    }
+	}
+
+      if (rc)
+	{
+	  syslog (LOG_ERR, "Error initializing krb5: %s",
+		  error_message (rc));
+	  rshd_error ("Permission denied.\n");
+	  exit (EXIT_FAILURE);
+	}
+
+# ifdef ENCRYPTION
+      if (doencrypt)
+	{
+	  struct sockaddr_in local_addr;
+	  rc = sizeof local_addr;
+	  if (getsockname (STDIN_FILENO,
+			   (struct sockaddr *) &local_addr, &rc) < 0)
+	    {
+	      syslog (LOG_ERR, "getsockname: %m");
+	      rshd_error ("rlogind: getsockname: %s", strerror (errno));
+	      exit (EXIT_FAILURE);
+	    }
+	  authopts = KOPT_DO_MUTUAL;
+	  rc = krb_recvauth (authopts, 0, ticket,
+			     "rcmd", instance, &fromaddr,
+			     &local_addr, kdata, "", schedule, version);
+	  des_set_key (kdata->session, schedule);
+	}
+      else
+# endif /* ENCRYPTION */
+	rc = krb5_recvauth (context, &auth_ctx, &sockfd, "rcmd",
+			    0, 0, keytab, &ticket);
+
+      if (!rc)
+	rc = krb5_auth_con_getauthenticator (context, auth_ctx, &author);
+
+      if (!rc)
+	{
+	  rshd_error ("Kerberos authentication failure: %s\n",
+		      error_message(rc));
+	  exit (EXIT_FAILURE);
+	}
+    }
+  else
+#elif defined (SHISHI)	/* !KRB4 && !KRB5 */
   if (use_kerberos)
     {
       int rc;
@@ -1002,7 +1098,16 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
     shishi_ap_done (ap);
 
   }
-#endif /* SHISHI */
+#elif defined KRB5	/* !SHISHI */
+  if (use_kerberos)
+    {
+      remuser = getstr ("remuser");	/* The requesting user!  */
+
+      rc = krb5_copy_principal (context, ticket->enc_part2->client,
+				&client);
+
+    }
+#endif /* KRB5 || SHISHI */
 
   /* Look up locuser in the passwd file.  The locuser has to be a
    * valid account on this system.
@@ -1132,7 +1237,7 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
       }
 #endif
 
-#ifdef	KERBEROS
+#ifdef KRB4
   if (use_kerberos)
     {
       if (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0')
@@ -1147,6 +1252,21 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 	}
     }
   else
+#elif defined KRB5	/* !KRB4 */
+  if (use_kerberos)
+    {
+      if (pwd->pw_passwd != 0 && *pwd->pw_passwd != '\0' && client)
+	{
+	  if (krb5_kuserok (context, client, locuser) != 0)
+	    {
+	      syslog (LOG_INFO | LOG_AUTH, "Kerberos rsh denied to %s.%s@%s",
+		      "kdata->pname", "kdata->pinst", "kdata->prealm");
+	      rshd_error ("Permission denied.\n");
+	      exit (EXIT_FAILURE);
+	    }
+	}
+    }
+  else
 #elif defined(SHISHI) /* !KERBEROS */
   if (use_kerberos)
     {				/*
@@ -1487,8 +1607,8 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
 	{
 	  close (pv1[0]);
 	  close (pv2[0]);
-	  dup2 (pv1[1], 1);
-	  dup2 (pv2[1], 0);
+	  dup2 (pv1[1], STDOUT_FILENO);
+	  dup2 (pv2[1], STDIN_FILENO);
 	  close (pv1[1]);
 	  close (pv2[1]);
 	}
@@ -1636,14 +1756,14 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
   endpwent ();
   if (log_success || pwd->pw_uid == 0)
     {
-#ifdef	KERBEROS
+#ifdef KRB4
       if (use_kerberos)
 	syslog (LOG_INFO | LOG_AUTH,
 		"Kerberos shell from %s.%s@%s on %s as %s, cmd='%.80s'",
 		kdata->pname, kdata->pinst, kdata->prealm,
 		hostname, locuser, cmdbuf);
       else
-#endif /* KERBEROS */
+#endif /* KRB4 */
 	syslog (LOG_INFO | LOG_AUTH,
 		"%s%s@%s as %s: cmd='%.80s'",
 #ifdef SHISHI

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

Summary of changes:
 ChangeLog             |   50 +++++++++++++++++
 configure.ac          |    7 ++-
 libinetutils/des_rw.c |    4 +-
 libinetutils/kcmd.c   |    2 +-
 libinetutils/krcmd.c  |    2 +-
 libtelnet/kerberos5.c |   33 +++++++++--
 src/rlogind.c         |   13 +++-
 src/rshd.c            |  148 ++++++++++++++++++++++++++++++++++++++++++++-----
 telnet/main.c         |    6 +-
 9 files changed, 234 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Mar 29 19:21:10 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ULibe-0002CE-Al
	for mharc-commit-inetutils@gnu.org; Fri, 29 Mar 2013 19:21:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37635)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULibW-0002BZ-1F
	for commit-inetutils@gnu.org; Fri, 29 Mar 2013 19:21:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULibU-0003Qq-68
	for commit-inetutils@gnu.org; Fri, 29 Mar 2013 19:21:01 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48622)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1ULibU-0003QZ-2A
	for commit-inetutils@gnu.org; Fri, 29 Mar 2013 19:21:00 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1ULibT-0005N6-6s
	for commit-inetutils@gnu.org; Fri, 29 Mar 2013 23:20:59 +0000
Date: Fri, 29 Mar 2013 23:20:59 +0000
Message-Id: <E1ULibT-0005N6-6s@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1-265-gc2c33de
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3e5d87b25b4c314a184a44489a61e776712e46f1
X-Git-Newrev: c2c33de07f6497883d4d5200f62a7798f3371db4
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
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, 29 Mar 2013 23:21:08 -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  c2c33de07f6497883d4d5200f62a7798f3371db4 (commit)
      from  3e5d87b25b4c314a184a44489a61e776712e46f1 (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=c2c33de07f6497883d4d5200f62a7798f3371db4


commit c2c33de07f6497883d4d5200f62a7798f3371db4
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Mar 30 00:16:37 2013 +0100

    Configuration summary.

diff --git a/ChangeLog b/ChangeLog
index 398c7a3..39bcba7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-30  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	* configure.ac <summary>: New variables `*_PROPS'
+	for each targeted executable.  Set the likes of
+	`ftp_PROPS' and use them to simplify output.
+
 2013-03-28  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Let Telnet client override Kerberos5 realm.
diff --git a/configure.ac b/configure.ac
index 68579e3..6b5fd39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1010,52 +1010,86 @@ confpaths.h:confpaths.h.in
 ])
 AC_OUTPUT
 
+# Collect printable information on each
+# available (i.e., reportable) target.
+#
+# Group similar properties and append
+# by succession in an orderly manner.
+
+# Kerberised services.
+
+rcp_PROPS=$KERBEROS_VERSION
+rlogin_PROPS=$KERBEROS_VERSION
+rlogind_PROPS=$KERBEROS_VERSION
+rsh_PROPS=$KERBEROS_VERSION
+rshd_PROPS=$KERBEROS_VERSION
+telnet_PROPS=$KERBEROS_VERSION
+telnetd_PROPS=$KERBEROS_VERSION
+
+# PAM enabled services.
+
+ftpd_PROPS="${ftpd_PROPS:+$ftpd_PROPS }${FTPD_LIBPAM:+PAM}"
+rexecd_PROPS="${rexecd_PROPS:+$rexecd_PROPS }${LIBPAM:+PAM}"
+rlogind_PROPS="${rlogind_PROPS:+$rlogind_PROPS }${LIBPAM:+PAM}"
+rshd_PROPS="${rshd_PROPS:+$rshd_PROPS }${LIBPAM:+PAM}"
+
+# Support for libwrap.
+
+ftpd_PROPS="${ftpd_PROPS:+$ftpd_PROPS }$LIBWRAP"
+rlogind_PROPS="${rlogind_PROPS:+$rlogind_PROPS }$LIBWRAP"
+
+# Support for libidn.
+
+ping_PROPS="${ping_PROPS:+$ping_PROPS }${LIBIDN:+-libidn}"
+traceroute_PROPS="${traceroute_PROPS:+$traceroute_PROPS }${LIBIDN:+-libidn}"
+
+# Termcap variants.
+
+ftp_PROPS="${ftp_PROPS:+$ftp_PROPS }$LIBTERMCAP"
+telnet_PROPS="${telnet_PROPS:+$telnet_PROPS }$LIBTERMCAP"
+telnetd_PROPS="${telnetd_PROPS:+$telnetd_PROPS }$LIBTERMCAP"
+
+# Readline variants.
+
+ftp_PROPS="${ftp_PROPS:+$ftp_PROPS }$LIBREADLINE"
+
+# Variants of libcurses.
+
+talk_PROPS="${talk_PROPS:+$talk_PROPS }$LIBCURSES"
+
 # Collect informational status.
 AC_MSG_NOTICE([summary of build decisions:
 
   Clients:
 
     dnsdomainname  ${enable_dnsdomainname}
-    ftp            ${enable_ftp}  \
-${ftp_BUILD:+${LIBREADLINE:+$LIBREADLINE }$LIBTERMCAP}
+    ftp            ${enable_ftp}${ftp_BUILD:+  $ftp_PROPS}
     hostname       ${enable_hostname}
     ifconfig       ${enable_ifconfig}
     logger         ${enable_logger}
-    ping           ${enable_ping}  \
-${ping_BUILD:+${LIBIDN:+-libidn}}
-    ping6          ${enable_ping6}  \
-${ping6_BUILD:+${LIBIDN:+-libidn}}
-    rcp            ${enable_rcp}  \
-${rcp_BUILD:+$KERBEROS_VERSION}
+    ping           ${enable_ping}${ping_BUILD:+  $ping_PROPS}
+    ping6          ${enable_ping6}${ping6_BUILD:+  $ping_PROPS}
+    rcp            ${enable_rcp}${rcp_BUILD:+  $rcp_PROPS}
     rexec          ${enable_rexec}
-    rlogin         ${enable_rlogin}  \
-${rlogin_BUILD:+$KERBEROS_VERSION}
-    rsh            ${enable_rsh}  \
-${rsh_BUILD:+$KERBEROS_VERSION}
-    talk           ${enable_talk}  \
-${talk_BUILD:+$LIBCURSES}
-    telnet         ${enable_telnet}  \
-${telnet_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }$LIBTERMCAP}
+    rlogin         ${enable_rlogin}${rlogin_BUILD:+  $rlogin_PROPS}
+    rsh            ${enable_rsh}${rsh_BUILD:+  $rsh_PROPS}
+    talk           ${enable_talk}${talk_BUILD:+  $talk_PROPS}
+    telnet         ${enable_telnet}${telnet_BUILD:+  $telnet_PROPS}
     tftp           ${enable_tftp}
-    traceroute     ${enable_traceroute}  \
-${traceroute_BUILD:+${LIBIDN:+-libidn}}
+    traceroute     ${enable_traceroute}\
+${traceroute_BUILD:+  $traceroute_PROPS}
     whois          ${enable_whois}
 
   Servers:
 
-    ftpd           ${enable_ftpd}  \
-${ftpd_BUILD:+${FTPD_LIBPAM:+PAM }$LIBWRAP}
+    ftpd           ${enable_ftpd}${ftpd_BUILD:+  $ftpd_PROPS}
     inetd          ${enable_inetd}
-    rexecd         ${enable_rexecd}  \
-${rexecd_BUILD:+${LIBPAM:+PAM}}
-    rlogind        ${enable_rlogind}  \
-${rlogind_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }${LIBPAM:+PAM }$LIBWRAP}
-    rshd           ${enable_rshd}  \
-${rshd_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }${LIBPAM:+PAM}}
+    rexecd         ${enable_rexecd}${rexecd_BUILD:+  $rexecd_PROPS}
+    rlogind        ${enable_rlogind}${rlogind_BUILD:+  $rlogind_PROPS}
+    rshd           ${enable_rshd}${rshd_BUILD:+  $rshd_PROPS}
     syslogd        ${enable_syslogd}
     talkd          ${enable_talkd}
-    telnetd        ${enable_telnetd}  \
-${telnetd_BUILD:+${KERBEROS_VERSION:+$KERBEROS_VERSION }$LIBTERMCAP}
+    telnetd        ${enable_telnetd}${telnetd_BUILD:+  $telnetd_PROPS}
     tftpd          ${enable_tftpd}
     uucpd          ${enable_uucpd}
 ])

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

Summary of changes:
 ChangeLog    |    6 ++++
 configure.ac |   90 ++++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 68 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


