Commit Graph

7173 Commits

Author SHA1 Message Date
K.B.Dharun Krishna
ebd15e962e check.yml: bump actions/upload-artifacts to v3
(cherry picked from commit a98854b1a0)
2023-11-14 21:28:30 +00:00
K.B.Dharun Krishna
9c1938f68f check.yml: remove glib260 ppa
The required package is present in Ubuntu repos https://packages.ubuntu.com/focal/libglib2.0-dev

(cherry picked from commit cb655ab336)
2023-11-14 21:28:27 +00:00
K.B.Dharun Krishna
7c9bbb62e6 block-autosquash-commits.yml: bump block-autosquash-commits-action version to 2.2.0
(cherry picked from commit dad39f61b5)
2023-11-14 21:28:22 +00:00
K.B.Dharun Krishna
d65cf36543 check.yml: bump actions/checkout version and replace deprecated 18.04 runner with 20.04
(cherry picked from commit 97768cea84)
2023-11-14 21:28:18 +00:00
Simon McVittie
38f1409b40 testlibrary: Initialize autofree variable to silence a compiler warning
As with commit 43085c0e "dir: Consistently initialize g_autofree
variables", this is currently harmless because we never actually
early-return or goto out of the region between declaration and
initialization, but some compiler versions log a warning here anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cffc3aed5b)
2023-11-14 21:27:31 +00:00
Simon McVittie
9de6856f7e run: Make it clearer that rest_argv_start is not used uninitialized
rest_argv_start is initialized whenever rest_argc != 0, so the previous
code was in fact safe; but this wasn't obvious to either a human reader
or the compiler, and some gcc versions warn here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 0e3e646839)
2023-11-14 21:27:17 +00:00
Simon McVittie
b7a18d8f98 dir: Consistently initialize g_autofree variables
All g_autofree and g_autoptr variables should be initialized, either
with a value or NULL, and some gcc versions warn if they are not.

This particular instance was harmless, because we initialized regexp
to either NULL or a valid non-NULL value as the first statement of the
function, so there was no way to return before regexp was initialized;
but if we introduced an early-return such as a g_return_val_if_fail
before the current first statement, then that early return would have
caused uninitialized stack contents to be freed, likely resulting in a
crash.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 43085c0e2a)
2023-11-14 21:27:07 +00:00
Philip Withnall
2fc0fa3306 dir: Fix a minor leak of an OSTree checksum
The checksum here can leak if `flatpak_dir_remote_load_cached_summary()`
returns false at least once.

Spotted by asan while running gnome-software:
```
Direct leak of 2925 byte(s) in 45 object(s) allocated from:
    #0 0x7f44774ba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af)
    #1 0x7f44764c941a in g_malloc ../../source/glib/glib/gmem.c:130
    #2 0x7f445bc860e7 in ostree_checksum_from_bytes src/libostree/ostree-core.c:1599
    #3 0x7f445bdbea82 in flatpak_dir_remote_fetch_indexed_summary /opt/gnome/source/flatpak/common/flatpak-dir.c:12563
    #4 0x7f445bd9932e in flatpak_remote_state_ensure_subsummary /opt/gnome/source/flatpak/common/flatpak-dir.c:577
    #5 0x7f445bdbfd42 in _flatpak_dir_get_remote_state /opt/gnome/source/flatpak/common/flatpak-dir.c:12872
    #6 0x7f445bdc006c in flatpak_dir_get_remote_state_optional /opt/gnome/source/flatpak/common/flatpak-dir.c:12953
    #7 0x7f445be07886 in flatpak_transaction_ensure_remote_state /opt/gnome/source/flatpak/common/flatpak-transaction.c:2057
    #8 0x7f445be095c7 in flatpak_transaction_add_ref /opt/gnome/source/flatpak/common/flatpak-transaction.c:2732
    #9 0x7f445be09c37 in flatpak_transaction_add_update /opt/gnome/source/flatpak/common/flatpak-transaction.c:2940
    #10 0x7f445bdd202c in flatpak_installation_list_installed_refs_for_update /opt/gnome/source/flatpak/common/flatpak-installation.c:1103
    #11 0x7f445bf07824 in gs_flatpak_add_updates ../../source/gnome-software/plugins/flatpak/gs-flatpak.c:2082
    #12 0x7f445bf2e2b9 in gs_plugin_add_updates ../../source/gnome-software/plugins/flatpak/gs-plugin-flatpak.c:484
    #13 0x7f44770533b2 in gs_plugin_loader_call_vfunc ../../source/gnome-software/lib/gs-plugin-loader.c:620
    #14 0x7f447705430f in gs_plugin_loader_run_results ../../source/gnome-software/lib/gs-plugin-loader.c:748
    #15 0x7f447706cb03 in gs_plugin_loader_process_thread_cb ../../source/gnome-software/lib/gs-plugin-loader.c:3110
    #16 0x7f44769967ed in g_task_thread_pool_thread ../../source/glib/gio/gtask.c:1531
    #17 0x7f447650e760 in g_thread_pool_thread_proxy ../../source/glib/glib/gthreadpool.c:350
    #18 0x7f447650dd02 in g_thread_proxy ../../source/glib/glib/gthread.c:831
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
(cherry picked from commit ce4bb3d153)
2023-11-14 21:26:57 +00:00
Simon McVittie
9a28eafcc4 tests: Call g_test_init() before isolated_test_dir_global_setup()
g_test_init() is meant to be called before any other use of GTest APIs,
and isolated_test_dir_global_setup() can call g_test_message(). GLib
2.76 makes this more of a practical problem.

(isolated_test_dir_global_setup() is essentially a reimplementation of
G_TEST_OPTION_ISOLATE_DIRS, since we don't depend on GLib 2.60.)

Alternative to https://github.com/flatpak/flatpak/pull/5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a058d9617f)
2023-11-14 21:26:46 +00:00
Simon McVittie
1423f0e9bf security policy: Downgrade 1.12.x, 1.10.x to "supported if feasible"
We have too many branches and too few maintainers to be able to treat
old-stable branches as fully supported.

Helps: #5352
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 319832190f)
2023-11-14 21:26:41 +00:00
Jan Alexander Steffens (heftig)
0dea86b0d6 Set size of file info for symlinks to 0
`ostree_raw_file_to_content_stream` will try to read it, causing a
critical warning with GLib 2.76 causing tests to fail.

(cherry picked from commit c9cbdf5179)
2023-11-14 21:26:33 +00:00
Simon McVittie
8a1edceadf Update translation files for 1.14.4 release
Signed-off-by: Simon McVittie <smcv@collabora.com>
1.14.4
2023-03-16 10:07:08 +00:00
Simon McVittie
b5a8880d58 Prepare v1.14.4
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-03-16 09:55:13 +00:00
Simon McVittie
ce35df08b1 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-03-16 09:55:13 +00:00
Simon McVittie
f015f91dc3 run: Prevent TIOCLINUX ioctl, the same as TIOCSTI
The TIOCLINUX ioctl is only available on Linux virtual consoles such as
/dev/tty1. It has several Linux-specific functions, one of which is a
copy/paste operation which can be used for attacks similar to TIOCSTI.

This vulnerability does not affect typical graphical terminal emulators
such as xterm, gnome-terminal and Konsole, and Flatpak is primarily
designed to be run from a Wayland or X11 graphical environment, so this
is relatively unlikely to be a practical problem.

CVE-2023-28100, GHSA-7qpw-3vjv-xrqp

Resolves: https://github.com/flatpak/flatpak/security/advisories/GHSA-7qpw-3vjv-xrqp
Signed-off-by: Simon McVittie <smcv@debian.org>
2023-03-16 09:55:13 +00:00
Simon McVittie
583cb3a16f cli-transaction: Escape any special characters in the EOL reason
CVE-2023-28101, GHSA-h43h-fwqx-mpp8

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-03-16 09:55:13 +00:00
Ryan Gonzalez
20cf7360ff Reject paths given to --filesystem/--persist with special characters
There isn't much in the way of legit reasons for this, but it's a
potential security footgun when displaying the text.

CVE-2023-28101, GHSA-h43h-fwqx-mpp8

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
Co-authored-by: Simon McVittie <smcv@collabora.com>
2023-03-16 09:55:13 +00:00
Ryan Gonzalez
9e7ec07e67 Ensure special characters in permissions and metadata are escaped
This prevents someone from placing special characters in order to
manipulate the appearance of the permissions list.

CVE-2023-28101, GHSA-h43h-fwqx-mpp8

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2023-03-16 09:55:13 +00:00
Piotr Drąg
e67356a93e Update Polish translation 2023-03-06 15:48:29 +00:00
Simon McVittie
ccafd8c1c8 Update translation files for release 1.14.3 2023-02-27 12:46:47 +00:00
Simon McVittie
f3184c60cf Prepare v1.14.3
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-27 12:23:08 +00:00
Dan Nicholson
70ad8e127c transaction: Ignore uninstall operations for no deploy
If `no_deploy` has been set to `TRUE` in a transaction, then the
intention is that no changes will be made to the installed flatpaks.
Currently that's not the case for explicitly or implicitly added
uninstall operations. That's particularly bad for eol-rebase flatpaks
since they old version will be automatically removed without the new
version being installed. To address this, prevent uninstall operations
from being added for no deploy transactions.

Closes: #5172
(cherry picked from commit fba3a7d35e)
2023-02-27 12:21:52 +00:00
Simon McVittie
42bc8428ca Update NEWS for 1.14.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-02-21 12:10:11 +00:00
Simon McVittie
1ebf5dfebf dir: If metadata is syntactically invalid, say which file is the problem
Similar to the previous commit, but for metadata.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit be2de97e86)
2023-02-21 12:10:11 +00:00
Simon McVittie
060e907382 dir: If overrides are syntactically invalid, include path in error message
It's unhelpful to say something like "Key file contains line “x” which is
not a key-value pair, group, or comment" without specifying which file
we are talking about.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 3ede5382fa)
2023-02-21 12:10:11 +00:00
Simon McVittie
b80616c2da list: Show a warning if we can't load the current version
Conceptually similar to the previous commit, except it didn't crash
before, just didn't display anything.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 628750d2de)
2023-02-21 12:10:11 +00:00
Simon McVittie
dcdae9e362 list: Handle error in flatpak_dir_load_deployed()
flatpak_dir_load_deployed() can fail and return NULL. If that happens,
there is a semi-installed but broken app, and we should show a warning
rather than crashing.

Resolves: https://github.com/flatpak/flatpak/issues/5293
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 5e2e771ece)
2023-02-21 12:10:11 +00:00
Dan Nicholson
a508d50a33 flatpak-run: Unset GDK_BACKEND
If the `GDK_BACKEND` environment variable is present and it's value does
not match the Wayland and X11 socket configuration, then a GTK app will
fail to run since it will only consider the display backend from the
environment variable.

This should probably be extended to cover other display environment
variables such as `QT_QPA_PLATFORM` for Qt and `SDL_VIDEODRIVER` for
SDL. However, I've only tested this with GTK applications.

(cherry picked from commit cc122e2972)
2023-02-18 14:08:27 +00:00
Piotr Drąg
9a804d207f Update POTFILES.in
Fixes: 5cd3ec5f "exports: Make _exports_path_expose produce a GError on failure"
(cherry picked from commit fa35ebe513)
2023-02-10 15:46:03 +00:00
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