6385 Commits

Author SHA1 Message Date
Alexander Larsson
c614eb400e Update pofiles for release 1.10.2 2021-03-10 11:44:00 +01:00
Alexander Larsson
2d637e2bb1 Update NEWS and version for release 2021-03-10 11:26:20 +01:00
Simon McVittie
a7401e638b dir: Refuse to export .desktop files with suspicious uses of @@ tokens
This is either a malicious/compromised app trying to do an attack, or
a mistake that will break handling of %f, %u and so on. Either way,
if we refuse to export the .desktop file, resulting in installation
failing, then it makes the rejection more obvious than quietly
removing the magic tokens.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 46b3ede524)
2021-03-10 11:13:38 +01:00
Simon McVittie
eb7946bb62 dir: Reserve the whole @@ prefix
If we add new features analogous to file forwarding later, we might
find that we need a different magic token. Let's reserve the whole
@@* namespace so we can call it @@something-else.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 1e7e8fdb24)
2021-03-10 11:13:38 +01:00
Ryan Gonzalez
8279c58184 Disallow @@ and @@u usage in desktop files
Fixes #4146.

(cherry picked from commit 652a28ffab)
2021-03-10 11:13:38 +01:00
Gregor Simm
c638bf9208 Update dates in NEWS file
In the NEWS file, it says that versions 1.10.1 and 1.10.1 were released in 2020. Shouldn't that read 2021?

(cherry picked from commit bcd7425597)
2021-03-10 11:13:38 +01:00
Bastien Nocera
e7b5f46009 common: Fix Spawn portal method not working with UTF-8 files
When the portal's Spawn method is used with the environment cleared,
it's very likely that the "flatpak run" that ends up being run will be
in an environment without UTF-8 support.

If one of the files or directories we try to expose to the sub-sandbox
contains UTF-8/non-ASCII characters, then "flatpak run" would fail with:
error: Invalid byte sequence in conversion input

This is caused by GOption trying to parse the --filesystem option for
flatpak, as, when using the G_OPTION_ARG_CALLBACK argument type, GOption
will split the option name from its value, and try to convert the value
to UTF-8. Which will fail because there's no UTF-8.

It won't however do that if we tell the option parser that the value is
a filename using G_OPTION_FLAG_FILENAME, so set it.

(cherry picked from commit e67847e253)
2021-03-10 11:13:38 +01:00
Ludovico de Nittis
936bd2b3e0 run: Propagate X11 cookies with an address equals to XAUTHLOCALHOSTNAME
OpenSUSE inherits the hostname value from DHCP without updating its X11
authentication cookie, and it keeps the initial value in
`XAUTHLOCALHOSTNAME`.
To avoid breaking the X11 applications, OpenSUSE patches libxcb so that
it also considers the value in `XAUTHLOCALHOSTNAME` as another possible
hostname.

https://bugzilla.opensuse.org/show_bug.cgi?id=262309

To cope with that behavior we need to check `XAUTHLOCALHOSTNAME` too
and, if we have a cookie with that address, propagate it inside the
container adjusting its address to the canonical hostname
`unames.nodename`.

Fixes: #4043

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
(cherry picked from commit fd6a3b79f4)
2021-03-10 11:13:38 +01:00
Phaedrus Leeds
2ebc79b38e CI: Add 1.10 branch 2021-02-19 09:16:10 +01:00
Kalev Lember
93fb812b44 Add G_BEGIN_DECLS/G_END_DECLS to public headers
This ensures that we correctly specify C linkage when including flatpak
headers from C++ code.

This should fix fallout from glib's change to include C++ code in its
headers, see https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1935
for discussion.

Fixes https://github.com/flatpak/flatpak/issues/4117

(cherry picked from commit 426284759c)
2021-02-19 09:16:10 +01:00
Phaedrus Leeds
a1a6b7f208 testlibrary: Fix memory leaks
(cherry picked from commit 7224809bc1)
2021-02-19 09:16:10 +01:00
Phaedrus Leeds
bc39bb59c4 doc: Add info -l docs 2021-02-09 09:37:32 +01:00
Phaedrus Leeds
dbe81c90c2 common: Tweak error code docs
FLATPAK_ERROR_ALREADY_INSTALLED can be returned from, for example,
flatpak_installation_add_remote(), so document that it applies to
remotes not just apps and runtimes.
2021-02-09 09:36:59 +01:00
Phaedrus Leeds
0920e959b5 common: Update FlatpakRef docs with respect to uniqueness
See these links for context on this change:
- https://lists.freedesktop.org/archives/flatpak/2021-January/002087.html
- https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/583#note_1006763
2021-02-09 09:34:47 +01:00
Simon McVittie
a926776cf4 tests: Disable revokefs if FUSE doesn't work
There are various reasons why distro autobuilder environments might not
be able to use FUSE in build-time tests: they might not have
fusermount(1), they might be locked-down to be unable to load the FUSE
kernel module as a result of security hardening, they might not have the
/etc/mtab symlink, they might not have CAP_SYS_ADMIN in their capability
bounding set, or they might not have write access to /dev/fuse. Try to
check for all of these conditions.

Heavily based on code that I previously contributed to
xdg-desktop-portal. Disabling revokefs, instead of skipping the test
that needs it, is based on the patches applied in @alexlarsson's PPA.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-09 09:33:57 +01:00
Phaedrus Leeds
a8cc112dfa Merge pull request #4102 from jtojnar/docbook-unification
doc: Unify DocBook versions again
2021-02-05 19:51:16 -08:00
Phaedrus Leeds
997293d91e Merge pull request #4104 from pwithnall/content-rating-leak
flatpak-installation: Fix a leak of the content rating hash table
2021-02-05 15:34:52 -08:00
Philip Withnall
ae457239f5 flatpak-installation: Fix a leak of the content rating hash table
`flatpak_deploy_data_get_appdata_content_rating()` returns ownership of
the container.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-02-03 17:13:01 +00:00
Jan Tojnar
2bdd687bd7 doc: Unify DocBook versions again
Fixes a regression in version monoculture that occurred since the first attempt in
https://github.com/flatpak/flatpak/pull/3760
2021-02-01 23:16:25 +01:00
Alexander Larsson
acb2a190b3 Update pofiles for release 1.10.1 2021-01-21 14:59:10 +01:00
Alexander Larsson
c159070a74 Update version to 1.10.1 2021-01-21 14:45:11 +01:00
Alexander Larsson
f800187ce9 Update NEWS for release 2021-01-21 14:44:59 +01:00
Yuri Chornoivan
84fe927048 Update Ukrainian translation 2021-01-21 14:21:27 +01:00
Simon McVittie
b2b3612148 NEWS: Add CVE reference for CVE-2021-21261
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:20:48 +01:00
AsciiWolf
362c60e089 Update Czech translation 2021-01-21 14:20:01 +01:00
Piotr Drąg
ef825991e1 Update Polish translation 2021-01-21 14:18:45 +01:00
Simon McVittie
d0d5794621 doc: Mention some typical tags
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:18:21 +01:00
Simon McVittie
59a8be5805 run: Remove unused minimal environment
We instantiated this but didn't use it for anything.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:16:44 +01:00
Simon McVittie
baa5affb5e run: Pass environment variables via bwrap --setenv when running ldconfig
This means we can systematically pass the environment variables
through bwrap(1), even if it is setuid and thus is filtering out
security-sensitive environment variables. bwrap ends up being
run with an empty environment instead.

This did not regress in 6d1773d "run: Convert all environment variables
into bwrap arguments", because the LD_LIBRARY_PATH special case in
flatpak_run_add_environment_args() was already not used here; but it's
a bug fix along the same lines as fixing the regression.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:16:44 +01:00
Simon McVittie
fb473cad80 dir: Pass environment via bwrap --setenv when running apply_extra
This means we can systematically pass the environment variables
through bwrap(1), even if it is setuid and thus is filtering out
security-sensitive environment variables. bwrap ends up being
run with an empty environment instead.

As with the previous commit, this regressed while fixing CVE-2021-21261.

Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:16:44 +01:00
Simon McVittie
9a61d2c44f build: Convert environment into a sequence of bwrap arguments
This means we can systematically pass the environment variables
through bwrap(1), even if it is setuid and thus is filtering out
security-sensitive environment variables. bwrap itself ends up being
run with an empty environment instead.

This fixes a regression when CVE-2021-21261 was fixed: before the
CVE fixes, LD_LIBRARY_PATH would have been passed through like this
and appeared in the `flatpak build` shell, but during the CVE fixes,
the special case that protected LD_LIBRARY_PATH was removed in favour
of the more general flatpak_bwrap_envp_to_args(). That reasoning only
works if we use flatpak_bwrap_envp_to_args(), consistently, everywhere
that we run the potentially-setuid bwrap.

Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
Resolves: https://github.com/flatpak/flatpak/issues/4080
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980323
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-21 14:16:44 +01:00
Phaedrus Leeds
06869af68a Merge pull request #4085 from pwithnall/null-subpaths
flatpak-dir: Fix crash on updating app with no deploy data or subpaths
2021-01-20 15:39:30 -08:00
Philip Withnall
8f24958d2a flatpak-dir: Set subpaths when calling Deploy() if not set
This adds `NULL` protection to the `subpaths` argument to
`flatpak_dir_system_helper_call_deploy()`, just like already exists for
other arguments.

It’s a second layer of defence against bugs like fixed in the previous
commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-01-20 21:44:15 +00:00
Philip Withnall
e274bafc01 flatpak-dir: Fix crash on updating app with no deploy data or subpaths
If an app had no deploy data, and `flatpak_dir_update()` was called with
`opt_subpaths == NULL`, then `arg_subpaths` passed to
`flatpak_dir_system_helper_call_deploy()` would be `NULL`, which causes
an assertion failure from an internal `g_variant_new()` call:
```
g_variant_new_strv: assertion 'length == 0 || strv != NULL' failed
```

Fix that by setting the `subpaths` to an empty array if nothing else is
specified.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-01-20 21:40:39 +00:00
Alexander Larsson
b8d8e5bf04 Fix nonliteral string warning in flatpak_invocation_return_error()
We're only forwarding a format string, which we can tell gcc by
adding a G_GNUC_PRINTF marker.
2021-01-14 12:43:46 +01:00
Alexander Larsson
d5de05b608 CI: Use the new --enable-asan 2021-01-14 12:43:46 +01:00
Alexander Larsson
97a153fe0a Add --enable-asan option
This passes -fsanitize=address in the right place.
Passing it this way instead of CFLAGS allows us to strategically
not add sanitize in specific places as needed.
2021-01-14 12:43:46 +01:00
Alexander Larsson
dad9a9c20d Pass AM_CFLAGS to system-helper build (for warnings) 2021-01-14 12:43:46 +01:00
Alexander Larsson
50ee8293cc Fix shadowed variable "error" 2021-01-14 12:43:46 +01:00
Alexander Larsson
649ad5fe49 Update pofiles for release 1.10.0 2021-01-14 10:58:56 +01:00
Alexander Larsson
47a5fa1f56 Bump version to 1.10 2021-01-14 10:47:32 +01:00
Alexander Larsson
67852b0101 Update NEWS for release 2021-01-14 10:47:22 +01:00
Alexander Larsson
c702f92609 Fix tests when installed tests are not enabled
We need a different rpath for libpreload in this case, because
installed_testdir is not set.
2021-01-14 10:32:18 +01:00
Simon McVittie
c4a58d5822 portal: Add the ability to unset environment variables
This is really just syntactic sugar for running `env -u VAR ... COMMAND`,
but env(1) is inconvenient when the form of the COMMAND is not known:
if the COMMAND might contain an equals sign, you end up having to run
`env -u VAR sh -c 'exec "$@"' sh COMMAND`. Let's make this simpler.

This follows up from GHSA-4ppf-fxf6-vxg2 to fix an issue that I noticed
while resolving that vulnerability, but is not required for fixing the
vulnerability.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
4108e02245 context: Add --unset-env option and a corresponding override
This follows up from GHSA-4ppf-fxf6-vxg2 to fix missing functionality
that I noticed while resolving that vulnerability, but is not required
for fixing the vulnerability.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
b0aea9c053 run: Allow setting environment variables to empty strings
Some consumers of environment variables distinguish between present
with an empty value and absent. For example, if an environment variable
represents a search path like VK_ICD_FILENAMES, unsetting it often
results in use of a default, but setting it to the empty string results
in not searching any locations, which is sometimes what is desired.

The shell syntax "${BAR-unset}" expands to the value of ${BAR} if it
is set to anything (even an empty string), or to "unset" if not.
We can use that in the unit test to check that BAR is set to the
empty string in this case.

This follows up from GHSA-4ppf-fxf6-vxg2 to fix an issue that I noticed
while resolving that vulnerability, but is not required for fixing the
vulnerability.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
e2c4ded323 portal: Let --env= and --env-fd= take precedence over extra-args
Previously, if you launched a subsandbox while specifying environment
variable overrides, any environment variable overrides that existed
in the parent Flatpak app would take precedence:

    host$ flatpak run --env=FOO=1 --command=bash example.app
    [📦 example.app ~]$ env | grep FOO
    FOO=1
    [📦 example.app ~]$ flatpak-spawn --env=FOO=x sh -c 'env | grep FOO'
    FOO=1

This does not seem like least-astonishment, and in particular will
cause problems if the app wants to override LD_LIBRARY_PATH in the
subsandbox. Change the precedence so that the environment variables
set by flatpak-spawn will "win":

    host$ flatpak run --env=FOO1=1 --env=FOO2=2 --command=bash example.app
    [📦 example.app ~]$ env | grep FOO
    FOO1=1
    FOO2=2
    [📦 example.app ~]$ flatpak-spawn --env=FOO1=x sh -c 'env | grep FOO'
    FOO1=x
    FOO2=2

This follows up from GHSA-4ppf-fxf6-vxg2 to fix an issue that I noticed
while resolving that vulnerability, but is not required for fixing the
vulnerability.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
4ac1106690 portal: Add a note about CLEAR_ENV behaviour
This seems like something to fix later, outside embargo.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
d19f6c330a tests: Assert that --env= does not go in flatpak run or bwrap environ
For the portal's use of --env-fd= to be safe, we want the environment
variables that it sets to end up in the environment for the program
that is run by `bwrap` as process 2, but they must not go into the
environment that gets used to run `flatpak run` or `bwrap`. Assert
that this is the case.

For completeness, we're testing both --env= and --env-fd= here,
even though the earlier commit
"portal: Do not use caller-supplied variables in environment"
always uses --env-fd=.

Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-14 09:33:24 +01:00
Simon McVittie
cc1401043c portal: Do not use caller-supplied variables in environment
If the caller specifies a variable that can be used to inject arbitrary
code into processes, we must not allow it to enter the environment
block used to run `flatpak run`, which runs unsandboxed.

This change requires the previous commit "context: Add --env-fd option",
which adds infrastructure used here.

To be secure, this change also requires the previous commit
"run: Convert all environment variables into bwrap arguments", which
protects a non-setuid bwrap(1) from the same attack.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
2021-01-14 09:33:24 +01:00