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

Bug#509866: found the ALL CAPS bug



On Sun, Aug 30, 2009 at 01:36:24AM +0200, Cyril Brulebois wrote:
> Simon Richter <sjr@debian.org> (28/04/2009):
> > I believe the problem is line 785 of apt-pkg/deb/dpkgpm.cc:
> > 
> > | tcgetattr(0, &tt);
> 
> Hi,
> 
> thanks for that.
> 
> > The return code is not checked here; the call will fail if stdin is
> > not a terminal (in the case of d-i and autobuilders, it isn't), and
> > the termios struct ends up uninitialized, so the pty for dpkg is set
> > up randomly.
> 
> CAN SOMEBODY PLEASE LOOK INTO IT, THAT'S REALLY ANNOYING TO SEE ALL
> THOSE CAPS IN BUILD LOGS, NOT TO MENTION LOCAL BUILDS?!

Thanks for the reminder. Could you please test the attached patch and
let me know if that fixes the problem for you?

Thanks,
 Michael

=== modified file 'apt-pkg/deb/dpkgpm.cc'
--- apt-pkg/deb/dpkgpm.cc	2009-07-21 14:05:52 +0000
+++ apt-pkg/deb/dpkgpm.cc	2009-08-31 09:05:49 +0000
@@ -809,32 +809,35 @@
 
       struct	termios tt;
       struct	winsize win;
-      int	master;
-      int	slave;
+      int	master = -1;
+      int	slave = -1;
 
-      // FIXME: setup sensible signal handling (*ick*)
-      tcgetattr(0, &tt);
-      ioctl(0, TIOCGWINSZ, (char *)&win);
-      if (openpty(&master, &slave, NULL, &tt, &win) < 0) 
+      // if tcgetattr does not return zero there was a error
+      // and we do not do any pty magic
+      if (tcgetattr(0, &tt) == 0)
       {
-	 const char *s = _("Can not write log, openpty() "
-			   "failed (/dev/pts not mounted?)\n");
-	 fprintf(stderr, "%s",s);
-	 fprintf(term_out, "%s",s);
-	 master = slave = -1;
-      }  else {
-	 struct termios rtt;
-	 rtt = tt;
-	 cfmakeraw(&rtt);
-	 rtt.c_lflag &= ~ECHO;
-	 // block SIGTTOU during tcsetattr to prevent a hang if
-	 // the process is a member of the background process group
-	 // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html
-	 sigemptyset(&sigmask);
-	 sigaddset(&sigmask, SIGTTOU);
-	 sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask);
-	 tcsetattr(0, TCSAFLUSH, &rtt);
-	 sigprocmask(SIG_SETMASK, &original_sigmask, 0);
+	 ioctl(0, TIOCGWINSZ, (char *)&win);
+	 if (openpty(&master, &slave, NULL, &tt, &win) < 0) 
+	 {
+	    const char *s = _("Can not write log, openpty() "
+	    "failed (/dev/pts not mounted?)\n");
+	    fprintf(stderr, "%s",s);
+	    fprintf(term_out, "%s",s);
+	    master = slave = -1;
+	 }  else {
+	    struct termios rtt;
+	    rtt = tt;
+	    cfmakeraw(&rtt);
+	    rtt.c_lflag &= ~ECHO;
+	    // block SIGTTOU during tcsetattr to prevent a hang if
+	    // the process is a member of the background process group
+	    // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html
+	    sigemptyset(&sigmask);
+	    sigaddset(&sigmask, SIGTTOU);
+	    sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask);
+	    tcsetattr(0, TCSAFLUSH, &rtt);
+	    sigprocmask(SIG_SETMASK, &original_sigmask, 0);
+	 }
       }
 
        // Fork dpkg


Reply to: