]> git.openfabrics.org - ~shefty/librdmacm.git/commit
Open files with "close on exec" flag
authorYann Droneaud <ydroneaud@opteya.com>
Tue, 16 Jul 2013 21:59:52 +0000 (23:59 +0200)
committerSean Hefty <sean.hefty@intel.com>
Wed, 17 Jul 2013 04:16:47 +0000 (21:16 -0700)
commitaceece6052de25036760a51dcd7c2ad8afe4c2d2
treee14708a457c3eac12d51c437d6b9f6fac401ea73
parenta2e698171820a90a70acf65f8dcfe29b9224633a
Open files with "close on exec" flag

File opened by librdmacm are not supposed to be inherited across
exec*(), most of the files are of no use for another program, and
others cannot be used without the associated memory mapping.

This patch changes fopen() open() and socket() to always set
close on exec flag.

This patch also add checks to configure to guess if fopen() supports
"e" flag. If O_CLOEXEC and SOCK_CLOEXEC are supported, fopen() should
support "e". If not supported, its discarded according to POSIX. Many
operating systems have support for fopen("e").

You might find more information about close on exec in the following articles:

- "Excuse me son, but your code is leaking !!!" by Dan Walsh
  http://danwalsh.livejournal.com/53603.html

- "Secure File Descriptor Handling" by Ulrich Drepper
  http://udrepper.livejournal.com/20407.html

Note: this patch won't set close on exec flag on file descriptors
created by the kernel for completion channel and such.
This is addressed by another kernel patch.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
configure.ac
src/acm.c
src/cma.c