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

X Strike Force X.Org X11 SVN commit: r3951 - in trunk/app/xutils/debian: . patches



Author: julien
Date: 2006-11-05 22:03:44 -0500 (Sun, 05 Nov 2006)
New Revision: 3951

Added:
   trunk/app/xutils/debian/patches/02_luit_fix_race_condition.diff
Modified:
   trunk/app/xutils/debian/changelog
   trunk/app/xutils/debian/patches/series
Log:
* Add patch from upstream git to fix race condition in luit (closes:
  #291137).  Thanks, Juliusz Chroboczek!

Modified: trunk/app/xutils/debian/changelog
===================================================================
--- trunk/app/xutils/debian/changelog	2006-11-06 02:29:52 UTC (rev 3950)
+++ trunk/app/xutils/debian/changelog	2006-11-06 03:03:44 UTC (rev 3951)
@@ -1,3 +1,10 @@
+xutils (1:7.1.ds.2-2) UNRELEASED; urgency=low
+
+  * Add patch from upstream git to fix race condition in luit (closes:
+    #291137).  Thanks, Juliusz Chroboczek!
+
+ -- Julien Cristau <julien.cristau@ens-lyon.org>  Mon,  6 Nov 2006 03:49:31 +0100
+
 xutils (1:7.1.ds.2-1) unstable; urgency=low
 
   * Internal directory name cleanup. This means we want a new .orig.tar.gz for

Added: trunk/app/xutils/debian/patches/02_luit_fix_race_condition.diff
===================================================================
--- trunk/app/xutils/debian/patches/02_luit_fix_race_condition.diff	                        (rev 0)
+++ trunk/app/xutils/debian/patches/02_luit_fix_race_condition.diff	2006-11-06 03:03:44 UTC (rev 3951)
@@ -0,0 +1,146 @@
+From 33c99a9408fc236ec68cc027c1caddc805e80efe Mon Sep 17 00:00:00 2001
+From: Juliusz Chroboczek <jch@pps.jussieu.fr>
+Date: Sun, 5 Nov 2006 23:43:52 +0100
+Subject: [PATCH] Set up parent pty before forking (bug 8490).
+This avoids a race condition when the child reads the terminal settings
+before the parent has set the pty up.
+---
+ luit.c |   76 +++++++++++++++++++++++++++++++++------------------------------
+ 1 files changed, 40 insertions(+), 36 deletions(-)
+
+diff --git a/luit.c b/luit.c
+index c4e1f91..99cee82 100644
+--- luit/luit.c
++++ luit/luit.c
+@@ -434,6 +434,17 @@ convert(int ifd, int ofd)
+     return 0;
+ }
+         
++static void
++sigwinchHandler(int sig)
++{
++    sigwinch_queued = 1;
++}
++
++static void
++sigchldHandler(int sig)
++{
++    sigchld_queued = 1;
++}
+ 
+ static int
+ condom(int argc, char **argv)
+@@ -444,6 +455,7 @@ condom(int argc, char **argv)
+     char *path;
+     char **child_argv;
+     int rc;
++    int val;
+ 
+     rc = parseArgs(argc, argv, child_argv0,
+                    &path, &child_argv);
+@@ -461,6 +473,29 @@ condom(int argc, char **argv)
+         perror("Couldn't drop priviledges");
+         exit(1);
+     }
++#ifdef SIGWINCH
++    installHandler(SIGWINCH, sigwinchHandler);
++#endif
++    installHandler(SIGCHLD, sigchldHandler);
++
++    rc = copyTermios(0, pty);
++    if(rc < 0)
++        FatalError("Couldn't copy terminal settings\n");
++
++    rc = setRawTermios();
++    if(rc < 0)
++        FatalError("Couldn't set terminal to raw\n");
++
++    val = fcntl(0, F_GETFL, 0);
++    if(val >= 0) {
++        fcntl(0, F_SETFL, val | O_NONBLOCK);
++    }
++    val = fcntl(pty, F_GETFL, 0);
++    if(val >= 0) {
++        fcntl(pty, F_SETFL, val | O_NONBLOCK);
++    }
++
++    setWindowSize(0, pty);
+ 
+     pid = fork();
+     if(pid < 0) {
+@@ -470,6 +505,10 @@ condom(int argc, char **argv)
+ 
+     if(pid == 0) {
+         close(pty);
++#ifdef SIGWINCH
++        installHandler(SIGWINCH, SIG_DFL);
++#endif
++        installHandler(SIGCHLD, SIG_DFL);
+         child(line, path, child_argv);
+     } else {
+         free(child_argv);
+@@ -490,6 +529,7 @@ child(char *line, char *path, char **arg
+     close(0);
+     close(1);
+     close(2);
++
+     pgrp = setsid();
+     if(pgrp < 0) {
+         kill(getppid(), SIGABRT);
+@@ -517,53 +557,17 @@ child(char *line, char *path, char **arg
+     exit(1);
+ }
+ 
+-static void
+-sigwinchHandler(int sig) {
+-    sigwinch_queued = 1;
+-}
+-
+-static void
+-sigchldHandler(int sig)
+-{
+-    sigchld_queued = 1;
+-}
+-
+ void
+ parent(int pid, int pty)
+ {
+     unsigned char buf[BUFFER_SIZE];
+     int i;
+-    int val;
+     int rc;
+ 
+     if(verbose) {
+         reportIso2022(outputState);
+     }
+ 
+-#ifdef SIGWINCH
+-    installHandler(SIGWINCH, sigwinchHandler);
+-#endif
+-    installHandler(SIGCHLD, sigchldHandler);
+-
+-    rc = copyTermios(0, pty);
+-    if(rc < 0)
+-        FatalError("Couldn't copy terminal settings\n");
+-
+-    rc = setRawTermios();
+-    if(rc < 0)
+-        FatalError("Couldn't set terminal to raw\n");
+-
+-    val = fcntl(0, F_GETFL, 0);
+-    if(val >= 0) {
+-        fcntl(0, F_SETFL, val | O_NONBLOCK);
+-    }
+-    val = fcntl(pty, F_GETFL, 0);
+-    if(val >= 0) {
+-        fcntl(pty, F_SETFL, val | O_NONBLOCK);
+-    }
+-
+-    setWindowSize(0, pty);
+-
+     for(;;) {
+         rc = waitForInput(0, pty);
+ 
+-- 
+1.4.3.2
+

Modified: trunk/app/xutils/debian/patches/series
===================================================================
--- trunk/app/xutils/debian/patches/series	2006-11-06 02:29:52 UTC (rev 3950)
+++ trunk/app/xutils/debian/patches/series	2006-11-06 03:03:44 UTC (rev 3951)
@@ -1 +1,2 @@
 01_sessreg_implement_hostname_hashing.diff -p0
+02_luit_fix_race_condition.diff -p0



Reply to: