Your message dated Sun, 29 Jan 2017 22:28:55 +0200
with message-id <20170129202855.nhq4nn3kuzizw3lx@localhost>
and subject line This has been fixed in 2.27-2
has caused the Debian Bug report #853109,
regarding grep-2.27-1 fails when >/dev/null 2>&1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
853109: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853109
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: grep
Version: 2.27-1
Severity: serious
Tags: patch fixed-upstream
Control: forwarded -1 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25283

This is a bug that was reported to debian-testing.

Severity is based on the fact that grep is a tool where a wrong
return value has the potential to cause much (and hard to detect)
harm in scripts.

The patch is in the upstream bug.


Original report copied from Lars Bro
  https://lists.debian.org/debian-testing/2017/01/msg00000.html
follows:

I am using Debian Stretch, obtained with debootstrap (as of Jan 02 2017). Linux 
kernel of the host is 4.4.6, and the following is run in a chroot. File system 
is ext4.

When I try to run "./configure" of one of the applications I use, it fails, 
claiming that gmake is not present.

When looking into the "configure script" I find this construct:

/bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1

And when I test it, I see this:

root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1
root@mini:/# echo $?
2
root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>/dev/null
root@mini:/# echo $?
0
root@mini:/#

There is apparently something that goes wrong when "dup(2)" is used as in 2>&1

I did an strace of the two constructs:
This is the failing:

"/bin/sh -c 'make --version | gre"..., 8192) = 55
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(1, 2)

[pid 11678] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11678] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1
EINVAL 
(Invalid argument)


And this one works

read(0,  /bin/sh -c 'make --version | grep GNU' > /dev/null
2>/dev/null
" /bin/sh -c 'make --version | gr"..., 8192) = 64
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 2)                              = 2
close(3)

[pid 11689] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11689] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = 0

This suggests that there is something with the "splice(2)" system call.

I tried with grep_2.25-6 wich was in Stretch before. It works as below:

[pid 11821] <... read resumed> "GNU Make 4.1\nBuilt for x86_64-
pc"..., 
32768) = 297
...
[pid 11821] read(0, "", 32768)          = 0
[pid 11821] write(1, "GNU Make 4.1\nLicense GPLv3+: GNU"..., 91) = 91


It seems to work because it uses read(0,...) and write(1,...) instead of 
splice().

--- End Message ---
--- Begin Message ---
Version: 2.27-2


grep (2.27-2) unstable; urgency=low

  * Upstream patches to solve issues when standard input is a file in Linux
    /proc file system and standard output is /dev/null:
...
    - upstream-grep-fix-bug-dev-null-output.patch
...
 -- Santiago Ruano Rinc<C3><B3>n <santi...@debian.org>  Mon, 23 Jan 2017 
19:18:59 +0100


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--- End Message ---

Reply via email to