[ 
http://dev.sourcefabric.org/browse/LS-512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21939#action_21939
 ] 

Romain Beauxis commented on LS-512:
-----------------------------------

I've pushed a proposed fix in LS-512 branch. Basically it consists in forcing 
all file descriptors >= 3 to be marked close-on-exec. Should be properly tested 
on win32 and other exotic OSes. Here's a way to reproduce:

Start this process: 
  liquidsoap 'output.harbor(%external("lame - 
-"),mount="foo",single("/Users/toots/Downloads/BB Seaton Anthology CD1/09 
Forgive Them Lord.mp3"),format="audio/mpeg")'

Check without the patch that lame inherits the file descriptor for that opened 
file:

toots@zulu src  % lsof | grep lame                   
lame       1492 toots  cwd      DIR       14,2       2890  8650344 
/Users/toots/sources/savonet/liquidsoap/src
lame       1492 toots  txt      REG       14,2     369168   938271 
/usr/local/Cellar/lame/3.98.4/bin/lame
lame       1492 toots  txt      REG       14,2    1054960   414150 /usr/lib/dyld
lame       1492 toots  txt      REG       14,2  235044864 55418780 
/private/var/db/dyld/dyld_shared_cache_x86_64
lame       1492 toots    0     PIPE 0x08440770      16384          ->0x0b266af8
lame       1492 toots    1     PIPE 0x0b2665e4      16384          ->0x0b266a30
lame       1492 toots    2u     CHR       16,3  0t4233500      629 /dev/ttys003
lame       1492 toots    3     PIPE 0x0a9a5c20      16384          ->0x0a9a64b8
lame       1492 toots    4     PIPE 0x0a9a64b8      16384          ->0x0a9a5c20
lame       1492 toots    5     PIPE 0x0a9a54b4      16384          ->0x0a9a4af0
lame       1492 toots    6     PIPE 0x0a9a4af0      16384          ->0x0a9a54b4
lame       1492 toots    7r     REG       14,2    2260607 59683552 
/Users/toots/Downloads/BB Seaton Anthology CD1/09 Forgive Them Lord.mp3

Check that it no longer inherits it after applying the patch:
toots@zulu src  % lsof | grep lame
lame       9782 toots  cwd      DIR       14,2       2890  8650344 
/Users/toots/sources/savonet/liquidsoap/src
lame       9782 toots  txt      REG       14,2     369168   938271 
/usr/local/Cellar/lame/3.98.4/bin/lame
lame       9782 toots  txt      REG       14,2    1054960   414150 /usr/lib/dyld
lame       9782 toots  txt      REG       14,2  235044864 55418780 
/private/var/db/dyld/dyld_shared_cache_x86_64
lame       9782 toots    0     PIPE 0x0b266e7c      16384          ->0x0b26606c
lame       9782 toots    1     PIPE 0x0b266af8      16384          ->0x0b266a30
lame       9782 toots    2u     CHR       16,3  0t4284270      629 /dev/ttys003


> External processes inherit opened file descriptor, including opened sockets.
> ----------------------------------------------------------------------------
>
>                 Key: LS-512
>                 URL: http://dev.sourcefabric.org/browse/LS-512
>             Project: Liquidsoap
>          Issue Type: Bug
>          Components: Liquidsoap
>            Reporter: Romain Beauxis
>            Priority: Critical
>
> When liquidsoap spawns a new process using Ocaml's open_process* functions, 
> the new process is created using fork() and therefore inherits all opened 
> file descriptors from liquidsoap.
> This leads to many different type of issues, among which:
>  * If liquidsoap stops before an external process, any port opened by 
> liquidsoap remains open until all external processes have terminated
>  * All external processes have access to the file/sockets opened by 
> liquidsoap, in particular they may read a file whose content is supposed to 
> be protected (password) or listen to network traffic (source password for 
> instance)
> The problem is not easy. There are several possibilities:
>  * Define our own implementation of Unix.open_process*
>  * Use some shell trickery to close the descriptors before invoking the new 
> process. Something like:
>   "/bin/ls /dev/fd/ | while read i; do if test "$i" -ge "3"; then exec 
> "$i<&-" 2>/dev/null; fi done; my_process
>  * Convince OCaml's maintainer to apply some patch and wait for a new release 
> of OCaml...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://dev.sourcefabric.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Savonet-devl mailing list
Savonet-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-devl

Répondre à