Bash leaks heredoc fd to child processes

2017-01-17 Thread Siteshwar Vashisht
Hello,

Bash leaks heredoc fd to child processes if heredoc string contains command 
substitution.

Reproducer code :

$ cat test.sh 
#!/bin/bash

cat 

Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread Chet Ramey
On 1/17/17 8:24 AM, Siteshwar Vashisht wrote:
> Hello,
> 
> Bash leaks heredoc fd to child processes if heredoc string contains command 
> substitution.
> 
> Reproducer code :

What is `pvs'?

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread John McKown
On Tue, Jan 17, 2017 at 10:06 AM, Chet Ramey  wrote:

> On 1/17/17 8:24 AM, Siteshwar Vashisht wrote:
> > Hello,
> >
> > Bash leaks heredoc fd to child processes if heredoc string contains
> command substitution.
> >
> > Reproducer code :
>
> What is `pvs'?
>
>
​Probably a part of LVM (Logical Volume Manager),

VS(8)
System Manager's Manual
 PVS(8)

NAME
   pvs — report information about physical volumes

​


-- 
There’s no obfuscated Perl contest because it’s pointless.

—Jeff Polk

Maranatha! <><
John McKown


Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread Siteshwar Vashisht


- Original Message -
> From: "John McKown" 
> To: "Chester Ramey" 
> Cc: bug-bash@gnu.org, "Siteshwar Vashisht" 
> Sent: Tuesday, January 17, 2017 5:14:44 PM
> Subject: Re: Bash leaks heredoc fd to child processes
> 
> ​Probably a part of LVM (Logical Volume Manager),
> 
> VS(8)
> System Manager's Manual
>  PVS(8)
> 
> NAME
>pvs — report information about physical volumes

Yes, it's the utility used in my reproducer. I used it because it was verbose 
about the descriptor leak.

For reference, this is what I was working on 
https://bugzilla.redhat.com/show_bug.cgi?id=1413676
 
> 
> ​
> 
> 
> --
> There’s no obfuscated Perl contest because it’s pointless.
> 
> —Jeff Polk
> 
> Maranatha! <><
> John McKown
> 

-- 
--
Siteshwar Vashisht



Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread Chet Ramey
On 1/17/17 12:38 PM, Siteshwar Vashisht wrote:

>> NAME
>>pvs — report information about physical volumes
> 
> Yes, it's the utility used in my reproducer. I used it because it was verbose 
> about the descriptor leak.

It's ok, I was able to reproduce it using something else.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread Chet Ramey
On 1/17/17 8:24 AM, Siteshwar Vashisht wrote:
> Hello,
> 
> Bash leaks heredoc fd to child processes if heredoc string contains command 
> substitution.

Thanks for the report. Here's a simpler patch.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.4-patched/redir.c	2016-06-02 20:22:24.0 -0400
--- redir.c	2017-01-17 13:23:40.0 -0500
***
*** 470,473 
--- 467,472 
  }
  
+   SET_CLOSE_ON_EXEC (fd);
+ 
errno = r = 0;		/* XXX */
/* write_here_document returns 0 on success, errno on failure. */


Re: Bash leaks heredoc fd to child processes

2017-01-17 Thread Siteshwar Vashisht


- Original Message -
> From: "Chet Ramey" 
> To: "Siteshwar Vashisht" , bug-bash@gnu.org
> Cc: "chet ramey" 
> Sent: Tuesday, January 17, 2017 7:42:07 PM
> Subject: Re: Bash leaks heredoc fd to child processes
> 
> Thanks for the report. Here's a simpler patch.

Looks good to me. Thanks!

> 
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
> 

-- 
--
Siteshwar Vashisht