diff --git a/src/flatpak-bwrap-private.h b/src/flatpak-bwrap-private.h index 2a633d30cd609b870950f287cbfac8b79232c8a3..92d6e9de26a5982712aa034a26754fc9cab8853a 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 2ea9bdae697a421a28701807f6bc34963860b62c..c620ea2a38a5939be78abfd095e6b5eb4407fee5 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 06a9bba1d840a96a55c3fdafae469e932e51455b..e528dc7708e6f0f00a32fcc8a0d8440bd93bcd47 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 ef3e2736bf54069e5229f0545c6f0e688d02a9eb..c9a8a2cda5f22abf074e01b9b01fc25bdb4e976f 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 fbea468e8754bab96a0a65ba83bce9828fe31ee1..e6d82915081a4657ac377c04f42a99e5469726a6 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 */