From 34e82f81bdbdd26b82501bc2d27d18aaab5747dd Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Fri, 31 Jul 2020 10:17:08 -0400 Subject: validate fds --preserve-fds validate file descriptors passed from podman run and podman exec --preserve-fds. Signed-off-by: Qi Wang --- pkg/rootless/rootless_linux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/rootless/rootless_linux.c') diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 0223c35ee..2e1fddc48 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -225,6 +225,16 @@ can_use_shortcut () return ret; } +int +is_fd_inherited(int fd) +{ + if (open_files_set == NULL || fd > open_files_max_fd || fd < 0) + { + return 0; + } + return FD_ISSET(fd % FD_SETSIZE, &(open_files_set[fd / FD_SETSIZE])) ? 1 : 0; +} + static void __attribute__((constructor)) init() { const char *xdg_runtime_dir; -- cgit v1.2.3-54-g00ecf