From MAILER-DAEMON Thu Nov 07 13:46:59 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1VeUbb-0005dI-Q9
	for mharc-commit-inetutils@gnu.org; Thu, 07 Nov 2013 13:46:59 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50024)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VeUbU-0005V9-QM
	for commit-inetutils@gnu.org; Thu, 07 Nov 2013 13:46:57 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VeUbR-00018f-Py
	for commit-inetutils@gnu.org; Thu, 07 Nov 2013 13:46:52 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39579)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VeUbR-00018b-MP
	for commit-inetutils@gnu.org; Thu, 07 Nov 2013 13:46:49 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1VeUbR-0007Tf-8M
	for commit-inetutils@gnu.org; Thu, 07 Nov 2013 18:46:49 +0000
Date: Thu, 07 Nov 2013 18:46:49 +0000
Message-Id: <E1VeUbR-0007Tf-8M@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1_100-11-g804f20e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f475b43550975cf05f7a06c35b0e4d0506d47c5f
X-Git-Newrev: 804f20e073d6ec39e60796ee49f1e26f82a19959
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, 07 Nov 2013 18:46:58 -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  804f20e073d6ec39e60796ee49f1e26f82a19959 (commit)
      from  f475b43550975cf05f7a06c35b0e4d0506d47c5f (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=804f20e073d6ec39e60796ee49f1e26f82a19959


commit 804f20e073d6ec39e60796ee49f1e26f82a19959
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue Nov 5 19:42:51 2013 +0100

    Detection of readline.

diff --git a/ChangeLog b/ChangeLog
index d954b04..40f0f1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-11-05  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Improve detection of readline.
+
+	* am/readline.m4 (gl_FUNC_READLINE): Check for libedit
+	with AC_LIB_LINKFLAGS_BODY and with AC_CACHE_CHECK.
+	<readline in libreadline>: Ignore <editline/readline.h>.
+	<readline in libedit>: Prefer <editline/readline.h>.
+	Define HAVE_READLINE if readline() was located in one of
+	the libraries, and if its use had not been disabled.
+	Define HAVE_LIBREADLINE and HAVE_LIBEDIT if it was found
+	in the corresponding library.
+	* ftp/Makefile.am (LDADD): Remove $(LIBGLOB), $(LIBTERMCAP).
+	The latter is handled by LIBREADLINE.
+
+	* configure.ac (ftp_PROPS): Do not add $LIBTERMCAP.
+
 2013-10-16  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	syslogd, talkd: Act on failed read_utmp.
diff --git a/am/readline.m4 b/am/readline.m4
index 56cf01a..49f1047 100644
--- a/am/readline.m4
+++ b/am/readline.m4
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_READLINE],
   dnl Allow disabling the use of libreadline.
   AC_ARG_ENABLE([readline],
     AS_HELP_STRING([--disable-readline],
-		   [do not build against libreadline]), ,
+		   [do not build against libreadline or libedit]), ,
     [enable_readline=yes])
 
   dnl Readline libraries come in a handful flavours.
@@ -28,6 +28,7 @@ AC_DEFUN([gl_FUNC_READLINE],
   dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
   dnl INCREADLINE accordingly.
   AC_LIB_LINKFLAGS_BODY([readline])
+  AC_LIB_LINKFLAGS_BODY([edit])
 
   dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
   dnl because if the user has installed libreadline and not disabled its use
@@ -36,7 +37,7 @@ AC_DEFUN([gl_FUNC_READLINE],
   am_save_CPPFLAGS="$CPPFLAGS"
   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
 
-  AC_CACHE_CHECK([for readline], [gl_cv_lib_readline], [
+  AC_CACHE_CHECK([for libreadline], [gl_cv_lib_readline], [
     gl_cv_lib_readline=no
     am_save_LIBS="$LIBS"
     dnl On some systems, -lreadline doesn't link without an additional
@@ -52,8 +53,6 @@ AC_DEFUN([gl_FUNC_READLINE],
       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
 #ifdef HAVE_READLINE_READLINE_H
 # include <readline/readline.h>
-#elif defined HAVE_EDITLINE_READLINE_H
-# include <editline/readline.h>
 #endif]],
           [[readline((char*)0);]])],
         [if test -n "$extra_lib"; then
@@ -72,24 +71,34 @@ AC_DEFUN([gl_FUNC_READLINE],
   dnl In case of failure, examine whether libedit can act
   dnl as replacement. Small NetBSD systems use editline
   dnl as wrapper for readline.
-  if test "$gl_cv_lib_readline" = no; then
+  CPPFLAGS="$am_save_CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCEDIT])
+
+  AC_CACHE_CHECK([for libedit], [gl_cv_lib_edit], [
+    gl_cv_lib_edit=no
     am_save_LIBS="$LIBS"
     LIBS="$am_save_LIBS -ledit"
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-#ifdef HAVE_READLINE_READLINE_H
-# include <readline/readline.h>
-#elif defined HAVE_EDITLINE_READLINE_H
+#ifdef HAVE_EDITLINE_READLINE_H
 # include <editline/readline.h>
+#elif defined HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
 #endif]],
         [[readline((char*)0);]])],
-      [gl_cv_lib_readline="yes"])
+      [gl_cv_lib_edit="yes"])
     LIBS="$am_save_LIBS"
-    LIBREADLINE=-ledit
+  ])
+
+  dnl Is the function readline() available?
+  if ( test "$gl_cv_lib_readline" != no || test "$gl_cv_lib_edit" != no ) \
+     && test "$enable_readline" = yes; then
+    AC_DEFINE([HAVE_READLINE], [1], [Define if you have a readline function.])
   fi
 
+  dnl Identify the available implementation.
   if test "$enable_readline" = "yes" \
      && test "$gl_cv_lib_readline" != no; then
-    AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.])
+    AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have the readline library.])
     extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'`
     if test -n "$extra_lib"; then
       LIBREADLINE="$LIBREADLINE $extra_lib"
@@ -97,12 +106,23 @@ AC_DEFUN([gl_FUNC_READLINE],
     fi
     AC_MSG_CHECKING([how to link with libreadline])
     AC_MSG_RESULT([$LIBREADLINE])
+  elif test "$enable_readline" = "yes" \
+     && test "$gl_cv_lib_edit" != no; then
+    AC_DEFINE([HAVE_LIBEDIT], [1], [Define if you have the edit library.])
+
+    dnl We have a working replacement for libreadline, so use it.
+    LIBREADLINE="$LIBEDIT"
+    LTLIBREADLINE="$LTLIBEDIT"
+    AC_MSG_CHECKING([how to link with libedit])
+    AC_MSG_RESULT([$LIBEDIT])
   else
     dnl If $LIBREADLINE didn't lead to a usable library, we don't
     dnl need $INCREADLINE either.
     CPPFLAGS="$am_save_CPPFLAGS"
     LIBREADLINE=
     LTLIBREADLINE=
+    LIBEDIT=
+    LTLIBEDIT=
   fi
   AC_SUBST([LIBREADLINE])
   AC_SUBST([LTLIBREADLINE])
diff --git a/configure.ac b/configure.ac
index 229f814..79a6776 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1057,7 +1057,6 @@ traceroute_PROPS="${traceroute_PROPS:+$traceroute_PROPS }${LIBIDN:+-lidn}"
 
 # Termcap variants.
 
-ftp_PROPS="${ftp_PROPS:+$ftp_PROPS }$LIBTERMCAP"
 telnet_PROPS="${telnet_PROPS:+$telnet_PROPS }$LIBTERMCAP"
 telnetd_PROPS="${telnetd_PROPS:+$telnetd_PROPS }$LIBTERMCAP"
 
diff --git a/ftp/Makefile.am b/ftp/Makefile.am
index 5589154..4542784 100644
--- a/ftp/Makefile.am
+++ b/ftp/Makefile.am
@@ -27,7 +27,7 @@ AM_CPPFLAGS = \
 
 LDADD = \
 	$(iu_LIBRARIES) \
-	$(LIBGLOB) $(LIBREADLINE) $(LIBTERMCAP) $(LIBHISTORY) \
+	$(LIBREADLINE) $(LIBHISTORY) \
 	$(LIBIDN)
 
 bin_PROGRAMS = $(ftp_BUILD)

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

Summary of changes:
 ChangeLog       |   17 +++++++++++++++++
 am/readline.m4  |   42 +++++++++++++++++++++++++++++++-----------
 configure.ac    |    1 -
 ftp/Makefile.am |    2 +-
 4 files changed, 49 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri Nov 15 13:30:45 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1VhOAH-0003tj-38
	for mharc-commit-inetutils@gnu.org; Fri, 15 Nov 2013 13:30:45 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60082)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VhOAE-0003s4-Ny
	for commit-inetutils@gnu.org; Fri, 15 Nov 2013 13:30:43 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VhOAD-0006VE-Aw
	for commit-inetutils@gnu.org; Fri, 15 Nov 2013 13:30:42 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:52514)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1VhOAD-0006Ul-1Y
	for commit-inetutils@gnu.org; Fri, 15 Nov 2013 13:30:41 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1VhOAC-0000iN-9U
	for commit-inetutils@gnu.org; Fri, 15 Nov 2013 18:30:40 +0000
Date: Fri, 15 Nov 2013 18:30:40 +0000
Message-Id: <E1VhOAC-0000iN-9U@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1_100-12-g2d4d6b7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 804f20e073d6ec39e60796ee49f1e26f82a19959
X-Git-Newrev: 2d4d6b7a24252f463bef8413ab2dffc9cac621e0
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 Nov 2013 18:30:44 -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  2d4d6b7a24252f463bef8413ab2dffc9cac621e0 (commit)
      from  804f20e073d6ec39e60796ee49f1e26f82a19959 (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=2d4d6b7a24252f463bef8413ab2dffc9cac621e0


commit 2d4d6b7a24252f463bef8413ab2dffc9cac621e0
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri Nov 15 17:43:07 2013 +0100

    tftp: Buffer size checking.
    
    During hardened compilation, a bogus string array defined
    in <arpa/tftp.h> can cause false negatives.

diff --git a/ChangeLog b/ChangeLog
index 40f0f1c..2a1f676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-11-15  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	tftp: Buffer size checking.
+	Hardened builds need a helping hand in interpreting
+	a bogus array length.
+
+	* src/tftp.c (makerequest): New variables ARGLEN, LEN.
+	Use them in calculating available space for file name.
+	[HAVE_STRUCT_TFTPHDR_TH_U]: Calculate CP using an offset
+	argument.  Needed to prevent false negatives from stack
+	allocation protectors.
+
 2013-11-05  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Improve detection of readline.
diff --git a/src/tftp.c b/src/tftp.c
index 2d66322..f50abc1 100644
--- a/src/tftp.c
+++ b/src/tftp.c
@@ -1211,16 +1211,37 @@ makerequest (int request, const char *name, struct tftphdr *tp,
 	     const char *mode)
 {
   register char *cp;
+  size_t arglen, len;
 
   tp->th_opcode = htons ((unsigned short) request);
 #if HAVE_STRUCT_TFTPHDR_TH_U
-  cp = tp->th_stuff;
+  /*
+   * GNU and BSD essentially, i.e. modulo a macro, define
+   * 'tftphdr.th_stuff' as a character array of length
+   * naught with GNU, and one with BSD!
+   *
+   * When compiling with stack protectors, like during
+   * hardened builds in Debian, every useful file name
+   * will overflow that limit.  However, our code ensures
+   * '*tp' to be of length PKTSIZE.  Assigning CP via an
+   * offset calculation avoids this issue.
+   */
+  cp = (char *) tp + (tp->th_stuff - (char *) tp);
 #else
   cp = (char *) &(tp->th_stuff);
 #endif
-  strcpy (cp, name);
-  cp += strlen (name);
+
+  /* Available space for naming the target file.  */
+  len = PKTSIZE - sizeof (struct tftphdr) - sizeof ("netascii");
+  arglen = strlen (name);
+
+  strncpy (cp, name, len);
+
+  cp += (arglen < len) ? arglen : len;
   *cp++ = '\0';
+
+  /* Mode is either "netascii" or "octet", so is always fits
+   * based on our choice of LEN.  */
   strcpy (cp, mode);
   cp += strlen (mode);
   *cp++ = '\0';

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

Summary of changes:
 ChangeLog  |   12 ++++++++++++
 src/tftp.c |   27 ++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Wed Nov 27 12:17:25 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Vlijt-0001M2-Ox
	for mharc-commit-inetutils@gnu.org; Wed, 27 Nov 2013 12:17:25 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57594)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vlijq-0001Lu-SG
	for commit-inetutils@gnu.org; Wed, 27 Nov 2013 12:17:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vlijn-0003FA-3U
	for commit-inetutils@gnu.org; Wed, 27 Nov 2013 12:17:22 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:49088)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vlijm-0003F4-Vq
	for commit-inetutils@gnu.org; Wed, 27 Nov 2013 12:17:19 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Vlijm-0004vY-HK
	for commit-inetutils@gnu.org; Wed, 27 Nov 2013 17:17:18 +0000
Date: Wed, 27 Nov 2013 17:17:18 +0000
Message-Id: <E1Vlijm-0004vY-HK@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1_100-14-gfa00853
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2d4d6b7a24252f463bef8413ab2dffc9cac621e0
X-Git-Newrev: fa0085314a98c2acce9a5a99116f829c4a46f742
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, 27 Nov 2013 17:17:24 -0000

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

The branch, master has been updated
       via  fa0085314a98c2acce9a5a99116f829c4a46f742 (commit)
       via  7123f5cbf232992fe9365c67537af91766046af9 (commit)
      from  2d4d6b7a24252f463bef8413ab2dffc9cac621e0 (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=fa0085314a98c2acce9a5a99116f829c4a46f742


commit fa0085314a98c2acce9a5a99116f829c4a46f742
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Mon Nov 25 00:02:00 2013 +0100

    inetd: Ensure successful daemon mode.
    
    Check all remaining calls to chdir.

diff --git a/ChangeLog b/ChangeLog
index a30dc39..f03aa11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-11-24  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	inetd: Ensure successful daemon mode.
+
+	* src/inetd.c (main) <!debug>: Abort with a syslog message,
+	should daemon() return unsuccessfully.
+	* libinetutils/damon.c (waitdaemon): Return with failure,
+	should chdir("/") fail.
+
+
+	Check all calls to chdir.
+
+	* src/rshd.c (doit): Make a syslog error message and abort
+	execution, should chdir("/") fail.
+	* src/uucpd.c (doit): Abort with a message to stderr,
+	should chdir("/") fail.
+
 2013-11-23  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	Check all returns from fgets.
diff --git a/libinetutils/daemon.c b/libinetutils/daemon.c
index af4a383..5c8b739 100644
--- a/libinetutils/daemon.c
+++ b/libinetutils/daemon.c
@@ -166,8 +166,8 @@ waitdaemon (int nochdir, int noclose, int maxwait)
       _exit (EXIT_SUCCESS);
     }
 
-  if (!nochdir)
-    chdir ("/");
+  if (!nochdir && chdir ("/") < 0)
+    return -1;			/* Unlikely failure, but check it.  */
 
   if (!noclose)
     {
diff --git a/src/inetd.c b/src/inetd.c
index bd67e9a..7d1cd5e 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -1938,7 +1938,12 @@ main (int argc, char *argv[], char *envp[])
 
   if (!debug)
     {
-      daemon (0, 0);
+      if (daemon (0, 0) < 0)
+	{
+	  syslog (LOG_DAEMON | LOG_ERR,
+		  "%s: Unable to enter daemon mode, %m", argv[0]);
+	  exit (EXIT_FAILURE);
+	};
     }
 
   openlog ("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
diff --git a/src/rshd.c b/src/rshd.c
index cde8dca..4dc6f50 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -1880,11 +1880,18 @@ doit (int sockfd, struct sockaddr *fromp, socklen_t fromlen)
    */
   if (chdir (pwd->pw_dir) < 0)
     {
-      chdir ("/");
       syslog (LOG_INFO | LOG_AUTH,
 	      "%s@%s as %s: no home directory. cmd='%.80s'", remuser,
 	      hostname, locuser, cmdbuf);
       rshd_error ("No remote directory.\n");
+
+      if (chdir ("/") < 0)
+	{
+	  syslog (LOG_ERR | LOG_AUTH,
+		  "%s@%s as %s: access denied to '/'",
+		  remuser, hostname, locuser);
+	  exit (EXIT_FAILURE);
+	}
     }
 
   /* Set up an initial environment for the shell that we exec() */
diff --git a/src/uucpd.c b/src/uucpd.c
index 4467d6c..1c898eb 100644
--- a/src/uucpd.c
+++ b/src/uucpd.c
@@ -258,7 +258,11 @@ doit (struct sockaddr *sap, socklen_t salen)
 #ifdef HAVE_INITGROUPS
   initgroups (pw->pw_name, pw->pw_gid);
 #endif
-  chdir (pw->pw_dir);
+  if (chdir (pw->pw_dir) < 0)
+    {
+      fprintf (stderr, "Login incorrect.");
+      return;
+    }
   setuid (pw->pw_uid);
   execl (uucico_location, "uucico", NULL);
   perror ("uucico server: execl");

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


commit 7123f5cbf232992fe9365c67537af91766046af9
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Sat Nov 23 23:57:17 2013 +0100

    Check all returns from fgets.

diff --git a/ChangeLog b/ChangeLog
index 2a1f676..a30dc39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-11-23  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	Check all returns from fgets.
+	Handle every failed fgets() with care.
+
+	* ftp/cmds.c (user): Set account string to empty when
+	fgets() fails.
+	* src/rexec.c (main): Likewise for password string.
+	* src/tftp.c (get_args): Call makeargv() only on successful
+	call to fgets().  Otherwise, instantiate a trivial command
+	list containing command name only.
+	* telnet/commands.c (setescape): Leave escape character
+	unchanged when fgets() fails.
+	(tn) <get host>: Call makeargv() only for successful fgets().
+	Otherwise, print a message and rely on later usage printout.
+	(command): Print a line feed at EOF on stream error.
+
 2013-11-15  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	tftp: Buffer size checking.
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 15ecefc..52da092 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -1695,8 +1695,10 @@ user (int argc, char **argv)
 	{
 	  printf ("Account: ");
 	  fflush (stdout);
-	  fgets (acct, sizeof (acct) - 1, stdin);
-	  acct[strlen (acct) - 1] = '\0';
+	  if (fgets (acct, sizeof (acct) - 1, stdin))
+	    acct[strlen (acct) - 1] = '\0';	/* Erase newline.  */
+	  else
+	    acct[0] = '\0';			/* Set empty name.  */
 	  argv[3] = acct;
 	  argc++;
 	}
diff --git a/src/rexec.c b/src/rexec.c
index bb222ee..a5bcae7 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -206,13 +206,14 @@ main (int argc, char **argv)
 	    }
 
 	  printf ("Password: ");
-	  fgets (password, sizeof (password), stdin);
+	  if (fgets (password, sizeof (password), stdin) == NULL)
+	    password[0] = '\0';
 
 	  if (changed && (tcsetattr (STDIN_FILENO, TCSANOW, &tt) < 0))
 	    error (0, errno, "failed to restore terminal");
 	}
-      else
-	fgets (password, sizeof (password), stdin);
+      else if (fgets (password, sizeof (password), stdin) == NULL)
+	password[0] = '\0';
       alarm (0);
 
       n = strlen (password);
diff --git a/src/tftp.c b/src/tftp.c
index f50abc1..d668075 100644
--- a/src/tftp.c
+++ b/src/tftp.c
@@ -404,11 +404,17 @@ get_args (char *arg0, char *prompt, int *argc, char ***argv)
   strcat (line, " ");
 
   printf ("%s", prompt);
-  fgets (line + arg0_len + 1, sizeof line - arg0_len - 1, stdin);
-
-  makeargv ();
-  *argc = margc;
-  *argv = margv;
+  if (fgets (line + arg0_len + 1, sizeof line - arg0_len - 1, stdin))
+    {
+      makeargv ();
+      *argc = margc;
+      *argv = margv;
+    }
+  else
+    {
+      *argv[0] = arg0;
+      *argc = 1;		/* Will produce a usage printout.  */
+    }
 }
 
 void
diff --git a/telnet/commands.c b/telnet/commands.c
index f0307f7..25ed235 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -1505,7 +1505,11 @@ setescape (int argc, char *argv[])
   else
     {
       printf ("new escape character: ");
-      fgets (buf, sizeof (buf), stdin);
+      if (fgets (buf, sizeof (buf), stdin) == NULL)
+	{
+	  buf[0] = '\0';
+	  printf ("\n");
+	}
       arg = buf;
     }
   if (arg[0] != '\0')
@@ -2472,10 +2476,15 @@ tn (int argc, char *argv[])
     {
       strcpy (line, "open ");
       printf ("(to) ");
-      fgets (&line[strlen (line)], sizeof (line) - strlen (line), stdin);
-      makeargv ();
-      argc = margc;
-      argv = margv;
+      if (fgets (&line[strlen (line)],
+		 sizeof (line) - strlen (line), stdin))
+	{
+	  makeargv ();
+	  argc = margc;
+	  argv = margv;
+	}
+      else
+	printf ("?Name of host was not understood.\n");
     }
   cmd = *argv;
   --argc;
@@ -2967,6 +2976,7 @@ command (int top, char *tbuf, int cnt)
 	    {
 	      if (feof (stdin) || ferror (stdin))
 		{
+		  printf ("\n");
 		  quit ();
 		}
 	      break;

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

Summary of changes:
 ChangeLog             |   34 ++++++++++++++++++++++++++++++++++
 ftp/cmds.c            |    6 ++++--
 libinetutils/daemon.c |    4 ++--
 src/inetd.c           |    7 ++++++-
 src/rexec.c           |    7 ++++---
 src/rshd.c            |    9 ++++++++-
 src/tftp.c            |   16 +++++++++++-----
 src/uucpd.c           |    6 +++++-
 telnet/commands.c     |   20 +++++++++++++++-----
 9 files changed, 89 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Thu Nov 28 14:26:11 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Vm7E3-0006lz-Kn
	for mharc-commit-inetutils@gnu.org; Thu, 28 Nov 2013 14:26:11 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58286)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vm7Dz-0006ko-Vj
	for commit-inetutils@gnu.org; Thu, 28 Nov 2013 14:26:09 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vm7Dy-0001JM-6q
	for commit-inetutils@gnu.org; Thu, 28 Nov 2013 14:26:07 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:52209)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1Vm7Dy-0001JI-3G
	for commit-inetutils@gnu.org; Thu, 28 Nov 2013 14:26:06 -0500
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1Vm7Dq-000271-6u
	for commit-inetutils@gnu.org; Thu, 28 Nov 2013 19:26:02 +0000
Date: Thu, 28 Nov 2013 19:25:58 +0000
Message-Id: <E1Vm7Dq-000271-6u@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_1_100-15-g17518fb
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: fa0085314a98c2acce9a5a99116f829c4a46f742
X-Git-Newrev: 17518fbec9610f2ac9d2c576774917e419d7e4a5
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 Nov 2013 19:26: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  17518fbec9610f2ac9d2c576774917e419d7e4a5 (commit)
      from  fa0085314a98c2acce9a5a99116f829c4a46f742 (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=17518fbec9610f2ac9d2c576774917e419d7e4a5


commit 17518fbec9610f2ac9d2c576774917e419d7e4a5
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Thu Nov 28 19:25:55 2013 +0100

    rlogind, telnet, telnetd: Modify exit status.
    
    As a side effect, a race condition is now avoided,
    while `rlogind' is tearing down pseudo-terminal pairs.

diff --git a/ChangeLog b/ChangeLog
index f03aa11..4e8b94a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,36 @@
+2013-11-28  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	rlogind, telnet, telnetd: Modify exit status.
+
+	* src/rlogind.c (rlogind_mainloop): Delay cleanup()
+	call until libshishi has torn down its structures.
+	(cleanup): New variable STATUS.  If `signo' is SIGCHLD,
+	call waitpid() to reap the waiting child process and
+	use its return status for the whole server's status.
+	Waiting for the child resolves a race condition when
+	tearing down the pseudo-terminal pair, since the slave
+	now is gone when the master side is being closed down.
+
+	* telnet/commands.c (tn): Use exit status 0 when setjmp()
+	manages to execute telnet().  Otherwise, keep 1.
+	(command) [unix || __unix || __unix__]: Enclose the
+	complete else-block within preprocessor conditionals.
+
+	* telnetd/pty.c (cleanup): Let STATUS have full scope
+	in this function, and use it for exit().  Execute waitpid()
+	only if `sig' is SIGCHLD, and update STATUS for later use.
+	On SIGHUP, set STATUS to success, which happens only at
+	reception of TELOPT_LOGOUT from client.
+	* telnetd/state.c (dooption) <TELOPT_LOGOUT>: Call cleanup()
+	with argument SIGHUP, since the client willingly leaves off.
+
 2013-11-24  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	inetd: Ensure successful daemon mode.
 
 	* src/inetd.c (main) <!debug>: Abort with a syslog message,
 	should daemon() return unsuccessfully.
-	* libinetutils/damon.c (waitdaemon): Return with failure,
+	* libinetutils/daemon.c (waitdaemon): Return with failure,
 	should chdir("/") fail.
 
 
diff --git a/src/rlogind.c b/src/rlogind.c
index 409a929..d279f71 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -618,7 +618,7 @@ main (int argc, char *argv[])
   else
     exit (rlogind_mainloop (fileno (stdin), fileno (stdout)));
 
-  return 0;
+  return 0;		/* Not reachable.  */
 }
 
 /* Create a listening socket for the indicated
@@ -852,6 +852,7 @@ rlogin_daemon (int maxchildren, int port)
 	  close (fd);
 	}
     }
+  /* NOT REACHED */
 }
 
 int
@@ -1266,7 +1267,6 @@ rlogind_mainloop (int infd, int outfd)
   setsig (SIGCHLD, cleanup);
   protocol (infd, master, &auth_data);
   setsig (SIGCHLD, SIG_IGN);
-  cleanup (0);
 
 #ifdef SHISHI
   if (kerberos)
@@ -1288,6 +1288,9 @@ rlogind_mainloop (int infd, int outfd)
     }
 #endif /* SHISHI */
 
+  cleanup (0);
+  /* NOT REACHED */
+
   return 0;
 }
 
@@ -2063,10 +2066,18 @@ control (int pty, char *cp, size_t n)
 }
 
 void
-cleanup (int signo _GL_UNUSED_PARAMETER)
+cleanup (int signo)
 {
+  int status = EXIT_FAILURE;
   char *p;
 
+  if (signo == SIGCHLD)
+    {
+      (void) waitpid ((pid_t) -1, &status, WNOHANG);
+
+      status = WEXITSTATUS (status);
+    }
+
   p = line + sizeof (PATH_TTY_PFX) - 1;
 #if !defined HAVE_LOGOUT || !defined HAVE_LOGWTMP
   utmp_logout (p);
@@ -2082,7 +2093,7 @@ cleanup (int signo _GL_UNUSED_PARAMETER)
   chown (line, 0, 0);
 #endif
   shutdown (netf, 2);
-  exit (EXIT_FAILURE);
+  exit (status);
 }
 
 int
diff --git a/telnet/commands.c b/telnet/commands.c
index 25ed235..dd30b5a 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -2814,11 +2814,15 @@ tn (int argc, char *argv[])
       env_export ("USER");
     }
   call (status, "status", "notmuch", 0);
+  err = 0;
   if (setjmp (peerdied) == 0)
     telnet (user);
+  else
+    err = 1;
 
   close (net);
-  ExitString ("Connection closed by foreign host.\n", 1);
+  ExitString ("Connection closed by foreign host.\n", err);
+  /* NOT REACHED */
   return 0;
 }
 
@@ -2942,14 +2946,14 @@ command (int top, char *tbuf, int cnt)
   if (!top)
     {
       putchar ('\n');
-#if defined unix || defined __unix || defined __unix__
     }
+#if defined unix || defined __unix || defined __unix__
   else
     {
       signal (SIGINT, SIG_DFL);
       signal (SIGQUIT, SIG_DFL);
-#endif /* unix || __unix || __unix__ */
     }
+#endif /* unix || __unix || __unix__ */
   for (;;)
     {
       if (rlogin == _POSIX_VDISABLE)
diff --git a/telnet/main.c b/telnet/main.c
index 419462a..765144a 100644
--- a/telnet/main.c
+++ b/telnet/main.c
@@ -371,6 +371,8 @@ main (int argc, char *argv[])
 
   if (argc)
     {
+      /* The command line contains at least one argument.
+       */
       char *args[8], **argp = args;
 
       if (argc > 2)
@@ -393,11 +395,14 @@ main (int argc, char *argv[])
 
       if (setjmp (toplevel) != 0)
 	Exit (0);
-      if (tn (argp - args, args) == 1)
+      if (tn (argp - args, args) == 1)	/* Returns only on error.  */
 	return (0);
       else
 	return (1);
+      /* NOT REACHED */
     }
+
+  /* Built-in parser loop; sub-commands jump to `toplevel' mark.  */
   setjmp (toplevel);
   for (;;)
     {
@@ -408,4 +413,5 @@ main (int argc, char *argv[])
 #endif
 	command (1, 0, 0);
     }
+  /* NOT REACHED */
 }
diff --git a/telnetd/pty.c b/telnetd/pty.c
index 58bf4e2..21b0b69 100644
--- a/telnetd/pty.c
+++ b/telnetd/pty.c
@@ -136,23 +136,35 @@ start_login (char *host, int autologin, char *name)
   fatalperror (net, cmd);
 }
 
+/* SIG is generally naught every time the server itself
+ * decides to close the connection out of an error condition.
+ * In response to TELOPT_LOGOUT from the client, SIG is set
+ * to SIGHUP, so we consider the exit as a success.  In other
+ * cases, when the forked client process is caught exiting,
+ * then SIG will be SIGCHLD.  Then we deliver the clients's
+ * reported exit code.
+ */
 void
 cleanup (int sig)
 {
+  int status = EXIT_FAILURE;
   char *p;
 
-  if (sig)
+  if (sig == SIGCHLD)
     {
-      int status;
       pid_t pid = waitpid ((pid_t) - 1, &status, WNOHANG);
       syslog (LOG_INFO, "child process %ld exited: %d",
 	      (long) pid, WEXITSTATUS (status));
+
+      status = WEXITSTATUS (status);
     }
+  else if (sig == SIGHUP)
+    status = EXIT_SUCCESS;	/* Response to TELOPT_LOGOUT.  */
 
   p = line + sizeof (PATH_TTY_PFX) - 1;
   utmp_logout (p);
   chmod (line, 0644);
   chown (line, 0, 0);
   shutdown (net, 2);
-  exit (EXIT_FAILURE);
+  exit (status);
 }
diff --git a/telnetd/state.c b/telnetd/state.c
index 81dd9d7..6878c3d 100644
--- a/telnetd/state.c
+++ b/telnetd/state.c
@@ -1000,7 +1000,7 @@ dooption (int option)
 	  send_will (TELOPT_LOGOUT, 0);
 	  set_my_state_will (TELOPT_LOGOUT);
 	  netflush ();
-	  cleanup (0);
+	  cleanup (SIGHUP);
 	  /* NOT REACHED */
 	  break;
 
diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c
index 30e2f3b..cf7ce0f 100644
--- a/telnetd/telnetd.c
+++ b/telnetd/telnetd.c
@@ -221,7 +221,7 @@ main (int argc, char **argv)
     error (EXIT_FAILURE, 0, "junk arguments in the command line");
 
   telnetd_setup (0);
-  return telnetd_run ();
+  return telnetd_run ();	/* Never returning.  */
 }
 
 void
@@ -719,7 +719,9 @@ telnetd_run (void)
       if (FD_ISSET (pty, &obits) && pty_output_level () > 0)
 	ptyflush ();
     }
+
   cleanup (0);
+  /* NOT REACHED */
 
   return 0;
 }
diff --git a/telnetd/utility.c b/telnetd/utility.c
index 5fb31b9..5703f1e 100644
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -274,6 +274,7 @@ net_read (void)
     {
       syslog (LOG_INFO, "telnetd:  peer died");
       cleanup (0);
+      /* NOT REACHED */
     }
   else if (ncc > 0)
     {
@@ -338,6 +339,7 @@ ptyflush (void)
       if (errno == EWOULDBLOCK || errno == EINTR)
 	return;
       cleanup (0);
+      /* NOT REACHED */
     }
 
   pbackp += n;
@@ -615,6 +617,7 @@ netflush (void)
       if (errno == EWOULDBLOCK || errno == EINTR)
 	return;
       cleanup (0);
+      /* NOT REACHED */
     }
 
   nbackp += n;

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

Summary of changes:
 ChangeLog         |   28 +++++++++++++++++++++++++++-
 src/rlogind.c     |   19 +++++++++++++++----
 telnet/commands.c |   10 +++++++---
 telnet/main.c     |    8 +++++++-
 telnetd/pty.c     |   18 +++++++++++++++---
 telnetd/state.c   |    2 +-
 telnetd/telnetd.c |    4 +++-
 telnetd/utility.c |    3 +++
 8 files changed, 78 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


