From 62a669d9f04e83debe729347617a935707badc7e Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Sat, 1 Oct 2011 14:14:27 +0100 Subject: Mark simple file and socket descriptors as uninheritable. This patch creates two utility functions: int open_cloexec(pathname, flags) int create_cloexec(pathname, flags, mode) These return a file descriptor with the CLOEXEC flag set, to ensure that the descriptor is not inherited across a fork/exec operation. The sockets returned by: _x_io_tcp_connect_ipv4() _x_io_tcp_connect() now also have their CLOEXEC flag set. --- src/libw32dll/wine/registry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libw32dll') diff --git a/src/libw32dll/wine/registry.c b/src/libw32dll/wine/registry.c index 0ccf3de9b..6b9a30fa3 100644 --- a/src/libw32dll/wine/registry.c +++ b/src/libw32dll/wine/registry.c @@ -89,7 +89,7 @@ static void open_registry(void) printf("Multiple open_registry(>\n"); return; } - fd = open(localregpathname, O_RDONLY); + fd = open_cloexec(localregpathname, O_RDONLY); if (fd == -1) { printf("Creating new registry\n"); @@ -132,7 +132,7 @@ static void save_registry(void) int fd, i; if (!regs) init_registry(); - fd = open(localregpathname, O_WRONLY | O_CREAT, 00666); + fd = create_cloexec(localregpathname, O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (fd == -1) { printf("Failed to open registry file '%s' for writing.\n", -- cgit v1.2.3 From 5db268a002e7a102855e84a3ff5e1c27ca7cb927 Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Mon, 3 Oct 2011 12:11:56 +0100 Subject: Prefix open_cloexec() and create_cloexec() with xine_, and add new xine_socket_cloexec() function. --- src/libw32dll/wine/registry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libw32dll') diff --git a/src/libw32dll/wine/registry.c b/src/libw32dll/wine/registry.c index 6b9a30fa3..7c4c0f5d8 100644 --- a/src/libw32dll/wine/registry.c +++ b/src/libw32dll/wine/registry.c @@ -89,7 +89,7 @@ static void open_registry(void) printf("Multiple open_registry(>\n"); return; } - fd = open_cloexec(localregpathname, O_RDONLY); + fd = xine_open_cloexec(localregpathname, O_RDONLY); if (fd == -1) { printf("Creating new registry\n"); @@ -132,7 +132,7 @@ static void save_registry(void) int fd, i; if (!regs) init_registry(); - fd = create_cloexec(localregpathname, O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + fd = xine_create_cloexec(localregpathname, O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (fd == -1) { printf("Failed to open registry file '%s' for writing.\n", -- cgit v1.2.3