1 /*
2  * Copyright (C) 2018, Matthias Clasen
3  *
4  * This file is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 3.0 of the
7  * License.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  * SPDX-License-Identifier: LGPL-3.0-only
18  */
19 
20 #pragma once
21 
22 #include <libportal/types.h>
23 
24 G_BEGIN_DECLS
25 
26 /**
27  * XdpSpawnFlags:
28  * @XDP_SPAWN_FLAG_NONE: No flags
29  * @XDP_SPAWN_FLAG_CLEARENV: Clear the environment
30  * @XDP_SPAWN_FLAG_LATEST: Spawn the latest version of the app
31  * @XDP_SPAWN_FLAG_SANDBOX: Spawn in a sandbox (equivalent to the --sandbox option of flatpak run)
32  * @XDP_SPAWN_FLAG_NO_NETWORK: Spawn without network (equivalent to the --unshare=network option of flatpak run)
33  * @XDP_SPAWN_FLAG_WATCH: Kill the sandbox when the caller disappears from the session bus
34  *
35  * Flags influencing the spawn operation and how the
36  * new sandbox is created.
37  */
38 typedef enum {
39   XDP_SPAWN_FLAG_NONE       = 0,
40   XDP_SPAWN_FLAG_CLEARENV   = 1 << 0,
41   XDP_SPAWN_FLAG_LATEST     = 1 << 1,
42   XDP_SPAWN_FLAG_SANDBOX    = 1 << 2,
43   XDP_SPAWN_FLAG_NO_NETWORK = 1 << 3,
44   XDP_SPAWN_FLAG_WATCH      = 1 << 4,
45 } XdpSpawnFlags;
46 
47 XDP_PUBLIC
48 void         xdp_portal_spawn                 (XdpPortal            *portal,
49                                                const char           *cwd,
50                                                const char * const   *argv,
51                                                int                  *fds,
52                                                int                  *map_to,
53                                                int                   n_fds,
54                                                const char * const   *env,
55                                                XdpSpawnFlags         flags,
56                                                const char * const   *sandbox_expose,
57                                                const char * const   *sandbox_expose_ro,
58                                                GCancellable         *cancellable,
59                                                GAsyncReadyCallback   callback,
60                                                gpointer              data);
61 
62 XDP_PUBLIC
63 pid_t        xdp_portal_spawn_finish          (XdpPortal            *portal,
64                                                GAsyncResult         *result,
65                                                GError              **error);
66 
67 XDP_PUBLIC
68 void        xdp_portal_spawn_signal           (XdpPortal            *portal,
69                                                pid_t                 pid,
70                                                int                   signal,
71                                                gboolean              to_process_group);
72 
73 G_END_DECLS
74