seccomp: make seccomp notifier fd non-blocking

parent 7fde74f3
...@@ -577,3 +577,15 @@ int open_beneath(int dir_fd, const char *path, unsigned int flags) ...@@ -577,3 +577,15 @@ int open_beneath(int dir_fd, const char *path, unsigned int flags)
return openat(dir_fd, path, O_NOFOLLOW | flags); return openat(dir_fd, path, O_NOFOLLOW | flags);
} }
int fd_make_nonblocking(int fd)
{
int flags;
flags = fcntl(fd, F_GETFL);
if (flags < 0)
return -1;
flags &= ~O_NONBLOCK;
return fcntl(fd, F_SETFL, flags);
}
...@@ -76,5 +76,6 @@ __hidden extern int timens_offset_write(clockid_t clk_id, int64_t s_offset, int6 ...@@ -76,5 +76,6 @@ __hidden extern int timens_offset_write(clockid_t clk_id, int64_t s_offset, int6
__hidden extern bool exists_dir_at(int dir_fd, const char *path); __hidden extern bool exists_dir_at(int dir_fd, const char *path);
__hidden extern bool exists_file_at(int dir_fd, const char *path); __hidden extern bool exists_file_at(int dir_fd, const char *path);
__hidden extern int open_beneath(int dir_fd, const char *path, unsigned int flags); __hidden extern int open_beneath(int dir_fd, const char *path, unsigned int flags);
__hidden int fd_make_nonblocking(int fd);
#endif /* __LXC_FILE_UTILS_H */ #endif /* __LXC_FILE_UTILS_H */
...@@ -1280,6 +1280,9 @@ int lxc_seccomp_load(struct lxc_conf *conf) ...@@ -1280,6 +1280,9 @@ int lxc_seccomp_load(struct lxc_conf *conf)
return -1; return -1;
} }
if (fd_make_nonblocking(ret))
return log_error_errno(-1, errno, "Failed to make seccomp listener fd non-blocking");;
conf->seccomp.notifier.notify_fd = ret; conf->seccomp.notifier.notify_fd = ret;
TRACE("Retrieved new seccomp listener fd %d", ret); TRACE("Retrieved new seccomp listener fd %d", ret);
} }
......
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