From 087f1fb407b3fd64e7029f84eaa57d201e831578 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Thu, 23 Jan 2020 19:27:57 +0000 Subject: [PATCH] Further reduce diff between Flatpak 1.6.1 and our Flatpak-derived code Signed-off-by: Simon McVittie <smcv@collabora.com> --- src/flatpak-bwrap-private.h | 5 +++-- src/flatpak-bwrap.c | 19 +++++++++++++++---- src/flatpak-run-private.h | 16 +++++++++++----- src/flatpak-run.c | 14 +++++++++----- src/flatpak-utils.c | 3 +-- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/flatpak-bwrap-private.h b/src/flatpak-bwrap-private.h index 2a633d30c..92d6e9de2 100644 --- a/src/flatpak-bwrap-private.h +++ b/src/flatpak-bwrap-private.h @@ -48,7 +48,7 @@ void flatpak_bwrap_add_noinherit_fd (FlatpakBwrap *bwrap, void flatpak_bwrap_add_fd (FlatpakBwrap *bwrap, int fd); void flatpak_bwrap_add_args (FlatpakBwrap *bwrap, - ...); + ...) G_GNUC_NULL_TERMINATED; void flatpak_bwrap_add_arg_printf (FlatpakBwrap *bwrap, const char *format, ...) G_GNUC_PRINTF (2, 3); @@ -80,7 +80,8 @@ gboolean flatpak_bwrap_bundle_args (FlatpakBwrap *bwrap, GError **error); void flatpak_bwrap_child_setup_cb (gpointer user_data); - +void flatpak_bwrap_child_setup (GArray *fd_array, + gboolean close_fd_workaround); G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakBwrap, flatpak_bwrap_free) diff --git a/src/flatpak-bwrap.c b/src/flatpak-bwrap.c index 2ea9bdae6..c620ea2a3 100644 --- a/src/flatpak-bwrap.c +++ b/src/flatpak-bwrap.c @@ -34,8 +34,8 @@ #include "libglnx/libglnx.h" #include "flatpak-bwrap-private.h" -#include "flatpak-utils-base-private.h" #include "flatpak-utils-private.h" +#include "flatpak-utils-base-private.h" #include "glib-backports.h" @@ -323,13 +323,15 @@ flatpak_bwrap_bundle_args (FlatpakBwrap *bwrap, return TRUE; } -/* Unset FD_CLOEXEC on the array of fds passed in @user_data */ void -flatpak_bwrap_child_setup_cb (gpointer user_data) +flatpak_bwrap_child_setup (GArray *fd_array, + gboolean close_fd_workaround) { - GArray *fd_array = user_data; int i; + if (close_fd_workaround) + flatpak_close_fds_workaround (3); + /* If no fd_array was specified, don't care. */ if (fd_array == NULL) return; @@ -349,3 +351,12 @@ flatpak_bwrap_child_setup_cb (gpointer user_data) fcntl (fd, F_SETFD, 0); } } + +/* Unset FD_CLOEXEC on the array of fds passed in @user_data */ +void +flatpak_bwrap_child_setup_cb (gpointer user_data) +{ + GArray *fd_array = user_data; + + flatpak_bwrap_child_setup (fd_array, TRUE); +} diff --git a/src/flatpak-run-private.h b/src/flatpak-run-private.h index 06a9bba1d..e528dc770 100644 --- a/src/flatpak-run-private.h +++ b/src/flatpak-run-private.h @@ -6,21 +6,25 @@ * * SPDX-License-Identifier: LGPL-2.1-or-later * - * This library is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Alexander Larsson <alexl@redhat.com> */ -#pragma once +#ifndef __FLATPAK_RUN_H__ +#define __FLATPAK_RUN_H__ #include <glib.h> #include <glib-object.h> @@ -28,6 +32,7 @@ #include "libglnx/libglnx.h" #include "flatpak-bwrap-private.h" +#include "flatpak-utils-private.h" #include "glib-backports.h" void flatpak_run_add_x11_args (FlatpakBwrap *bwrap, @@ -36,3 +41,4 @@ gboolean flatpak_run_add_wayland_args (FlatpakBwrap *bwrap); void flatpak_run_add_pulseaudio_args (FlatpakBwrap *bwrap); gboolean flatpak_run_add_system_dbus_args (FlatpakBwrap *app_bwrap); gboolean flatpak_run_add_session_dbus_args (FlatpakBwrap *app_bwrap); +#endif /* __FLATPAK_RUN_H__ */ diff --git a/src/flatpak-run.c b/src/flatpak-run.c index ef3e2736b..c9a8a2cda 100644 --- a/src/flatpak-run.c +++ b/src/flatpak-run.c @@ -6,18 +6,21 @@ * * SPDX-License-Identifier: LGPL-2.1-or-later * - * This library is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Alexander Larsson <alexl@redhat.com> */ #include "flatpak-run-private.h" @@ -26,6 +29,7 @@ #include <X11/Xauth.h> #include <gio/gio.h> +#include "libglnx/libglnx.h" #include "flatpak-utils-base-private.h" #include "flatpak-utils-private.h" @@ -126,7 +130,7 @@ write_xauth (char *number, FILE *output) fclose (f); } -#endif +#endif /* ENABLE_XAUTH */ void flatpak_run_add_x11_args (FlatpakBwrap *bwrap, diff --git a/src/flatpak-utils.c b/src/flatpak-utils.c index fbea468e8..e6d829150 100644 --- a/src/flatpak-utils.c +++ b/src/flatpak-utils.c @@ -20,8 +20,6 @@ * Alexander Larsson <alexl@redhat.com> */ -#include "flatpak-utils-private.h" - #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -39,6 +37,7 @@ #include <glib.h> #include "flatpak-utils-base-private.h" +#include "flatpak-utils-private.h" /* To keep this more similar to the original file, we explicitly disable * this warning rather than fixing it */ -- GitLab