Commit Graph

45 Commits

Author SHA1 Message Date
Matthew Leeds
d5909171bb context: Improve description of --persist
The --persist option makes a subpath in the user's home directory
available in the sandbox. Make the description more clear accordingly.
2019-12-01 15:50:29 -08:00
Alexander Larsson
921d1c9b87 run: In sandboxed mode, if still allowing dbus, only allow $appid.Sandboxed.*
This means sandboxes with dbus access can use portals etc, but they can't
talk to the main app, or impersonate it, but you can still use dbus and
well-known names to talk to them if needed.

It does mean however that if you use this, different sandboxes can see each
other on the bus, so be careful.
2019-11-26 09:52:07 +01:00
Alexander Larsson
13be8b6365 common: Add flatpak_context_adds_permissions()
We want to use this in the update portal to catch the case
when some new permission was added and disallow self-updates in this case.
2019-10-02 14:57:11 +02:00
Umang Jain
3c55320539 context: Add support forexposing extra app id dirs
This will be used to export old app id dirs after a rebase.

Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Valentin David
8ce289b4c3 Add support for PCSC socket
Closes: #2778
Approved by: alexlarsson
2019-04-12 06:37:44 +00:00
Matthias Clasen
67b8d19f93 Write out negative D-Bus policy entries
Write out =none lines for D-Bus policy entries.

Closes: #2818
Approved by: alexlarsson
2019-04-12 06:31:05 +00:00
Matthias Clasen
44c540a1c4 Allow overriding bus names to none
flatpak override could set a bus name policy to
talk or own, but not to none. Fix this oversight.

Closes: https://github.com/flatpak/flatpak/issues/2722

Closes: #2818
Approved by: alexlarsson
2019-04-12 06:31:05 +00:00
Rafael Fontenelle
95e692794b Fix misspellings
Closes: #2807
Approved by: matthiasclasen
2019-04-08 12:50:42 +00: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
Matthew Leeds
a0d3d65476 Remove extra newlines near curly braces
Edit uncrustify.cfg to add options to remove extra newlines near opening
and closing braces, and run uncrustify again.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Alexander Larsson
28e96288c4 Fix issues with XDG_RUNTIME_DIR being /var/run which is a symlink
Whenever we use $XDG_RUNTIME_DIR and expose it somehow in the sandbox
we fully resolve the path, because if (as happens on gentoo for instance)
it contains /var/run -> ../run, then flatpak thinks we need to
add the /var/run symlink in the runtime even though we already
exposed that.

Closes: #2710
Approved by: matthiasclasen
2019-02-20 19:43:28 +00:00
Matthias Clasen
6b59406e80 Consistently use Unicode ellipsis
Now that we're moving away from a pure ASCII esthetic,
it looks odd to me to have a mixture of 3 dots and
proper ellipsis, so switch everything over to use
U+2026 instead of 3 dots.

Some minor other formatting and string changes
are included here as well.

Closes: #2454
Approved by: alexlarsson
2018-12-21 08:07:25 +00:00
Matthias Clasen
40854e00df Fix misleading error message
The error messages here make it appear that values can
be prepended with a '!', but a few lines down we throw
an error if thats the case.

Closes: #2298
Approved by: matthiasclasen
2018-11-10 16:09:47 +00:00
Patrick Griffis
d6e51ede6d Implicity grant MPRIS2 permissions
This should be safe to expose without requiring everybody request
it.

Closes: #2226
Approved by: alexlarsson
2018-10-11 12:51:55 +00:00
Alexander Larsson
99fbbc25c6 build-finish: Inherit permissions from runtime by default
In version 0.99.1 (065053775b) flatpak
stopped inheriting permissions from the runtime, because that made
the story about application permissions way to complicated. What
we want is to have a static set of permissions for the app that
is frozen at install time.

However, inheriting permissions from the runtime makes a lot of sense
as certain permissions are required from the runtime, in particular this
is used by the kde runtime to read the kdeglobals file, etc.

So, to combine the best of the two worlds, we now do inherit permissions,
but at build-time (and you can disable it if you want). This way
kde apps don't have to repeat themselves, but we still get static
application permissions.

Closes: #2230
Approved by: alexlarsson
2018-10-10 15:40:58 +00:00
Alexander Larsson
35b92d7237 Support --allow=canbus for AF_CAN access
This fixes https://github.com/flatpak/flatpak/issues/2176

Closes: #2179
Approved by: alexlarsson
2018-10-03 14:31:30 +00: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
Matthias Clasen
9d0fbdd0b4 FlatpakContext: Avoid flatpak_fail
flatpak_fail is a convenient shortcut, but falls short
for actual error reporting. Use proper G_OPTION_ERROR
error codes here.

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
065053775b run: Never inherit permissions from the runtime
We want inherit environment variables, but not actual permissions,
those need to be requested by the app only.

Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Joonas Sarajärvi
59ecad0f29 Add ssh-auth socket support
SSH authentication sockets can be placed in a number of places, so it
is difficult for applications to just mount a fixed directory or
directories, hoping that SSH_AUTH_SOCK points somewhere inside the
mounted content.

Closes: #1764
Approved by: alexlarsson
2018-06-19 07:11:36 +00:00
Alexander Larsson
7311eff800 Fix regression with --own=name
We deleted the "filtered" policy, but forgot to delete it in one place.

This fixes https://github.com/flatpak/flatpak/issues/1761
2018-06-08 14:39:35 +02:00
Alexander Larsson
a84e6195a8 Remove newlines from GError messages
These are not supposed to be in the message, but by the person printing the error.
2018-05-29 16:37:21 +02:00
Alexander Larsson
fd15690934 Simplify default application dbus access rules
Now that name.* matches the name itself we can simplify the default rule
from `--own=name --own-name=name.*` to just `--own-name=name.*`.

Closes: #1730
Approved by: alexlarsson
2018-05-29 10:23:58 +00:00
Alexander Larsson
7739209a74 context: Add --allow=bluetooth
This gives access to AF_BLUETOOTH sockets in the seccomp rules. You additionally
need to give network access for the sockets to really work, because the
kernel doesn't (yet) namespace bluetooth sockets.

Closes: #1721
Approved by: alexlarsson
2018-05-28 13:06:50 +00:00
Alexander Larsson
dcca240bee run: Break out generation of run flags from context to helper
This also adds a call to this from flatpak build, although it is
not (yet) strictly necessary as all the flags it sets so far
are always set when building. This may change in the future though.

Closes: #1721
Approved by: alexlarsson
2018-05-28 13:06:50 +00:00
Alexander Larsson
efb92704fe Merge lib/* into common
This moves all the files from lib into common, and it also adds all the libflatpak
sources into libflatpak-common, making libflatpak just a wrapper around the common
helper library.

This move allows the CLI to use all the code from libflatpak. We were already doing
this with a few things like flatpak-error*.[ch], and we want to do it even more
when sharing FlatpakTransaction. This also allows use to slowly move
the CLI to using the libflatpak apis for some things.

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Alexander Larsson
1ad3b8c30b Move FlatpakCompletion to app/flatpak-complete.[ch]
Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Alexander Larsson
c570e09ac9 common: Rename all generated files to *-dbus-generated.[ch]
Easier to spot them this way

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +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
dac54c82e8 run: Clean up how we launch the proxy
This uses FlatpakBwrap to simplify the setup of the dbus-proxy,
resulting in cleaner code, but also a better base for future work
to pass pre-created socket fds into the proxy instead of paths.

Closes: #1676
Approved by: alexlarsson
2018-05-16 09:21:51 +00:00
Alexander Larsson
94ce9da571 dir: Fix saving of features in metadata
This fixes https://github.com/flatpak/flatpak/issues/1617
2018-04-30 14:33:38 +02:00
Sam Spilsbury
b0b8f55ecb run: Export flatpak_context_get_session_bus_policy_allowed_own_names
We will use this later to work out which .service files we can export
based on names that we are allowed to own.

Closes: #1589
Approved by: alexlarsson
2018-04-19 07:31:25 +00:00
Alexander Larsson
a6ec434aed run: Escape : as \: in --filesystem= paths
This way we never get confused about which part of the argument
is the permission suffix, which could be exploitable if you can
control the --filesystem calls such as with sandboxed Spawns.
2018-04-04 17:25:59 +02:00
Alexander Larsson
74c4006dbe run: Add --sandbox
This runs the app in a very tight sandbox, with no access to anything
except /app and /run and some read-only host things like fonts and icons.

You can additionally add explicit permissions on the commandline,
like --share=network to actually grant some access.

This also sets $FLATPAK_SANDBOX_DIR to ~/.var/app/$appid/sandbox in the
environment.
2018-04-04 17:25:59 +02:00
Alexander Larsson
b66243e26d Fix --file-forwarding
flatpak_context_append_bwrap_filesystem() didn't actually return the
exports so callers crashed dereferencing NULL.

This fixes https://github.com/flatpak/flatpak/issues/1428
2018-02-19 14:18:12 +01:00
Alexander Larsson
195976a1b8 Fix persisted directories on atomic
On atomic /home is a symlink to /var/home, so when we bind-mount
the persistent directories we need to early-resolve the symlinks
to avoid running into issues with /newroot.

In most cases we do this already by calling flatpak_bwrap_add_bind_arg,
but the persistent dir case did not, because that function required
the target to exist, and the persistent directoried might not.
However, these days flatpak_bwrap_add_bind_arg is fine if the base
dir doesn't exists but the target does, which is the case here,
so we can use it now.

This fixes e.g. steam: https://github.com/flatpak/flatpak/issues/1278

Closes: #1422
Approved by: cgwalters
2018-02-15 13:02:02 +00:00
Alexander Larsson
f33fac310c Add fallback-x11 socket permission
This means use x11 if no alternative is present, and should be used
for applications that support both X11 and wayland, but want to be
sandboxed when running under a wayland compositor (but still want to
run under an X server).

Closes: #1416
Approved by: alexlarsson
2018-02-14 09:19:56 +00:00
Alexander Larsson
f2a6c1db8d Remove document portal
This is now in xdg-desktop-portal. We keep a version of the document
portal dbus XML so that we avoid weird build dependencies.

Flatpak itself is technically not dependent on the document portal,
but it is very much recommended that you use it.

Closes: #1398
Approved by: alexlarsson
2018-02-09 09:23:26 +00:00
Alexander Larsson
3b1b9c65cd Move chunk of filesystem setup from flatpak-run.c to FlatpakContext
This way the filesystem setup is centralized in one place.

Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00
Alexander Larsson
38e2a5decc Rename some FlatpakContext functions
Since flatpak_export_paths_export_context and flatpak_exports_from_context
are now in flatpak-context.c we make them begin with flatpak_context_

Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00
Alexander Larsson
01156880dc Move flatpak_export_paths_export_context & flatpak_exports_from_context
These make more sense in flatpak-context.c, as they touch its FlatpakContext

Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00
Alexander Larsson
58b25843b5 Add and use flatpak_context_allows_features
This lets us avoid directly dereferencing FlatpakContext

Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00
Alexander Larsson
6296987a45 Move dbus filter argument generation to flatpak-context
Closes: #1374
Approved by: alexlarsson
2018-02-05 14:31:30 +00:00
Alexander Larsson
447a8d0537 Extract FlatpakContext to a separate file
This is basically a code motion only, no changes to behaviour.

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