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_1-177-g10841


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-177-g108417e
Date: Thu, 27 Sep 2012 22:47:53 +0000

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

The branch, master has been updated
       via  108417e11156e3d1c5256bb31d58e893e280f313 (commit)
       via  63d9bb0f224fd979f79da4204b3083697cf9e31e (commit)
      from  fc8280bc58b5575e7187eec77fadfffcc28fde1a (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=108417e11156e3d1c5256bb31d58e893e280f313


commit 108417e11156e3d1c5256bb31d58e893e280f313
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Sep 27 23:54:36 2012 +0200

    rlogin: Signal protection issues.
    
    Attempt consistent signal handling for all
    supported systems.  Also influencing window
    resizing and its IPC.

diff --git a/ChangeLog b/ChangeLog
index 8b421fa..8df810c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2012-09-27  Mats Erik Andersson  <address@hidden>
+
+       rlogin, rlogind: Signal dispositions.
+       Use a more portable signal API.
+
+       * libinetutils/libinetutils.h: Include <signal.h>.
+       (setsig): New prototype, exposing old function.
+
+       rlogin: Old signal API is inconsistent, even between
+       libc6 versions.
+
+       * src/rlogin.c (setsig): Remove external prototype.
+       (main): New variable SA.  Use STDIN_FILENO, not 0.
+       Call sigaction() with SIGURG, SIGUSR1, not setsig().
+       Pass `&osmask' to doit(), needed for window sizing.
+       (doit): Rename parameter as `osmask' for clarity.
+       New variable SA.  Call sigaction for SIGINT, SIGCHLD.
+       (setsignal): Fully reworked implementation.
+       (writeroob): New variable SA.  Use sigaction().
+       (oob): Use STDOUT_FILENO, not 1.  Offer ioctl TCIOFLUSH
+       for systems lacking TIOCFLUSH.
+       (reader): Rename parameter as `osmask'.  New variable SA.
+       Assume that contemporary getpid() returns positive values.
+       Call fcntl(F_SETOWN) as early as possible.  Use sigaction()
+       for SIGTTOU, SIGURG.
+       (lostpeer): Use input parameter in setsig().
+       (copytochild): Likewise for kill().
+
+       * src/rlogind.c (rlogind_sigchld): Rename parameter.
+       Replace signal() by setsig().
+       (main, rlogin_daemon, rlogind_mainloop, protocol):
+       Replace signal().
+
 2012-09-25  Mats Erik Andersson  <address@hidden>
 
        Disable incompatible utmpx implementation.
diff --git a/libinetutils/libinetutils.h b/libinetutils/libinetutils.h
index 9286383..5dc329d 100644
--- a/libinetutils/libinetutils.h
+++ b/libinetutils/libinetutils.h
@@ -22,7 +22,9 @@
 #endif
 
 #include "argp-version-etc.h"
+#include <signal.h>
 
+sighandler_t setsig (int sig, sighandler_t handler);
 void utmp_init (char *line, char *user, char *id, char *host);
 char *utmp_ptsid (char *line, char *tag);
 void utmp_logout (char *line);
diff --git a/src/rlogin.c b/src/rlogin.c
index a2ab0bf..569245e 100644
--- a/src/rlogin.c
+++ b/src/rlogin.c
@@ -193,7 +193,7 @@ struct winsize
 };
 
 int get_window_size (int, struct winsize *);
-#else
+#else /* !OLDSUN */
 # define get_window_size(fd, wp)       ioctl (fd, TIOCGWINSZ, wp)
 #endif
 struct winsize winsize;
@@ -221,8 +221,6 @@ void writeroob (int);
 void warning (const char *, ...);
 #endif
 
-extern sighandler_t setsig (int, sighandler_t);
-
 const char args_doc[] = "HOST";
 const char doc[] = "Starts a terminal session on a remote host.";
 
@@ -335,6 +333,7 @@ main (int argc, char *argv[])
 {
   struct passwd *pw;
   struct servent *sp;
+  struct sigaction sa;
   sigset_t smask, osmask;
   uid_t uid;
   int index;
@@ -416,7 +415,7 @@ main (int argc, char *argv[])
      terminal's speed.  The name and the speed are passed to the server
      as the argument "cmd" of the rcmd() function.  This is something like
      "vt100/9600".  */
-  term_speed = speed (0);
+  term_speed = speed (STDIN_FILENO);
   if (term_speed == SPEED_NOTATTY)
     {
       char *p;
@@ -429,13 +428,21 @@ main (int argc, char *argv[])
       snprintf (term, sizeof term, "%s/%d",
                ((p = getenv ("TERM")) ? p : "network"), term_speed);
     }
-  get_window_size (0, &winsize);
+  get_window_size (STDIN_FILENO, &winsize);
 
-  setsig (SIGPIPE, lostpeer);
+  setsig (SIGPIPE, lostpeer);  /* XXX: Replace setsig()?  */
 
-  /* Block SIGURG and SIGUSR1 signals.  These will be handled by the
-     parent and the child after the fork.  */
-  /* Will be using SIGUSR1 for window size hack, so hold it off.  */
+  /*
+   * Block SIGURG and SIGUSR1 signals during connection setup.
+   * These signals will be handled distinctly by parent and child
+   * after completion of process forking.
+   *
+   * SIGUSR1 will be be raise by the child for the parent process,
+   * in order that the client's finding of window size be transmitted
+   * to the remote machine.
+   *
+   * osmask will be passed along as the desired runtime signal mask.
+   */
   sigemptyset (&smask);
   sigemptyset (&osmask);
   sigaddset (&smask, SIGURG);
@@ -443,13 +450,17 @@ main (int argc, char *argv[])
   sigprocmask (SIG_SETMASK, &smask, &osmask);
 
   /*
-   * We set SIGURG and SIGUSR1 below so that an
+   * We set disposition for SIGURG and SIGUSR1 so that an
    * incoming signal will be held pending rather than being
    * discarded. Note that these routines will be ready to get
-   * a signal by the time that they are unblocked below.
+   * a signal by the time that they are unblocked later on.
    */
-  setsig (SIGURG, copytochild);
-  setsig (SIGUSR1, writeroob);
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  sa.sa_handler = copytochild;
+  (void) sigaction (SIGURG, &sa, NULL);
+  sa.sa_handler = writeroob;
+  (void) sigaction (SIGUSR1, &sa, NULL);
 
 #if defined KERBEROS || defined SHISHI
 try_connect:
@@ -635,7 +646,7 @@ try_connect:
   seteuid (uid);
   setuid (uid);
 
-  doit (&smask);
+  doit (&osmask);      /* The old mask will activate SIGURG and SIGUSR1!  */
 
   return 0;
 }
@@ -747,9 +758,10 @@ struct termios ixon_state;
 struct termios nott;
 
 void
-doit (sigset_t * smask)
+doit (sigset_t * osmask)
 {
   int i;
+  struct sigaction sa;
 
   for (i = 0; i < NCCS; i++)
     nott.c_cc[i] = _POSIX_VDISABLE;
@@ -757,7 +769,11 @@ doit (sigset_t * smask)
   nott.c_cc[VSTART] = deftt.c_cc[VSTART];
   nott.c_cc[VSTOP] = deftt.c_cc[VSTOP];
 
-  setsig (SIGINT, SIG_IGN);
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = SA_RESTART;
+  sa.sa_handler = SIG_IGN;
+  (void) sigaction (SIGINT, &sa, NULL);
+
   setsignal (SIGHUP);
   setsignal (SIGQUIT);
 
@@ -770,7 +786,7 @@ doit (sigset_t * smask)
   if (child == 0)
     {
       mode (1);
-      if (reader (smask) == 0)
+      if (reader (osmask) == 0)
        {
          /* If the reader returns zero, the socket to the server returned
             an EOF, meaning the client logged out of the remote system.
@@ -811,9 +827,10 @@ doit (sigset_t * smask)
    * that were set above.
    */
   /* Reenable SIGURG and SIGUSR1.  */
-  sigprocmask (SIG_SETMASK, smask, (sigset_t *) 0);
+  sigprocmask (SIG_SETMASK, osmask, (sigset_t *) 0);
 
-  setsig (SIGCHLD, catch_child);
+  sa.sa_handler = catch_child;
+  (void) sigaction (SIGCHLD, &sa, NULL);
 
   writer ();
 
@@ -843,24 +860,28 @@ doit (sigset_t * smask)
   done (0);
 }
 
-/* Enable a signal handler, unless the signal is already being ignored.
-   This function is called before the fork (), for SIGHUP and SIGQUIT.  */
+/*
+ * Install an exit handler, unless the signal is already being ignored.
+   This function is called before fork () for SIGHUP and SIGQUIT.  */
 void
 setsignal (int sig)
 {
-  sighandler_t handler;
-  sigset_t sigs, osigs;
-
-  sigemptyset (&sigs);
-  sigemptyset (&osigs);
-  sigaddset (&sigs, sig);
-  sigprocmask (SIG_BLOCK, &sigs, &osigs);
-
-  handler = setsig (sig, exit);
-  if (handler == SIG_IGN)
-    setsig (sig, handler);
-
-  sigprocmask (SIG_SETMASK, &osigs, (sigset_t *) 0);
+  int rc;
+  struct sigaction sa;
+
+  /* Query the present disposition of SIG.
+   * This achieves minimal manipulation.  */
+  sa.sa_flags = 0;
+  sa.sa_handler = NULL;
+  sigemptyset (&sa.sa_mask);
+  rc = sigaction (sig, NULL, &sa);
+
+  /* Set action to exit, unless the signal is ignored.  */
+  if (!rc && sa.sa_handler != SIG_IGN)
+    {
+      sa.sa_handler = _exit;
+      (void) sigaction (sig, &sa, NULL);
+    }
 }
 
 /* This function is called by the parent:
@@ -880,7 +901,7 @@ done (int status)
   if (child > 0)
     {
       /* make sure catch_child does not snap it up */
-      setsig (SIGCHLD, SIG_DFL);
+      setsig (SIGCHLD, SIG_DFL);               /* XXX: Replace setsig()?  */
       if (kill (child, SIGKILL) >= 0)
        while ((w = waitpid (-1, &wstatus, WNOHANG)) > 0 && w != child)
          continue;
@@ -894,6 +915,8 @@ int dosigwinch;
  * This is called when the reader process gets the out-of-band (urgent)
  * request to turn on the window-changing protocol.
  *
+ * Input signal is SIGUSR1, but SIGWINCH is being activated.
+ *
  * FIXME: Race condition due to sendwindow() in signal handler?
  */
 void
@@ -901,8 +924,14 @@ writeroob (int signo _GL_UNUSED_PARAMETER)
 {
   if (dosigwinch == 0)
     {
+      struct sigaction sa;
+
       sendwindow ();
-      setsig (SIGWINCH, sigwinch);
+
+      sa.sa_flags = SA_RESTART;
+      sa.sa_handler = sigwinch;
+      sigemptyset (&sa.sa_mask);
+      (void) sigaction (SIGWINCH, &sa, NULL);
     }
   dosigwinch = 1;
 }
@@ -1067,7 +1096,7 @@ void
 stop (char cmdc)
 {
   mode (0);
-  setsig (SIGCHLD, SIG_IGN);
+  setsig (SIGCHLD, SIG_IGN);           /* XXX: Replace setsig()?  */
   kill (cmdc == deftt.c_cc[VSUSP] ? 0 : getpid (), SIGTSTP);
   setsig (SIGCHLD, catch_child);
   mode (1);
@@ -1197,8 +1226,11 @@ oob (int signo _GL_UNUSED_PARAMETER)
     }
   if (mark & TIOCPKT_FLUSHWRITE)
     {
-#ifdef TIOCFLUSH
-      ioctl (1, TIOCFLUSH, (char *) &out);
+#ifdef TIOCFLUSH               /* BSD and Solaris.  */
+      ioctl (STDOUT_FILENO, TIOCFLUSH, (char *) &out);
+#elif defined TCIOFLUSH                /* Glibc, BSD, and Solaris.  */
+      out = TCIOFLUSH;
+      ioctl (STDOUT_FILENO, TCIOFLUSH, &out);
 #endif
       for (;;)
        {
@@ -1236,25 +1268,27 @@ oob (int signo _GL_UNUSED_PARAMETER)
 
 /* reader: read from remote: line -> 1 */
 int
-reader (sigset_t * smask)
+reader (sigset_t * osmask)
 {
   pid_t pid;
   int n, remaining;
   char *bufp;
+  struct sigaction sa;
 
-#if BSD >= 43 || defined SUNOS4
-  pid = getpid ();             /* modern systems use positives for pid */
-#else
-  pid = -getpid ();            /* old broken systems use negatives */
-#endif
+  pid = getpid ();     /* Modern systems use positive values for pid.  */
+  ppid = getppid ();
 
-  setsig (SIGTTOU, SIG_IGN);
-  setsig (SIGURG, oob);
+  fcntl (rem, F_SETOWN, pid);          /* Get ownership early.  */
+
+  sa.sa_flags = SA_RESTART;
+  sa.sa_handler = SIG_IGN;
+  sigemptyset (&sa.sa_mask);
+  (void) sigaction (SIGTTOU, &sa, NULL);
+  sa.sa_handler = oob;
+  (void) sigaction (SIGURG, &sa, NULL);
 
-  ppid = getppid ();
-  fcntl (rem, F_SETOWN, pid);
   setjmp (rcvtop);
-  sigprocmask (SIG_SETMASK, smask, (sigset_t *) 0);
+  sigprocmask (SIG_SETMASK, osmask, (sigset_t *) 0);
   bufp = rcvbuf;
 
   for (;;)
@@ -1349,18 +1383,18 @@ mode (int f)
 /* FIXME: Race condition due to done() in signal handler?
  */
 void
-lostpeer (int signo _GL_UNUSED_PARAMETER)
+lostpeer (int signo)
 {
-  setsig (SIGPIPE, SIG_IGN);
+  setsig (signo, SIG_IGN);     /* Used with SIGPIPE only.  */
   error (0, 0, "\007Connection to %s lost.\r", host);
   done (1);
 }
 
 /* copy SIGURGs to the child process. */
 void
-copytochild (int signo _GL_UNUSED_PARAMETER)
+copytochild (int signo)
 {
-  kill (child, SIGURG);
+  kill (child, signo);
 }
 
 #if defined KERBEROS || defined SHISHI
diff --git a/src/rlogind.c b/src/rlogind.c
index 6e2847c..f5eda15 100644
--- a/src/rlogind.c
+++ b/src/rlogind.c
@@ -222,14 +222,14 @@ int do_shishi_login (int infd, struct auth_data *ad, 
const char **err_msg);
 #endif
 
 void
-rlogind_sigchld (int sig)
+rlogind_sigchld (int signo)
 {
   pid_t pid;
   int status;
 
   while ((pid = waitpid (-1, &status, WNOHANG)) > 0)
     --numchildren;
-  signal (sig, rlogind_sigchld);
+  setsig (signo, rlogind_sigchld);
 }
 
 #if defined KERBEROS && defined ENCRYPTION
@@ -417,7 +417,7 @@ main (int argc, char *argv[])
       exit (EXIT_FAILURE);
     }
 
-  signal (SIGHUP, SIG_IGN);
+  setsig (SIGHUP, SIG_IGN);
 
   if (!local_domain_name)
     {
@@ -479,7 +479,7 @@ rlogin_daemon (int maxchildren, int port)
       fatal (fileno (stderr), "fork failed, exiting", 0);
     }
 
-  signal (SIGCHLD, rlogind_sigchld);
+  setsig (SIGCHLD, rlogind_sigchld);
 
   listenfd = socket (AF_INET, SOCK_STREAM, 0);
 
@@ -921,9 +921,9 @@ rlogind_mainloop (int infd, int outfd)
   ioctl (master, FIONBIO, &true);
   ioctl (master, TIOCPKT, &true);
   netf = infd;                 /* Needed for cleanup() */
-  signal (SIGCHLD, cleanup);
+  setsig (SIGCHLD, cleanup);
   protocol (infd, master, &auth_data);
-  signal (SIGCHLD, SIG_IGN);
+  setsig (SIGCHLD, SIG_IGN);
   cleanup (0);
 
 #ifdef SHISHI
@@ -1458,7 +1458,7 @@ protocol (int f, int p, struct auth_data *ap)
    * when we try and set slave pty's window shape
    * (our controlling tty is the master pty).
    */
-  signal (SIGTTOU, SIG_IGN);
+  setsig (SIGTTOU, SIG_IGN);
 #ifdef SHISHI
   if (kerberos && (ap->protocol == 2))
     {

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


commit 63d9bb0f224fd979f79da4204b3083697cf9e31e
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Sep 25 23:00:48 2012 +0200

    Discard strange utmpx.
    
    FreeBSD 9.0 changed to a non-standard utmpx
    interface.  Disable unsupported servers.

diff --git a/ChangeLog b/ChangeLog
index a1208d5..8b421fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-25  Mats Erik Andersson  <address@hidden>
+
+       Disable incompatible utmpx implementation.
+
+       * configure.ac <*-freebsd9* || *-freebsd10*>:
+       Disable building of ftpd, rlogind, syslogd,
+       talkd, telnetd, and uucpd.
+
 2012-09-19  Mats Erik Andersson  <address@hidden>
 
        * configure.ac <libwrap check>: Call AC_CHECK_DECLS
diff --git a/configure.ac b/configure.ac
index 63f84dd..e348aff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -963,6 +963,17 @@ AH_BOTTOM(
 # entry in utmpx.  Also for some OS they are better handled with
 # STREAMS.
 case "$host" in
+*-freebsd9* | *-freebsd10*)
+  # FreeBSD 9.0 has implemented a non-standard and singular
+  # UTMPX interface.  We do not support it, nor does the
+  # readutmp module from GNUlib.
+  enable_ftpd=no  ftpd_BUILD=''
+  enable_rlogind=no  rlogind_BUILD=''
+  enable_syslogd=no  syslogd_BUILD=''
+  enable_talkd=no  talkd_BUILD=''
+  enable_telnetd=no  telnetd_BUILD=''
+  enable_uucpd=no  uucpd_BUILD=''
+  ;;
 *olaris*)
   AC_DEFINE([SOLARIS], 1, [FIXME])
   AC_DEFINE([HAVE_STREAMSPTY], 1, [FIXME])

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

Summary of changes:
 ChangeLog                   |   41 ++++++++++++
 configure.ac                |   11 +++
 libinetutils/libinetutils.h |    2 +
 src/rlogin.c                |  142 ++++++++++++++++++++++++++----------------
 src/rlogind.c               |   14 ++--
 5 files changed, 149 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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