Bug#746434: apt: new apt breaks a shell script by reading from standard input when it shouldn't

2014-04-30 Thread Michael Vogt
On Tue, Apr 29, 2014 at 10:40:52PM +, Gianluca Borello wrote:
 Package: apt
 Version: 1.0.2
 Severity: normal

Thanks for your bugeport.
 
 I have an automated installation script that doesn't work anymore on Sid. 
 This is a snippet of code:
 
 #!/bin/bash
 
 apt-get -qq -y install iftop
 neverexecuted
 
 If executed by piping it to bash, the very first time (when the package is 
 not installed), I get:
[..]

I can reproduce this and bisected it to commit 872816. The attached
diff fixes it for me, would be great if you could confirm.


Cheers,
 Michael
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 959d064..bc86258 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1239,9 +1239,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
   // if tcgetattr does not return zero there was a error
   // and we do not do any pty magic
   _error-PushToStack();
-  if (tcgetattr(STDOUT_FILENO, tt) == 0)
+  if (tcgetattr(STDIN_FILENO, tt) == 0)
   {
-	 ioctl(0, TIOCGWINSZ, (char *)win);
+	 ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)win);
 	 if (openpty(master, slave, NULL, tt, win)  0)
 	 {
 	_error-Errno(openpty, _(Can not write log (%s)), _(Is /dev/pts mounted?));


Bug#746434: apt: new apt breaks a shell script by reading from standard input when it shouldn't

2014-04-30 Thread Gianluca Borello
On Wed, Apr 30, 2014 at 1:49 AM, Michael Vogt m...@ubuntu.com wrote:

 I can reproduce this and bisected it to commit 872816. The attached
 diff fixes it for me, would be great if you could confirm.


I can confirm it's fixed, thanks.

Two notes:

1) Despite the right behavior, I now get an error on screen, not sure
it's what you wanted:

# cat test.sh | bash
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  git git-man libbind9-80 libclass-isa-perl libdns88 liberror-perl libffi5
  libisc84 libisccc80 libisccfg82 liblwres80 libmpc2 librtmp0 libswitch-perl
  openssh-blacklist openssh-blacklist-extra
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  iftop
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/41.1 kB of archives.
After this operation, 120 kB of additional disk space will be used.
E: Can not write log (Is stdout a terminal?) - tcgetattr (22: Invalid argument)
Selecting previously unselected package iftop.
(Reading database ... 48089 files and directories currently installed.)
Preparing to unpack .../iftop_1.0~pre4-2_i386.deb ...
Unpacking iftop (1.0~pre4-2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up iftop (1.0~pre4-2) ...
bash: line 4: neverexecuted: command not found

Notice E: Can not write log (Is stdout a terminal?) - tcgetattr (22:
Invalid argument)

I'm sure this never happened before.

2) I'm less worried about Debian since wheezy still works and I'm sure
the next stable will contain the fix, but actually I have an important
script that my customers are using that is broken on Ubuntu 14.04
because of this bug. It gets piped to bash by design, so everything
after the first apt-get is never executed. Do you happen to know how
long it will take for this to get to Ubuntu?


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#746434: apt: new apt breaks a shell script by reading from standard input when it shouldn't

2014-04-29 Thread Gianluca Borello
Package: apt
Version: 1.0.2
Severity: normal

Hello,

I have an automated installation script that doesn't work anymore on Sid. This 
is a snippet of code:

#!/bin/bash

apt-get -qq -y install iftop
neverexecuted

If executed by piping it to bash, the very first time (when the package is not 
installed), I get:

# cat test.sh | bash
neverexecuted
Selecting previously unselected package iftop.
(Reading database ... 69655 files and directories currently installed.)
Preparing to unpack .../iftop_1.0~pre2-5_amd64.deb ...
Unpacking iftop (1.0~pre2-5) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up iftop (1.0~pre2-5) ...

As you can see, neverexecuted is printed on stdout (by apt-get if I look 
through strace) instead of being executed by bash at a later time.

If executed the second time (when the package is already installed), I 
correctly get:

# cat test.sh | bash
bash: line 4: neverexecuted: command not found

apt version: 1.0.2

I'm sure this used to work a few weeks ago.

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt depends on:
ii  debian-archive-keyring  2012.4
ii  gnupg   1.4.16-1.1
ii  libapt-pkg4.12  1.0.2
ii  libc6   2.18-5
ii  libgcc1 1:4.9.0-1
ii  libstdc++6  4.9.0-1

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc none
ii  aptitude0.6.10-1
ii  dpkg-dev1.17.8
ii  python-apt  0.9.3.6

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org