rexec: mark all fds as close-on-exec if possible

parent e8aaef81
...@@ -672,4 +672,6 @@ enum { ...@@ -672,4 +672,6 @@ enum {
#define ENOCGROUP2 ENOMEDIUM #define ENOCGROUP2 ENOMEDIUM
#define MAX_FILENO ~0U
#endif /* __LXC_MACRO_H */ #endif /* __LXC_MACRO_H */
...@@ -162,6 +162,9 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name) ...@@ -162,6 +162,9 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
if (execfd < 0) if (execfd < 0)
return; return;
ret = close_range(STDERR_FILENO, MAX_FILENO, CLOSE_RANGE_CLOEXEC);
if (ret && (errno != ENOSYS && errno != EINVAL))
fprintf(stderr, "%m - Failed to mark all file descriptors as close-on-exec\n");
fexecve(execfd, argv, envp); fexecve(execfd, argv, envp);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment