summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2011-04-12 13:57:34 +0200
committerDavid Sommerseth <davids@redhat.com>2011-04-12 13:57:34 +0200
commit1680cbeb40e76dd975bc8ace756e74771901d607 (patch)
tree23fca42e696d356b109d363ae4eaaa5f3cb0320e
parent9f0d17aa532f7c43e0d849b3d2fdd3488362a493 (diff)
downloadpython-ethtool-0.7.tar.gz
python-ethtool-0.7.tar.xz
python-ethtool-0.7.zip
Force O_CLOEXEC on the NETLINK socketv0.7
To avoid that the NETLINK socket is available to forked children, set the FD_CLOEXEC flag on the NETLINK socket. This also avoids SELinux from complaining on Fedora 14. For more information: https://bugzilla.redhat.com/show_bug.cgi?id=689843 Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r--python-ethtool/etherinfo.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
index 42973ad..2cebdfb 100644
--- a/python-ethtool/etherinfo.c
+++ b/python-ethtool/etherinfo.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <asm/types.h>
#include <sys/socket.h>
@@ -382,6 +383,13 @@ int open_netlink(struct etherinfo_obj_data *data)
*data->nlc = nl_handle_alloc();
nl_connect(*data->nlc, NETLINK_ROUTE);
if( (*data->nlc != NULL) ) {
+ /* Force O_CLOEXEC flag on the NETLINK socket */
+ if( fcntl(nl_socket_get_fd(*data->nlc), F_SETFD, FD_CLOEXEC) == -1 ) {
+ fprintf(stderr,
+ "**WARNING** Failed to set O_CLOEXEC on NETLINK socket: %s\n",
+ strerror(errno));
+ }
+
/* Tag this object as an active user */
pthread_mutex_lock(&nlc_counter_mtx);
(*data->nlc_users)++;