Commit Graph

14 Commits

Author SHA1 Message Date
Alexander Larsson
9a4f5084ad run: (re-)allow forwarding fds into flatpak run
It turns out d91660fe2a accidentally
broke the inheritance of non-stdin/out file descriptor into children
of "flatpak run" which broke the fd passing in the flatpak spawn portal.

This reverts that, allowing all fds not specifically marked as CLOEXEC
by other means to be inherited into the child.

Fortunately the regression was not in any stable release.
2019-12-12 17:02:02 +01:00
Alexander Larsson
d91660fe2a Work around deadlocks in g_spawn by manually clo-exec:ing fds
As per https://gitlab.gnome.org/GNOME/glib/merge_requests/490
there is a bug in glib < 2.60 where g_spawn_* can sometimes deadlock
due to using malloc in the child func to close fds.

We work around this in places where the code is (potentially) threaded
by passing glib flags to leave fds alone and then do a very naive
(but safe) fd cloexec loop ourselves.
2019-09-30 12:15:36 +02:00
Matthew Leeds
e8816b7663 Remove extra newlines in variable definiton blocks
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.

Here's the command I used:

perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`

I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Alexander Larsson
9d8216ece2 Fix memleak in flatpak_bwrap_bundle_args 2018-12-10 13:53:08 +01:00
Alexander Larsson
7078a7f087 Make per-app generated files read-only
We generate various configuration files for each sandbox instance,
and expose them to the sandbox using flatpak_bwrap_add_args_data,
which in the end passed --bind-data to bwrap. These files are not
sensitive or shared, but it still doesn't really make sense for
the sandbox to allow them to be modified, so lets switch them
to --ro-bind-data.

This affects these files in the sandbox:

 $HOME/.var/app/$APPID/config/user-dirs.dirs
 /etc/group
 /etc/ld.so.conf
 /etc/passwd
 /etc/pkcs11/modules/p11-kit-trust.module
 /etc/pkcs11/pkcs11.conf
 /etc/timezone
 /run/flatpak/ld.so.conf.d/*.conf
 /run/user/$UID/pulse/config
 /run/user/$UID/Xauthority
2018-11-12 14:13:05 +01:00
Matthias Clasen
868552cb1f Fix localization
On the library side, we need to include gi18n-lib in order
to use dgettext for _().

Closes: #2163

Closes: #2150
Approved by: alexlarsson
2018-10-02 06:21:49 +00:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Alexander Larsson
d59e79ee79 FlatpakBwrap: Add flatpak_bwrap_add_noinherit_fd
This just keeps the fd alive until the FlatpakBwrap is freed, it
doesn't actually pass it on to the child.

We want to use this to keep a file lock held until the sandbox has
started where it takes over the lock.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00
Alexander Larsson
960d20448c common: Rename all private headers to *-private.h
This is the start of the merging of lib/* into common/*

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Alexander Larsson
6a2fe7d3e8 Revert "build: Bundle bwrap arguments when building too"
This reverts commit b0eaae2f51.
2018-05-16 16:11:55 +02:00
Alexander Larsson
b0eaae2f51 build: Bundle bwrap arguments when building too 2018-05-16 15:56:05 +02:00
Alexander Larsson
ade25b0ff8 Support --data=fd format in flatpak_bwrap_bundle_args
This is useful for the dbus-proxy, and complements the old --data fd format for
bubblewrap.

Closes: #1676
Approved by: alexlarsson
2018-05-16 09:21:51 +00:00
Alexander Larsson
a39303f763 FlatpakBwrap: Add more helper functions
Closes: #1676
Approved by: alexlarsson
2018-05-16 09:21:51 +00:00
Alexander Larsson
8ef735369d Break out FlatpakBwrap to its own file
This is pure code motion

Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00