Commit Graph

7144 Commits

Author SHA1 Message Date
Simon McVittie
cd47acf34b Update NEWS for backport of #5213
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-10 15:46:03 +00:00
Simon McVittie
70eb683621 exports: Test that a symlink to the root directory is rejected
Reproduces: https://github.com/flatpak/flatpak/issues/1357
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit fa005cdbbf)
2023-02-10 15:46:03 +00:00
Simon McVittie
45619228b6 exports: Assert that recently-excluded paths are excluded
Reproduces: https://github.com/flatpak/flatpak/issues/5205
Reproduces: https://github.com/flatpak/flatpak/issues/5207
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 4c792e533d)
2023-02-10 15:46:03 +00:00
Simon McVittie
6b02d68def exports: Don't export parent or ancestor of reserved directories
Previously, --filesystem=/run would prevent apps from starting by
breaking our ability to set up /run/flatpak and /run/host. Now it is
ignored, with a diagnostic message, resolving #5205 and #5207.

Similarly, --filesystem=/symlink-to-root (or --filesystem=host) would
have prevented apps from starting if a symlink like
`/symlink-to-root -> /` or `/symlink-to-root -> .` exists, and refusing
to export the target of that symlink avoids that failure mode,
resolving #1357.

Resolves: https://github.com/flatpak/flatpak/issues/1357
Resolves: https://github.com/flatpak/flatpak/issues/5205
Resolves: https://github.com/flatpak/flatpak/issues/5207
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit f325564c9a)
2023-02-10 15:46:03 +00:00
Simon McVittie
958ae32b5e context: Show a warning if we cannot provide any $HOME
If $HOME is below a reserved path (for example `/usr/home/thompson`
for Unix traditionalists) or otherwise cannot be shared, or is a
symbolic link to somewhere that cannot be shared, then we will end
up running the app with $HOME not existing. This is unexpected, so
we should make more noise about it.

There are two situations here, both of which get a warning: if we have
--filesystem=home or --filesystem=host then we are trying to share the
real $HOME with the application, and if we do not, then we are trying
to create a directory at the location of the real $HOME and replicate
the chain of symlinks (if any) leading from $HOME to that location.

Unlike the previous commit, this is not expected to happen during unit
testing, so we do not use a g_warning() for this.

Diagnoses: https://github.com/flatpak/flatpak/issues/5035
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit b85d30365e)
2023-02-10 15:46:03 +00:00
Simon McVittie
e36d9d2769 context: Show a warning when --filesystem exists but can't be shared
If the user gives us a override or command-line argument that we cannot
obey, like --filesystem=/usr/share/whatever or
--filesystem=/run/flatpak/whatever, then it's confusing that we silently
ignore it. We should give them an opportunity to see that their override
was ineffective.

However, there are a few situations where we still want to keep quiet.
If there is a --filesystem argument for something that simply doesn't
exist, we don't diagnose the failure to share it: that avoids creating
unnecessary noise for apps that opportunistically share locations that
might or might not exist, like the way the Steam app on Flathub asks
for access to $XDG_RUNTIME_DIR/app/com.discordapp.Discord.

Similarly, if we have been asked for --filesystem=host, the root
directory is very likely to contain symlinks into a reserved path, like
/lib -> usr/lib. We don't need a user-visible warning for that.

We actually use the equivalent of g_message() rather than g_warning(),
to avoid this being fatal during unit testing (in particular when we
do a `flatpak info` on an app that has never been run, which will
be unable to share its `.var/app` subdirectory). `app/flatpak-main.c`
currently displays them as equivalent to each other anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit dc7b1e873b)
2023-02-10 15:46:03 +00:00
Simon McVittie
4523755ff2 exports: Move error handling up into caller
This lets flatpak_context_export() or other callers decide how they want
to handle failure to export each path. For now, the callers in
FlatpakExports are still using g_debug() unconditionally, but we can now
have somewhat better test coverage.

Helps: https://github.com/flatpak/flatpak/issues/1357
Helps: https://github.com/flatpak/flatpak/issues/5035
Helps: https://github.com/flatpak/flatpak/issues/5205
Helps: https://github.com/flatpak/flatpak/issues/5207
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 3f0a2de2a2)
2023-02-10 15:46:03 +00:00
Simon McVittie
09577c63f7 exports: Make _exports_path_expose produce a GError on failure
This is a step towards allowing its direct and indirect callers to decide
how serious the failure is, and debug or warn accordingly.

Helps: https://github.com/flatpak/flatpak/issues/5205
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 1b49de1890)
2023-02-10 15:46:03 +00:00
Simon McVittie
ef4e2684da exports: Never try to export /.flatpak-info
Just for completeness, in practice the host system will not have this.

Helps: https://github.com/flatpak/flatpak/issues/5205
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 39ba9664fe)
2023-02-10 15:46:03 +00:00
Simon McVittie
1ac133bd63 exports: Never try to export paths below /run/flatpak or /run/host
These directories are reserved for Flatpak's own use.

Helps: https://github.com/flatpak/flatpak/issues/5205
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 97fddc7ba5)
2023-02-10 15:46:03 +00:00
Simon McVittie
31a69a2cab exports, context: List unexported paths one per line in sorted order
This will reduce conflicts when new entries are added.

Helps: https://github.com/flatpak/flatpak/issues/5205
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cee595763d)
2023-02-10 15:46:03 +00:00
Simon McVittie
72136fefef Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-08 14:44:45 +00:00
Simon McVittie
237d94aa09 run: Avoid double-free of gpgconf stdout stream
g_subprocess_get_stdout_pipe() does not transfer ownership, so the
stream still belongs to the GSubprocess and we must not unref it.

Fixes: 764e5a4d "Add --socket=gpg-agent"
Resolves: https://github.com/flatpak/flatpak/issues/5095
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 64d627968e)
2023-02-08 14:44:45 +00:00
Simon McVittie
a56f265100 Update translation files for v1.14.2 release
Signed-off-by: Simon McVittie <smcv@collabora.com>
1.14.2
2023-02-06 17:17:56 +00:00
Simon McVittie
5a68a601fb Prepare v1.14.2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-06 17:00:23 +00:00
Simon McVittie
2a308e7e99 Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-06 14:20:44 +00:00
Patrick
fd4f182bda CI: Disable Valgrind test for now
This test has consistently failed for months as it takes too long.

While it should be looked into its not helpful to show CI as always failing either.

(cherry picked from commit 8daa975ab3)
2023-02-06 14:20:44 +00:00
Simon McVittie
7975b9367e daemons: Treat g_info() as equivalent to g_debug()
Same as the previous commit, but for anything that runs in the
background.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ea584acf20)
2023-01-30 11:51:00 +00:00
Simon McVittie
b6122f659c main: Treat g_info() as equivalent to g_debug()
This makes us consistent with the default behaviour of GLib, and
its behaviour with G_MESSAGES_DEBUG=all. g_debug() and g_info() are
the two lowest priority levels, and GLib normally silences them by
default.

At the moment, Flatpak uses G_LOG_LEVEL_DEBUG in the flatpak2 domain
as its lowest-priority log level (only shown with flatpak -v -v), and
G_LOG_LEVEL_DEBUG in the flatpak domain as its second-lowest
(shown with flatpak -v or higher). I want to move towards using
G_LOG_LEVEL_INFO for flatpak -v messages, and G_LOG_LEVEL_DEBUG for
flapak -v -v, so that we don't need a second log domain: this is a
policy I've used successfully in Flatpak-derived Steam Runtime code.

This change does not fully implement that policy, but gives us a
migration path towards it, by allowing us to start using g_info() for
flatpak -v messages.

Helps: https://github.com/flatpak/flatpak/issues/5001
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ac4e322629)
2023-01-30 11:50:47 +00:00
Phaedrus Leeds
6929db2cb7 repair: Fix off-by-one error in fancy output
Fixes https://github.com/flatpak/flatpak/issues/5204

(cherry picked from commit 8ca1604a94)
2023-01-30 11:50:25 +00:00
Leorize
99329d0cf5 flatpak-run: unset GIO_EXTRA_MODULES
This variable contains paths to load GIO modules from. For the most
part, they refer to paths outside of the sandbox or if they happen
to be in the sandbox, would contain modules that are incompatible with
the sandbox runtime (ie. different libc).

While I've not found programs that would crash outright, it may cause
unexpected behaviors (eg. Apostrophe not being able to render math in
preview panel).

This variable is set by NixOS for its dependency boxing.

(cherry picked from commit df0b9d98b5)
2023-01-30 11:46:07 +00:00
Leorize
1e14a1fd30 flatpak-run: unset XKB_CONFIG_ROOT
This variable is typically used to configure the use of a custom
set of XKB definitions. In those cases, it's mostly meant for the
X11 server or Wayland compositor. NixOS is known to employ this
variable for their custom XKB layout implementation.

When the path it points to is unreachable (due to the sandbox),
most GTK+/Qt applications will crash on Wayland.

Unsetting this does not seem to negatively impact the use of custom
XKB layouts with Flatpak applications.

(cherry picked from commit 751ff11d3a)
2023-01-30 11:45:57 +00:00
Michael Catanzaro
e853fb4cdb Block KRB5CCNAME from inheriting into sandbox
If this environment variable is set on the host, it's going to mess up
authentication in the sandbox. For example, if the host has:

KRB5CCNAME=KCM:

then the sandboxed process will try to use the host KCM socket, which is
not available in the sandboxed environment, rather than the gssproxy
socket that we want it to use. We need to unset it to ensure that
whatever configuration we ship in the runtime gets used instead. We have
switched the GNOME runtime to use an empty krb5.conf and it works as
long as we don't break it with this environment variable meant for the
host.

(cherry picked from commit 1c32317841)
2023-01-30 11:45:49 +00:00
Martin Kühl
e14247f0a9 profile.d: Only add new directories to XDG_DATA_DIRS in fish
Previously in a0505f52d9
the profile script was modified to preserve XDG_DATA_DIRS.
This had the side-effect of making the script not idempotent,
adding duplicate entries for every installation every time it's sourced.

On my current system  that results in this value:

    /home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /home/mkhl/.local/share/flatpak/exports/share /var/lib/flatpak/exports/share /usr/local/share /usr/share

which in turn has the side-effect of the GNOME search settings showing two entries
for every application installed via flatpak.

This change makes the script check that an entry is new before adding it.
It also uses `set -p` (short for `--prepend`) to add them.

N.B.
`set -p VAR val` is equivalent to `set VAR val $VAR`
`$var[-1..1]` reverses the order of elements
so after iterating the first element of `$installations`
becomes the first element of `$XDG_DATA_DIRS`

(cherry picked from commit 16707a1937)
2023-01-30 11:44:29 +00:00
Forest
0f77c6a6f5 utils: Unmap the old summary.idx file before trying to replace it
Exporting to an existing repo on a Samba filesystem failed with EACCES
when libglnx called renameat() to replace the old summary.idx file.

    error: renameat: Permission denied

This occurred even when the user had appropriate permissions to the file
and its ancestor directories. The problem was that flatpak had mapped the
old file into memory for reading, and still held a reference to that mapping
when attempting to replace the underlying file. Apparently this works on some
filesystems, but not on cifs.

We therefore release the memory mapping before replacing the underlying file.

Fixes #5257

Co-authored-by: Patrick <tingping@tingping.se>
(cherry picked from commit 01910ad12f)
2023-01-30 11:43:38 +00:00
Simon McVittie
f9a768721e Update translation files for v1.14.1
Signed-off-by: Simon McVittie <smcv@collabora.com>
1.14.1
2022-11-18 13:41:08 +00:00
Simon McVittie
62a31e90b3 Prepare v1.14.1
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-18 13:33:32 +00:00
Simon McVittie
078c4cd98a Revert ".gitmodules: Temporarily fetch from Github mirror of libglnx"
This reverts commit 7cb9eb3ebc.
2022-11-18 13:32:33 +00:00
Simon McVittie
4568de61f5 Revert ".gitmodules: Temporarily fetch from my Github fork of v-s-c"
This reverts commit bdfebb44da.
2022-11-18 13:32:29 +00:00
Simon McVittie
ff75036545 .gitmodules: Temporarily fetch from my Github fork of v-s-c
gitlab.gnome.org is currently down, so use a mirror.
The specific commit we are using has not changed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit bdfebb44da)
2022-11-17 19:00:30 +00:00
Simon McVittie
1fc97aaf02 .gitmodules: Temporarily fetch from Github mirror of libglnx
gitlab.gnome.org is currently down, so use a mirror.
The specific commit we are using has not changed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 7cb9eb3ebc)
2022-11-17 19:00:27 +00:00
Simon McVittie
61fb373b88 .gitmodules: Canonicalize URL of bubblewrap
The project was moved to a new namespace a while ago, and is now using
the main branch rather than master.

The specific commit we are using has not changed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit f9a7d12014)
2022-11-17 19:00:24 +00:00
Simon McVittie
45ed3b11a6 Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-17 18:02:21 +00:00
Philip Withnall
ce9775e450 flatpak-dir: Add a debug message to remove_old_appstream_tmpdirs()
This should make it a bit clearer when `rm -rf` is being used in the
debug logs.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
(cherry picked from commit 6c7eb34dd6)
2022-11-17 17:58:44 +00:00
Simon McVittie
c8f3f0dc1a build: Accept gpgme >= 1.8.0 as equivalent to gpgme-pthread
Before 1.8.0 (2016), gpgme used to have two different thread-safe builds,
one for use with POSIX-style pthread and one for use with GNU Portable
Threads (libpth), plus a non-thread-safe version. Since 1.8.0, this
complexity has gone away and there is only libgpgme, which is thread-safe.

In practice this meant that on modern distros since 2016, we would always
fail to detect gpgme via pkg-config and fall back to calling gpgme-config.

Library-specific -config scripts are generally considered problematic
for multiarch, multilib and cross-compiling, and the gpgme-config script
recently disappeared from GPGME's Debian packaging
(see https://bugs.debian.org/1022348 and https://bugs.debian.org/1023601),
so it's better if we can prefer to use pkg-config.

If gpgme >= 1.8.0 is not found, fall back to gpgme-pthread >= 1.1.8,
either discovered via pkg-config or via gpgme-config.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9b87e4c0d4)
2022-11-17 17:58:26 +00:00
Simon McVittie
0033d1aae8 doc: Update flatpak-metadata(5) for #5155
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit db77992b28)
2022-11-17 17:58:07 +00:00
Gaël Donval
9bd6fa0f26 Add /efi in the hidding list when (fs=host)
When filesystem=host access is provided, some root folders are hidden, including /boot.

The bootloader specification now recommends mounting the system EFI filesystem in /efi
(currently visible) instead of /boot/efi (currently hidden). This hides /efi for the same
reasons /boot is already hidden.

(cherry picked from commit 397c97de9f)
2022-11-17 17:56:45 +00:00
Simon McVittie
ab698907a8 doc: Update flatpak-run(1) for #5168
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 26fbf692cd)
2022-11-17 17:56:45 +00:00
Erick555
8b0a9791af Clear more temporary file paths from env
This supplements clearing TMPDIR env variable which is only one among variables used for storing temporary files. Any of those leaking from host may confuse flatpak apps which try to save temporary files under non-existing directory in sandbox.

See https://github.com/flathub/com.logseq.Logseq/issues/29 for real world example.

(cherry picked from commit d8695f3071)
2022-11-17 17:56:45 +00:00
Simon McVittie
93c7036118 automake: Consistently include $(AM_CFLAGS) in target-specific CFLAGS
When built for i386 with Autotools, this would have detected the format
string issue fixed in #5148.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit de4de4dc44)
2022-11-17 17:54:47 +00:00
Simon McVittie
414bbfd617 revokefs: Remove incorrect libglnx include directory
revokefs already gets the correct include directory from the AM_CPPFLAGS.
This would also break the build with -Werror=missing-include-dirs.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 190bad06d2)
2022-11-17 17:54:40 +00:00
Simon McVittie
44b9cddeb3 workflows: Enable CI for flatpak-1.14.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 751d2b110b)
2022-11-10 13:13:53 +00:00
Philip Withnall
fdc7287d21 flatpak-dir: Clean up temp deploy dir on failure of flatpak_dir_deploy()
This already happens for installs due to the cleanup path in
`flatpak_dir_deploy_install()`, but it doesn’t happen for other calls to
`flatpak_dir_deploy()`. Notably, during updates of already installed
apps.

Specifically, this means that if an app update is cancelled due to being
blocked by a parental controls policy, the temp deploy dir for that app
(such as
`~/.local/share/flatpak/app/com.corp.App/x86_64/stable/.somehex-XXXXXX`)
will be leaked. It will never be automatically cleaned up, as it’s not
in `/var/tmp` either.

Fix that by using `glnx_mkdtempat()` to create a scoped temporary
directory.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
(cherry picked from commit ce1829a703)
2022-11-10 12:42:40 +00:00
Simon McVittie
6948b1c3db Update NEWS for 1.14.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-28 13:07:15 +01:00
Simon McVittie
5633ae11dd revokefs: Use correct format string for a ssize_t
This fixes the build on ILP32 architectures such as i386 with the Meson
build system. The Autotools build system accidentally didn't build
revokefs with -Werror=format, because it sets the target-specific CFLAGS
for revokefs but does not include the $(AM_CFLAGS) in them.

Fixes: aeecbb7d "revokefs: Split out the writing part from the fuse implementation"
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 959910f933)
2022-10-28 13:07:15 +01:00
Jan Tojnar
075482d2b7 profile.d: Do not destroy XDG_DATA_DIRS in fish
The profile script previously nuked `XDG_DATA_DIRS` and then
“helpfully” re-populated it with FHS paths. This was especially
bad for systems like NixOS, which do not have `/usr`
and rely on `XDG_DATA_DIRS` heavily.

Quoting from https://fishshell.com/docs/current/cmds/set.html

> If a variable is set to zero elements, it will become a list with zero elements.

And indeed, that is what the `set -x --path XDG_DATA_DIRS` command does.
We need to list the value explicitly, if we want to preserve it
while setting variable options.

(cherry picked from commit a0505f52d9)
2022-10-28 13:07:15 +01:00
Rafael Fontenelle
39a0c470a9 Update Brazilian Portuguese translation
(cherry picked from commit e5bb9af250)
2022-10-28 13:07:15 +01:00
Piotr Drąg
202d40c6f9 Update Polish translation
(cherry picked from commit 9d44a27d79)
2022-10-28 13:07:15 +01:00
Kukuh Syafaat
ed450226de Update Indonesian translation
(cherry picked from commit b26e9efb1d)
2022-10-28 13:07:15 +01:00
Alberto Garcia
2dad36ede6 session-helper: Run default signal handler after handle_sigterm()
Exiting the process with a custom exit status (1) after systemctl stop
(SIGTERM) makes systemd treat the flatpak-session-helper service as if
it had failed.

Signed-off-by: Alberto Garcia <berto@igalia.com>
(cherry picked from commit c1f0370958)
2022-10-28 13:07:15 +01:00