Commit Graph

8483 Commits

Author SHA1 Message Date
Mia McMahill
4d3f0bbb79 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.
2026-06-16 11:20:58 +00:00
Mia McMahill
cebc323966 tests: Add test for building and installing with exported releases.xml
Adds a test that verifies releases.xml metainfo files are not duplicated
at any export stage, and that they are not left unexported either.
2026-06-16 11:20:58 +00:00
Kolja Lampe
4ff158caea 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.
2026-06-15 10:02:12 +00:00
Kolja Lampe
420ce91428 http: Reset curl TLS options between transfers
Previously the curl object potentially leaked cert infos from different
urls
2026-06-15 10:02:12 +00:00
Razze
8ac2adefce 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.
2026-06-15 10:02:12 +00:00
bbhtt
69bf837676 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
2026-06-15 09:26:10 +00:00
asbytes
db70882df1 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
2026-06-11 20:40:49 +00:00
Luigi Pavan
b9c3cdd7a4 tests: Add test for installing from an auth-protected OCI registry
Add a regression test that installs from an auth-protected OCI registry.
The registry requires a bearer token for all /v2/ requests; the client
authenticates via the mock test authenticator and the installation
completes successfully. The test runs for both user and system install
paths.

Assisted-by: Cursor
2026-06-11 18:26:52 +00:00
Luigi Pavan
a5b15b9aa1 tests/oci-registry: Add bearer token auth support to the mock OCI registry
Add infrastructure for testing OCI installations from auth-protected
registries. The mock server now supports requiring a bearer token on all
/v2/ requests, configurable via a new POST /testing-auth/configure admin
endpoint. The client gains a corresponding 'configure-auth' subcommand.

Assisted-by: Cursor
2026-06-11 18:26:52 +00:00
Sebastian Wick
32baedaa7e 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`).
2026-06-11 18:26:52 +00:00
Sebastian Wick
1a33d1a15b oci-registry: Load the certificates from an ImageSource 2026-06-11 18:26:52 +00:00
Sebastian Wick
96ad6825f3 Post-release version bump 2026-06-08 14:51:50 +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 Petridis
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
razzeee
cc727e7f09 dir/http: Use gint64 for g_ascii_strtoll return values
g_ascii_strtoll returns gint64; storing the result in a narrower
type (int, gint) silently truncates large values.
2026-05-13 01:08:29 +00:00
razzeee
250516b059 history: Use uid_t and g_ascii_strtoull for UID parsing
UIDs are unsigned; using signed strtoll and int can mishandle
high UIDs such as those used by systemd dynamic users.
2026-05-13 01:08:29 +00:00
Rudi Heitbaum
68ffa487ee dir: fix build when HAVE_LIBSYSTEMD but not USE_SYSTEM_HELPER
polkit_subject_to_string() is called inside the HAVE_LIBSYSTEMD guard
in flatpak_dir_log(), but <polkit/polkit.h> is only included when
USE_SYSTEM_HELPER is defined. This causes a build failure on
configurations that have libsystemd but no system helper.

Guard the polkit call with USE_SYSTEM_HELPER and fall back to "(none)"
so the subject string is always valid for the sd_journal_send() call.

Fixes: f9d5c5c ("dir: Free result of polkit_subject_to_string")
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
2026-05-09 18:56:16 +05:30
Sebastian Wick
3daccaeadc Post-branching version bump 2026-05-06 00:51:17 +02:00
Sebastian Wick
b4c53a4cff 1.17.7 1.17.7 2026-05-06 00:48:51 +02:00
Sebastian Wick
8d58ebdeb4 Update translation files for 1.17.7 2026-05-06 00:43:28 +02:00
Sebastian Wick
17cb1135cb context: Keep fallback-x11 separate from x11 conditionals
If we convert fallback-x11 internally to a conditional x11 permission,
we cannot express current fallback-x11 stacking behavior:

lower: empty + upper: !fallback-x11 -> no x11 access
lower: fallback-x11 + upper: !fallback-x11 -> x11 access

The reason is that conditionals have no view of the lower level.

This changes things in a way that fallback-x11 stays its own socket
permission with two interactions with the x11 socket permission:

* If a upper level resets x11 (--socket=x11, --nosocket=x11), the lower
  level fallback-x11 permission gets dropped
* When computing the allowed sockets, --socket=fallback-x11 gets
  converted to --socket=if:x11:!has-wayland

Fixes: #6556
2026-04-29 10:14:29 +00:00
Sebastian Wick
bd75302323 tests/repo: Make a test more robust by checking files for diff
Instead of trying to read them into variables, which could fail if there
were null bytes in the key.

Fixes: 43642337 ("dir: Try to delete the remote if we failed to add it entirely")
2026-04-28 13:18:48 +00:00
Sebastian Wick
3296c9e619 system-helper: Fix checking if the reinstall flag was passed in
Fixes: 919d2922 ("common: support reinstall option on bundle installations")
2026-04-28 13:18:48 +00:00
Sebastian Wick
68343e938f tests: Fix checks where we expect a command to fail
I was convinced that the pattern `! command` with -e aborts when
`command` fails. This is not the case (the result of `false` is the same
as `! true` but somehow this doesn't matter).

Fix the tests and use the newly introduced `assert_not` function. One
could also use `command && assert_not_reached "message"` but who has
time to write error messages for all the cases.
2026-04-28 13:18:48 +00:00
razzeee
6dfe1ad4d0 dir: handle missing remote tracking ref in repo_pull so that Flatpak-Upgrade-From header is sent 2026-04-21 11:28:31 +00:00
razzeee
fad37dfa8c tests: add test for Flatpak-Upgrade-From header on install vs update
Add an integration test that verifies the Flatpak-Upgrade-From HTTP
header is correctly sent during update operations but absent during
fresh installs. This header is used by Flathub to distinguish updates
from new installs in download statistics.

To support the test, extend web-server.py to optionally log Flatpak-*
request headers to a separate file.
2026-04-21 11:28:31 +00:00
Gordon Messmer
fffe38a2b0 common: Report the age of the configuration
This change will allow applications to determine if their data
is older than the flatpak configuration, to aid cache invalidation.
2026-04-20 14:00:20 +00:00
Sebastian Wick
43642337e4 dir: Try to delete the remote if we failed to add it entirely
Ideally, we would be able to atomically add and remove remotes, but
we're very far from that ideal state. The current behavior is really
suboptimal and leaves the remotes in a inconsistent state if
initialization failed. We can at least make it better by trying to clean
up the half-initialized mess we're currently in. It does however not
protect against SIGKILL-like aborts, as that would require it to be
atomic.

Closes: #6449
Co-authored-by: craftyguy "Clayton Craft" <clayton@craftyguy.net>
2026-04-20 13:59:14 +00:00
lumingzh
7781da7767 update Chinese translation 2026-04-19 05:35:30 +05:30
Razze
3f2e10e274 tests: add missing assertions after second flatpak_usb_parse_usb_list call
The call to flatpak_usb_parse_usb_list() lacked the
g_assert(ret) and g_assert_no_error(error) guards that are present
on the first call.
2026-04-18 20:33:07 +05:30
emintufan
1ae9b4a4e8 Update Turkish translation 2026-04-18 18:33:04 +05:30
Sebastian Wick
5314d8cf93 dir: Succeed ensure_repo with allow_empty when system helper fails
If _flatpak_dir_ensure_repo is called with allow_empty=true, it is
allowed to fail to create the repo, and is supposed to return success in
that case.

The system helper handles this correctly, but we then call to
ensure_repo_opened no matter if the repo actuall exists and return an
error when it does not, no matter if allow_empty is set or not.

Closes: #6618
2026-04-16 15:24:46 +00:00