summaryrefslogtreecommitdiff
path: root/portal
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-12-12 14:37:23 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2019-12-12 17:02:02 +0100
commit3666eb0950f344d8e6eac1fb048d20ee9b1aee7d (patch)
tree5a611cf51a0a0e5d6fc8f7923f915f97e31e0c6c /portal
parente08cee0e828063eca4609b6052c24d293b36e0a7 (diff)
downloadflatpak-3666eb0950f344d8e6eac1fb048d20ee9b1aee7d.tar.gz
portal: Make sure we inherit the passed thought fds in Spawn()
In the start of child_setup_func we set CLOEXEC on everything > 3, so we need to undo this for the things we actually want to pass in.
Diffstat (limited to 'portal')
-rw-r--r--portal/flatpak-portal.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/portal/flatpak-portal.c b/portal/flatpak-portal.c
index 93cdd9d4..ddf9606e 100644
--- a/portal/flatpak-portal.c
+++ b/portal/flatpak-portal.c
@@ -242,6 +242,12 @@ typedef struct
} ChildSetupData;
static void
+drop_cloexec (int fd)
+{
+ fcntl (fd, F_SETFD, 0);
+}
+
+static void
child_setup_func (gpointer user_data)
{
ChildSetupData *data = (ChildSetupData *) user_data;
@@ -283,6 +289,9 @@ child_setup_func (gpointer user_data)
dup2 (fd_map[i].to, fd_map[i].final);
close (fd_map[i].to);
}
+
+ /* Ensure we inherit the final fd value */
+ drop_cloexec (fd_map[i].final);
}
/* We become our own session and process group, because it never makes sense