Commit Graph
8510 Commits
Author SHA1 Message Date
Sebastian Wick e13dfeda33 common: Fix return value and typos in flatpak_switch_symlink_and_remove
One error path returned -1 instead of FALSE. Since gboolean is gint,
-1 is truthy and the caller would skip error handling.

Assisted-by: Claude:opus-4.6
Helps: https://github.com/flatpak/flatpak/security/advisories/GHSA-99wv-m8rp-g58x
2026-08-10 23:30:10 +02:00
Sebastian Wick 0129cb0e19 Revert "http: Reset curl TLS options between transfers"
This reverts commit 420ce91428.

Apparently we do depend on the session-set certificates in some
situations. We should fix that, but until someone puts in the effort to
do so, reverting this will at least unbreak things.

(cherry picked from commit e61ae2114c)
2026-08-10 17:28:41 -04:00
Maximiliano Sandoval 3216f8eaf8 common: Stop using G_GNUC_CONST in _get_type funcs
As per g_type_ensure's documentation it is technically incorrect to mark
_get_type fns with G_GNUC_CONST since they have side-effects on their
first run.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/5223 for more
details.

(cherry picked from commit 59f9a7729f):
2026-08-03 17:22:46 -04:00
Sebastian Wick df58c117e6 portal: Cleanup getting the host-like environment for flatpak-run
(cherry picked from commit 21a9692718):
2026-08-03 17:22:46 -04:00
Sebastian Wick 6b7274071a portal: Pass run-environ to the spawned flatpak process, not the sandbox
Instead of modifying the host-like run environment to clear the sandbox
environment, we'll use the new --clear-env flag which does the correct
thing.

Assisted-by: Claude:opus-4.6
Closes: #5271
(cherry picked from commit afbabdc32c):
2026-08-03 17:22:46 -04:00
Sebastian Wick 884ef1363e portal: Clear error after warning to avoid issues on the next error
(cherry picked from commit 7322a05c7f):
2026-08-03 17:22:46 -04:00
Sebastian Wick 9a4249fab2 Revert "portal: Clear the environment via flatpak arguments"
This reverts commit a57f6bc372.

The run-environ from the calling instance is a host-like environment
(e.g. on NixOS it contains /nix/store paths). Passing it via --env
injects it into the sandbox payload environment where those paths don't
exist.

Revert the commit, so we pass run-environ as the envp for spawning
flatpak run again to let it make host-level decisions (DISPLAY,
FLATPAK_GL_DRIVERS, XDG_RUNTIME_DIR, etc.) without leaking into the
sandbox.

It also passes --clear-env unconditionally, because we'd build up the
environment, but the wrong one. We will implement --clear-env properly
again in the next few commits.

Closes: #6717
Fixes: a57f6bc3 ("portal: Clear the environment via flatpak arguments")
(cherry picked from commit b9fb6d4e25):
2026-08-03 17:22:46 -04:00
Mia McMahill 44f378d6ec completion: Minor cleanup of variable usage in bash completion
1. Removed unnecessary punctuation to help with readability
2. Loop over RES elements directly instead of indexing
3. Declare COMPGEN_OPTS only once vs redeclaring on each iteration

(cherry picked from commit 02fc85a3c2):
2026-08-03 17:22:46 -04:00
Mia McMahill 8712067391 completion: Address a couple shellcheck warnings
1. Use $() command substitution instead of legacy `` style
2. Properly quote COMPGEN_OPTS
3. Use readarray instead of relying on word splitting

(cherry picked from commit 21ae7723c0):
2026-08-03 17:22:46 -04:00
Mia McMahill 436338f40d completion: Make all variables local where possible in bash completion
A few global variables were being created unecessarily still. This makes
sure that users shell environments are not polluted by extra variables
and that the completion doesn't modify unrelated variables

(cherry picked from commit 9047dabfaf):
2026-08-03 17:22:46 -04:00
John Cardullo 20391f71bf run: Validate file object before checking cached path
Verify that the file object is valid before checking its cached path
to avoid a potential NULL pointer dereference.

Fixes: c4fce9e4 ("run: Error out if file forwarding of empty paths is attempted")
(cherry picked from commit f266346d6d):
2026-08-03 17:22:46 -04:00
Sebastian Wick b8fb355412 run: Error out if file forwarding of empty paths is attempted
The file forwarding feature errors out when the path or URI does not
lead to an actual file that can be forwarded. The empty path never
describes an actual file, so we always have to error out.

Without the check, we would get a NULL path from
`flatpak_file_get_path_cached` and crash later.

Closes: #6689
(cherry picked from commit c4fce9e42a):
2026-08-03 17:22:46 -04:00
Sebastian Wick 850db84d17 portal: Check if the monitor is closed before emitting progress
`emit_progress` is called from a thread while another thread could
unexport/close the GDbusInterfaceSkeleton. If that happens, the
connection becomes NULL which is illegal for
`g_dbus_connection_emit_signal` which results in dereferencing an unset
error.

The fix is to lock the UpdateMonitorData, and then only emit the signal
if it is not closed.

(cherry picked from commit ce4a27e1fe):
2026-08-03 17:22:46 -04:00
Owen W. Taylor b7025a7b07 Handle null properties as missing properties
We were handling null properties the same as missing properties
*except* that the MANDATORY flag allowed null properties but
not missing properties. Fix this, so null is disallowed by
MANDATORY.

When checking signatures, the image identity could only have
been NULL if it was null in the input file - so replace a
conditional check on it being non-null with an assertion.

(cherry picked from commit 906affa13b):
2026-08-03 17:22:46 -04:00
Owen W. Taylor dd00e84edf Fix crash on image indexes with missing architecture
It's legitimate to have manifests listed in an image index that
have no platform object, and hence no architecture - avoid crashing
if we encounter such a manifest.

(cherry picked from commit b15828e119):
2026-08-03 17:22:46 -04:00
Owen W. Taylor 1ba6d2d8a3 Make mandatory properties from OCI specifications mandatory
Mark all properties required by the OCI specification as required;
this eliminates a bunch of cases where we were assuming that
descriptor->digest was non-NULL, and potentially generating
critical errors from g_return_if_fail().

(cherry picked from commit fa4b413c02):
2026-08-03 17:22:46 -04:00
Mia McMahill 5ca141db18 app, common: Remove duplicate directories from export functions
Both collect exports and flatpak_export_dir recursively export the
directories in their respective directory lists. Because of this,
including share/metainfo/releases when share/metainfo is already in the
lists is unnecessary and can cause exporting to fail because of
duplicate files.

(cherry picked from commit 4d3f0bbb79):
2026-08-03 17:22:46 -04:00
Kolja Lampe 9462a59e2e http: Propagate stream write failures to curl
We did not report the written bytes of the aborted stream before - so
curl thought that we wrote all bytes.

(cherry picked from commit 4ff158caea):
2026-08-03 17:22:46 -04:00
Kolja Lampe 13fa7494c5 http: Reset curl TLS options between transfers
Previously the curl object potentially leaked cert infos from different
urls

(cherry picked from commit 420ce91428):
2026-08-03 17:22:46 -04:00
Razze 1534762a20 oci-registry: Apply TLS certs to request
Signature downloads can use a different URL from the OCI registry
itself, so they must not depend on TLS options left on the reused curl
handle. Resolve certificates for the URI and pass them explicitly.

(cherry picked from commit 8ac2adefce):
2026-08-03 17:22:46 -04:00
bbhtt 880d912adb instance: Annotate flatpak_instance_get_all as (transfer container)
Annotating the return as (transfer full) causes bindings to additionally
unref each element on array free, resulting in a use-after-free.

Change the annotation to (transfer container) so bindings know to unref
the array only.

Fixes: https://github.com/flatpak/flatpak/issues/6666
(cherry picked from commit 69bf837676):
2026-08-03 17:22:46 -04:00
asbytes cf3103d327 context: Fixed negated permission string for allow and share options
It was solved partially in e0e1b20, but not for completely disallowed code path.
Steps to reproduce:
1. Run any flatpak with explicit --unshare option, e.g:
    [user@user-standardpc ~]$ flatpak run --unshare=network --command=bash io.gitlab.librewolf-community
2. Inside flatpak shell spawn any executable:
    [io.gitlab.librewolf-community ~]$ flatpak-spawn ls /
Result is:
error: Unknown option --noshare=network

(cherry picked from commit db70882df1):
2026-08-03 17:22:46 -04:00
Sebastian Wick fe08fc001a oci-registry: Check signatures from mirrored repo in the system helper
In flatpak_pull_from_oci we can be in in the system helper where we pull
the mirrored OCI image into the system repo. However, to fetch the
signatures in GPG signed repos, we used a remote OciImageSource created
through `flatpak_remote_state_fetch_image_source`. This caused fetching
some data from the registry which we don't want in the deploy method,
and also fails if a token is required to access the repo.

This change fetches the signatures from the mirrored OCI repo instead of
pulling them from the remote OciImageSource. The signatures can come from
anywhere because we verify them against the GPG key in the system repo.

The important bit is the change in `flatpak_pull_from_oci` where we now
pass in the local image_source to fetch the signatures from, and in the
system helper, where we get the right metadata to check the signatures
against (eventually ends up in `flatpak_oci_signatures_verify`).

(cherry picked from commit 32baedaa7e):
2026-08-03 17:22:46 -04:00
Sebastian Wick 56869b2343 oci-registry: Load the certificates from an ImageSource
(cherry picked from commit 1a33d1a15b):
2026-08-03 17:22:46 -04:00
Sebastian Wick 47e74f2624 Update subtree: libglnx 2026-06-18
* backports, local-alloc: Provide a backport of g_autofd
* build: Add meson.override_dependency('libglnx', libglnx_dep)
* fdio: Add support for name_to_handle_at
* chase: Add glnx_chase_and_mkdirat

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2026-08-03 20:58:30 +02:00
Sebastian Wick 8ef5ee9455 Merge branch 'wip/chase-callback' into 'master'
chase: Add glnx_chase_and_mkdirat

See merge request GNOME/libglnx!76
2026-06-17 12:30:57 +00:00
Sebastian Wick ae7355612a chase: Add glnx_chase_and_mkdirat
We found that there is a common use case where we need to get a
subdirectory (potentially multiple levels) which might not exist yet.
Adding another flag for this to GlnxChaseFlags is what systemd has done,
but creating a directory takes a mode, so the flag creates directories
with a fixed mode. This approach instead takes the mode as argument.
2026-06-17 14:27:41 +02:00
Sebastian Wick 4f8674709d chase: Add internal glnx_chaseat_full for a strategic callback
It takes a callback which gets called every time we try to open the next
segment of the path. This allows implementing more specific and advanced
use cases to be implemented without adding more complexity to the chase
algorithm itself.
2026-06-17 14:27:16 +02:00
Simon McVittie c88d9f2251 Merge branch 'wip/meson-override-dependency' into 'master'
build: Add meson.override_dependency('libglnx', libglnx_dep)

See merge request GNOME/libglnx!77
2026-06-11 16:25:49 +00:00
Sebastian Wick cc47d35c1e Post-branching version bump 2026-06-08 15:40:05 +02:00
Sebastian Wick 5de2b58bda 1.18.0 1.18.0 2026-06-08 14:36:33 +02:00
Sebastian Wick 90f3aa450f Update SECURITY.md 2026-06-08 14:35:23 +02:00
Sebastian Wick ad7aff2c55 Update translation files for 1.18.0 2026-06-08 14:22:12 +02:00
razzeee 6b6fdda2f6 flatpak-coredumpctl: Guard against unexpected coredumpctl output
The bare tuple unpack 'executable, = re.findall(...)' raises a cryptic
ValueError if the pattern matches zero or more than one line. Replace it
with an explicit length check and a clear error message.

Also pass count=1 to str.replace() so a /newroot prefix is only stripped
once and /app/ paths are passed through unchanged.
2026-06-08 12:10:42 +00:00
Mia McMahill 8c418fa4b9 flatpak-coredumpctl: Use subprocess.PIPE instead of NamedTemporaryFile 2026-05-27 14:48:22 +00:00
Mia McMahill 61272df8cd flatpak-coredumpctl: Require Python 3.10 or greater at runtime 2026-05-27 14:48:22 +00:00
Mia McMahill b6ceab85c3 flatpak-coredumpctl: Pass tuple to startswith instead of two calls 2026-05-27 14:48:22 +00:00
Mia McMahill 4bcd6cd48b flatpak-coredumpctl: Pass description as argparse description argument
This prevents it from getting printed twice in some circumstances
2026-05-27 14:48:22 +00:00
Mia McMahill 8e5d4c1183 flatpak-coredumpctl: Exit with return code of flatpak_command 2026-05-27 14:48:22 +00:00
Mia McMahill 0285e879d0 flatpak-coredumpctl: Print help message to stderr
This is more consistent with common practice for
help messages printed due to missing/incorrect arguments.
2026-05-27 14:48:22 +00:00
Mia McMahill d7dbb10845 flatpak-coredumpctl: Replace old style format strings with f-strings
Print out error messages instead of raising an uncaught exception

Replace one more set of quotes that I missed previously
2026-05-27 14:48:22 +00:00
Mia McMahill f48c7866b6 flatpak-coredumpctl: Clean up mixed usage of single and double quotes 2026-05-27 14:48:22 +00:00
Mia McMahill af453ce99d flatpak-coredumpctl: Check for /app as well as /newroot
This fixes a bug where the warning about not being a flatpaked
application was being printed for flatpaks. This was due to a
change in bwrap so that the paths no longer start with /newroot.
2026-05-27 14:48:22 +00:00
Jordan PetridisandDan Nicholson 9a813ffba0 dir: Ignore system bus failures in parental controls check
Being unable to access the system-bus is nto a security boundry since,
in that case it's trivial to start your own session and set
DBUS_SYSTEM_BUS_ADDRESS. This is the same fix as 3afdfd2 but for handling
installation instead. See said commit for more details.

Adapted from #5609
Fixes #5076

Co-authored-by: Dan Nicholson <dbn@endlessaccess.org>
2026-05-27 14:39:32 +00:00
razzeee 8fd0f5d706 run: Add /dev/kfd to dri device permission
/dev/kfd is used for AMD ROCm/OpenCL compute. Add it to the dri
device list so apps can request GPU compute access without
needing --device=all.

Fixes: https://github.com/flatpak/flatpak/issues/5383
2026-05-27 14:36:25 +00:00
qweered 3891a228c6 profile: Skip flatpak --installations for fish if already in XDG_DATA_DIRS
Sourcing profile/flatpak.fish spawns `flatpak --installations` on every
fish shell startup, which costs ~15 ms on a typical desktop and
dominates fish's non-interactive init time when flatpak is installed.

On any system where the login stack (pam_env, systemd user session,
distro-specific init) has already populated XDG_DATA_DIRS with the
canonical user flatpak export path, this spawn is redundant: the
subsequent `contains` loop would be a no-op because the canonical
entry is already there.

Add a fast-path guard that checks for `$XDG_DATA_HOME/flatpak/exports/share`
(falling back to `$HOME/.local/share/flatpak/exports/share` when
XDG_DATA_HOME is unset) at the top of the script. When present, skip
the slow path entirely.

The slow path is preserved verbatim for sessions where the canonical
entry is missing — e.g. a freshly-created user, or environments where
session init hasn't populated XDG_DATA_DIRS yet — so custom
installations configured via /etc/flatpak/installations.d/*.conf are
still discovered in that case.

Measured on Linux with `hyperfine --warmup 5 'fish -c exit'`:
  before: ~23 ms of startup spent in `flatpak --installations`
  after:  ~10 us (a single `contains` check) on the common path.
2026-05-27 14:34:21 +00:00
bbhtt a38377eb88 tests: Suppress an unused-result warning
The warning seems to happen with GCC 11 but not with GCC 13 or newer.

A simple void cast still leaves the warning enabled due to a bug
or intentional choice in GCC [1], so it is assigned to a variable first
and then void-ed.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
2026-05-27 14:32:40 +00:00
lumingzh da20e502d9 update Chinese translation 2026-05-27 14:30:28 +00:00
Ryan Gonzalez 588eef8e65 dir: Include found refs in "ref binding metadata" errors
I accidentally screwed up the arch I passed to a `flatpak update`
invocation and was very confused as to what actually went wrong. Adding
the actual refs in the commit should help make failure cause more
obvious.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2026-05-13 02:44:17 +00:00
razzeee 7b17f13e5d http: Replace deprecated GTimeVal with g_get_real_time()
GTimeVal and g_get_current_time() are deprecated since GLib 2.62
and tv_sec is 32-bit on 32-bit platforms, causing Y2038 overflow.
g_get_real_time() returns gint64 and is safe on all platforms.
2026-05-13 01:08:29 +00:00