queue: set O_CLOEXEC on installed file descriptors
authorDaniel Mack <daniel@zonque.org>
Fri, 17 Oct 2014 07:55:51 +0000 (09:55 +0200)
committerDaniel Mack <daniel@zonque.org>
Sat, 18 Oct 2014 19:00:16 +0000 (21:00 +0200)
The receiver can still opt-out for this with fcntl(), but by default,
we should really set O_CLOEXEC.

Signed-off-by: Daniel Mack <daniel@zonque.org>
queue.c

diff --git a/queue.c b/queue.c
index e89d7200719258437533952aea5c11ad274f60d6..e480378f1f4469c20647d1db73157a9df3a57dde 100644 (file)
--- a/queue.c
+++ b/queue.c
@@ -115,7 +115,7 @@ static int kdbus_queue_entry_fds_install(struct kdbus_queue_entry *entry,
 
        /* allocate new file descriptors in the receiver's process */
        for (i = 0; i < entry->fds_count; i++) {
-               fds[i] = get_unused_fd();
+               fds[i] = get_unused_fd_flags(O_CLOEXEC);
                if (fds[i] < 0) {
                        ret = fds[i];
                        goto remove_unused;
@@ -161,7 +161,7 @@ static int kdbus_queue_entry_memfds_install(struct kdbus_queue_entry *entry,
 
        /* allocate new file descriptors in the receiver's process */
        for (i = 0; i < entry->memfds_count; i++) {
-               fds[i] = get_unused_fd();
+               fds[i] = get_unused_fd_flags(O_CLOEXEC);
                if (fds[i] < 0) {
                        ret = fds[i];
                        goto remove_unused;