commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-45-g239949


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-45-g2399491
Date: Tue, 20 Jan 2015 15:22: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  239949170fa6715ffa634c51e275d4c95e29530e (commit)
      from  eaea8e167f7909ca3bb399f88f08503ea1d59917 (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=239949170fa6715ffa634c51e275d4c95e29530e


commit 239949170fa6715ffa634c51e275d4c95e29530e
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Jan 20 12:46:13 2015 +0100

    telnetd: Incomplete processing of PTY data.
    
    It may happen that an incoming SIGCHLD intervenes with the transfer
    of the last few bytes from the PTY of the child process to the net
    stream servicing the remote client with response.  Improved signal
    handling of SIGCHLD prevents this loss.

diff --git a/ChangeLog b/ChangeLog
index 44780e9..245e726 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2015-01-20  Mats Erik Andersson  <address@hidden>
+
+       telnetd: Incomplete processing of PTY data.
+       The reception of SIGCHLD can make the transfer of data from
+       the PTY stream to the client side's network stream incomplete.
+       The problem was raised as Debian Bug #607415, but is applicable
+       also here, due to a common origin.  A setting with the option
+       `-E /some/script' displays this error irregularly.
+
+       * telnetd/telnetd.c (pending_sigchld): New variable.
+       (telnetd_setup): Call setsig() when assigning SIGCHLD.  Set the
+       action to chld_is_done().
+       (telnetd_run) <I/O-loop>: If pending_sigchld is set, flush the
+       network output buffer and exit the loop with cleanup(SIGCHLD).
+       (chld_is_done): New function, used as signal action.
+
+       * telnetd/utility.c (pty_read) <DEBUG>: Set consistent text
+       prefixes in output.
+       (printdata): Cast char array value as `unsigned char' to avoid
+       an implicit cast as integer, implied in the format string `%02x'.
+
 2015-01-17  Mats Erik Andersson  <address@hidden>
 
        * telnetd/state.c (dooption) : Remove outdated and misnamed
diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c
index db5454f..eb825e5 100644
--- a/telnetd/telnetd.c
+++ b/telnetd/telnetd.c
@@ -42,6 +42,7 @@ static void parse_debug_level (char *str);
 static void telnetd_setup (int fd);
 static int telnetd_run (void);
 static void print_hostinfo (void);
+static void chld_is_done (int sig);
 
 /* Template command line for invoking login program.  */
 
@@ -73,6 +74,8 @@ int hostinfo = 1;             /* Print the host-specific 
information before
 int debug_level[debug_max_mode];       /* Debugging levels */
 int debug_tcp = 0;             /* Should the SO_DEBUG be set? */
 
+int pending_sigchld = 0;       /* Needed to drain pty input.  */
+
 int net;                       /* Network connection socket */
 int pty;                       /* PTY master descriptor */
 #if defined AUTHENTICATION || defined ENCRYPTION
@@ -527,7 +530,8 @@ telnetd_setup (int fd)
   signal (SIGTTOU, SIG_IGN);
 #endif
 
-  signal (SIGCHLD, cleanup);
+  /* Activate SA_RESTART whenever available.  */
+  setsig (SIGCHLD, chld_is_done);
 }
 
 int
@@ -718,6 +722,18 @@ telnetd_run (void)
 
       if (FD_ISSET (pty, &obits) && pty_output_level () > 0)
        ptyflush ();
+
+      /* Attending to the child must come last in the loop,
+       * so as to let pending data be flushed, mainly to the
+       * benefit of the remote and expecting client.
+       */
+      if (pending_sigchld) {
+       /* Check for pending output, independently of OBITS.  */
+       if (net_output_level () > 0)
+         netflush ();
+
+       cleanup (SIGCHLD);      /* Not returning from this.  */
+      }
     }
 
   cleanup (0);
@@ -754,3 +770,9 @@ print_hostinfo (void)
   pty_input_putback (str, strlen (str));
   free (str);
 }
+
+static void
+chld_is_done (int sig _GL_UNUSED_PARAMETER)
+{
+  pending_sigchld = 1;
+}
diff --git a/telnetd/utility.c b/telnetd/utility.c
index 0a4d430..e644377 100644
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -384,8 +384,8 @@ pty_read (void)
     pcc = 0;
   ptyip = ptyibuf;
 
-  DEBUG (debug_report, 1, debug_output_data ("ptyread %d chars\r\n", pcc));
-  DEBUG (debug_pty_data, 1, printdata ("pty", ptyip, pcc));
+  DEBUG (debug_report, 1, debug_output_data ("td: ptyread %d chars\r\n", pcc));
+  DEBUG (debug_pty_data, 1, printdata ("pd", ptyip, pcc));
   return pcc;
 }
 
@@ -1582,7 +1582,7 @@ printdata (char *tag, char *ptr, int cnt)
       debug_output_data ("%s: ", tag);
       for (i = 0; i < 20 && cnt; i++)
        {
-         debug_output_data ("%02x", *ptr);
+         debug_output_data ("%02x", (unsigned char) *ptr);
          xbuf[i] = isprint ((int) *ptr) ? *ptr : '.';
 
          if (i % 2)

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

Summary of changes:
 ChangeLog         |   21 +++++++++++++++++++++
 telnetd/telnetd.c |   24 +++++++++++++++++++++++-
 telnetd/utility.c |    6 +++---
 3 files changed, 47 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]