Commit Graph

8198 Commits

Author SHA1 Message Date
Sebastian Wick
36bd977772 flatpak-bwrap: Add dup-ing variant flatpak_bwrap_add_args_data_fd_dup 2026-04-07 16:17:51 -04:00
Simon McVittie
af44a2c9ff Update subtree: libglnx 2026-04-07
* fdio: Avoid relying on VLAs or gcc-specific constant-folding
* errors: Fix URL to an old libgsystem commit
* lockfile: Assert non-null path in make_lock_file for analyzers
* backports: Add g_clear_fd
* glnx-errors.h: add glnx_fd_throw[_*] variants
* fdio: Add glnx_fd_reopen
* local-alloc: Remove duplicate definition of glnx_unref_object
* fdio: Add glnx_statx
* chase: Add glnx_chaseat which functions similar to openat2
* chase: Add glnx_chase_and_statxat

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-04-07 20:46:35 +01:00
Simon McVittie
ccea836b79 Merge branch 'wip/smcv/autotools' into 'master'
build: Include glnx-chase in the Autotools build system, too

See merge request GNOME/libglnx!71
2026-04-07 14:54:55 +00:00
Simon McVittie
e3006ead94 build: Include glnx-chase in the Autotools build system, too
Fixes: a973baad "chase: Add glnx_chaseat which functions similar to openat2"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-04-06 21:29:01 +01:00
Simon McVittie
aae4505722 Merge branch 'wip/smcv/chase' into 'master'
chase: Fix a memory leak and some undefined behaviour

See merge request GNOME/libglnx!69
2026-03-24 20:45:24 +00:00
Simon McVittie
6dbe18bcda chase: Factor out a function to append to the queue
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:47 +00:00
Simon McVittie
46205a62d2 chase: Don't leak struct glnx_statx when we go up a level
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:47 +00:00
Simon McVittie
916b70619c chase: Don't left-shift signed integer 1 by 31 places
This overflows, which is undefined behaviour (in practice it will usually
wrap around into unsigned space, but this can't be guaranteed).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-24 20:43:45 +00:00
Sebastian Wick
7c1e8bd756 Merge branch 'wip/chaseat' into 'master'
chase: Safely traversing the filesystem

See merge request GNOME/libglnx!64
2026-03-24 11:21:17 +00:00
Sebastian Wick
4bacb4332a tests: Add comprehensive tests for glnx_chase_and_statxat
Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-17 18:40:38 +01:00
Sebastian Wick
b4b9951901 chase: Add glnx_chase_and_statxat
This combines glnx_chaseat with a call to glnx_statx for convenience.
2026-03-17 18:40:38 +01:00
Sebastian Wick
5f92fc4a93 tests: Add comprehensive tests for glnx_chaseat 2026-03-17 18:40:38 +01:00
Sebastian Wick
a973baad08 chase: Add glnx_chaseat which functions similar to openat2
The selling features are:

* Support for RESOLVE_BENEATH, RESOLVE_IN_ROOT and RESOLVE_NO_SYMLINKS
* Fallback from openat2 to open_tree to openat for compatibility
* Triggering of automounts
2026-03-17 18:40:38 +01:00
Sebastian Wick
2a75ac86e9 missing: Add syscall number for openat2() and open_tree()
They are taken from an older revision of systemd with minimal changes.
2026-03-12 00:41:48 +01:00
Sebastian Wick
01508367b4 fdio: Add glnx_statx 2026-03-12 00:41:48 +01:00
Sebastian Wick
14578d856e missing: Add syscall and structs for statx()
They are taken from an older revision of systemd with minimal changes.
2026-03-12 00:41:48 +01:00
Simon McVittie
8eb974e539 Merge branch 'wip/smcv/dup-unref-object' into 'master'
[trivial] local-alloc: Remove duplicate definition of glnx_unref_object

See merge request GNOME/libglnx!67
2026-03-10 17:32:50 +00:00
Colin Walters
287353e5ae Merge branch 'wip/smcv/wpointer-sign' into 'master'
[trivial] tests: Avoid a -Wpointer-sign warning

See merge request GNOME/libglnx!66
2026-03-10 17:11:27 +00:00
Simon McVittie
27f2b28c4f local-alloc: Remove duplicate definition of glnx_unref_object
The same `#define` exists both before and after `glnx_local_obj_unref()`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-05 13:29:31 +00:00
Simon McVittie
f4101e805c tests: Avoid a -Wpointer-sign warning
test_data is an array of (usually) signed char, but
glnx_file_replace_contents_at() takes an array of unsigned bytes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-05 13:24:43 +00:00
Colin Walters
51a1c2a9b6 Merge branch 'wip/various-improvements-1' into 'master'
glnx_fd_reopen, glnx_fd_throw, gcc fanalyzer improvements

See merge request GNOME/libglnx!65
2026-03-03 14:45:27 +00:00
Sebastian Wick
0b0703c3f0 tests: Add comprehensive tests for glnx_fd_reopen
Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 01:29:05 +01:00
Sebastian Wick
1ec49dfc9b fdio: Add glnx_fd_reopen
Reopens the specified fd with new flags. This is useful for convert an
O_PATH fd into a regular one, or to turn O_RDWR fds into O_RDONLY fds.
2026-02-21 01:29:05 +01:00
Sebastian Wick
c33f0ed05e glnx-errors.h: add glnx_fd_throw[_*] variants
Similar to the glnx_null_throw variants, this one returns -1 instead of
FALSE or NULL. This is helpful when dealing with functions which return
a fd.
2026-02-18 00:35:43 +01:00
Sebastian Wick
cdce8957b2 backports: Add g_clear_fd 2026-02-18 00:35:43 +01:00
Sebastian Wick
6a556d05d1 lockfile: Assert non-null path in make_lock_file for analyzers
Asserting the value helps the gcc analyzer and avoids a false-positive.
2026-02-17 22:53:31 +01:00
Sebastian Wick
32ba624845 Post-release version bump 2026-01-21 12:55:56 +01:00
Sebastian Wick
b76f2533c7 Update translation files for 1.16.3 1.16.3 2026-01-21 12:19:58 +01:00
Sebastian Wick
11bed7cca4 Update NEWS for 1.16.3 2026-01-21 12:18:38 +01:00
Christian Hergert
11473c515c app: be selective about when to map font-dirs.xml
If the command calling `flatpak build` has already specified a
font-dirs.xml to map, then mapping in again may break (as exemplified in
Builder and Foundry).

This checks to see if an argument has already been mapped in before doing
so and resolves the issue with Builder/Foundry.

Follow-up to !6138

Fixes: GNOME/gnome-builder#2387

(cherry picked from commit c896faae19)
2026-01-21 15:59:52 +05:30
Sebastian Wick
8b73df49b1 Post-release version bump 2025-12-17 22:33:05 +01:00
Sebastian Wick
7c806e340c Update translation files for 1.16.2 1.16.2 2025-12-15 18:52:28 +01:00
Sebastian Wick
631213c562 Update NEWS for 1.16.2 2025-12-15 18:52:28 +01:00
Sebastian Wick
ec36a48446 tests/test-run.sh: Only test for trigger results if we have the deps
If the binaries are not available in the environment, the trigger will
not do anything. The tests will not know about this and fail. So only
test for the results of the triggers if they have the dependencies they
require.

(cherry picked from commit 78b3c47c13)
2025-12-15 18:52:28 +01:00
Sebastian Wick
5c549cd5d0 kill: Do not kill pid 0 and embrace races
There are a number of races, and failure conditions which can lead to a
pid of 0 being returned from flatpak_instance_get_child_pid. This would
lead to a whole bunch of things getting killed.

We will skip the instance in those cases now, and retry a few times. We
also notice when the instance just goes away by itself now.

This should make killing more robust, and especially not SIGKILL pid 0.

(cherry picked from commit 8354ee56cf)
2025-12-03 19:34:17 -05:00
Georgia Garcia
2acd59913f common: Fix running_under_sudo check by checking euid
Sudo can be used in several ways other than calling a command with the
root user. For example, one can use -u to run the command as the
specified user, or -g to specify a primary group to run the command
as.

Flatpak adds a check when --user is used to prevent an installation in
the root's directory, for example, but it does it by only checking if
sudo was used. As stated previously, it does not necessarily imply
root, so this patch explicitly checks if the command is being run with
the root user.

Fixes: https://github.com/flatpak/flatpak/issues/5979
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit f61d931da8)
2025-12-03 19:34:17 -05:00
Kolja Lampe
2cd0b8c05e http: Add cancellation support for curl downloads and error handling
(cherry picked from commit b6775dc221)
2025-12-03 19:34:17 -05:00
Sebastian Wick
e4271b82b2 doc: Build libflatpak-doc.html
Closes #4591

(cherry picked from commit 815301f341)
2025-12-03 19:34:17 -05:00
Sebastian Wick
94b915352a context: Canonicalize xdg dir and home dir paths
When an xdg dir is not available, it is supposed to point at $HOME. We
do not want to mount $HOME though in that case, so we just skip the xdg
dir instead.

The check compares the strings of the the xdg dir path and the home dir
path. So far it relied on the functions internally canonicalizing the
paths in the same way, but there was a glib regression:

https://gitlab.gnome.org/GNOME/glib/-/issues/3811
("g_get_user_special_dir doesn't strip trailing slash from $HOME")

Which then was fixed in cb3e9fe74 ("gutils: Strip all trailing
slashes").

We can however just canonicalize on the paths on the caller side to make
this more robust, so let's just do that.

Closes: #6323
(cherry picked from commit bb2d517bb1)
2025-12-01 11:38:47 -05:00
joj
f415c676a3 Enable VA-API extension for Intel GPUs if either i915 or xe is loaded
Xe module supports the discrete and new integrated GPUs (the Arc series) and
the i915 supports the older Intel integrated GPUs (Intel HD).

Closes: https://github.com/flatpak/flatpak/issues/5248
(cherry picked from commit f53cef0041)
2025-12-01 11:04:56 -05:00
Mary Strodl
4c5693b892 common: support reinstall option on bundle installations
Fixes #2489

Adds and wires up a `reinstall` option to
`flatpak_dir_install_bundle`. Previously, bundle install
transactions would silently drop the reinstall flag.

(backported from commit 919d2922bf)
2025-12-01 11:04:56 -05:00
Sebastian Wick
159796af54 oci: Actually only return the only manifest in get_only_manifest
Instead of using flatpak_oci_manifest_descriptor_get_ref which requires
the `org.opencontainers.image.ref.name` annotation, get any valid
manifest, and make sure to return NULL if there are multiple valid
manifests.

Closes: https://github.com/flatpak/flatpak/issues/6081
(cherry picked from commit 3773617f30)
2025-12-01 11:04:56 -05:00
Sebastian Wick
3c007c97e2 transaction: Handle --include-sdk if SDK is installed in other dir
If an SDK is already installed in a dir that is not targeted with a
flatpak transaction, and the transaction has auto_install_sdk set,
add_new_dep_op returns NULL in dep_op which is not correctly handled in
add_deps.

Fixes #5894

(cherry picked from commit c4af112df4)
2025-11-20 06:20:38 +05:30
Chris Williams
f98c5d1bc4 dir: Also reload repo configuration after setting via system helper
Without doing so, flatpak_dir_get_config() won't reflect changes made
with flatpak_dir_set_config().

This fixes passing multiple patterns to `flatpak mask` for the system
installation.

Closes #5464

(cherry picked from commit a7ac4206c6)
2025-11-20 06:20:38 +05:30
bbhtt
7127ef00d0 utils-http: Fix an uninitialised variable warning
Fixes c75ba1c7e1

```
In file included from /usr/lib/aarch64-linux-gnu/glib-2.0/include/glibconfig.h:9,
 from /usr/include/glib-2.0/glib/gtypes.h:34,
 from /usr/include/glib-2.0/glib/galloca.h:34,
 from /usr/include/glib-2.0/glib.h:32,
 from /usr/include/glib-2.0/gobject/gbinding.h:30,
 from /usr/include/glib-2.0/glib-object.h:24,
 from /usr/include/glib-2.0/gio/gioenums.h:30,
 from /usr/include/glib-2.0/gio/giotypes.h:30,
 from /usr/include/glib-2.0/gio/gio.h:28,
 from ../common/flatpak-utils-http.c:23:
In function ‘glib_autoptr_clear_GFileEnumerator’,
 inlined from ‘glib_autoptr_cleanup_GFileEnumerator’ at /usr/include/glib-2.0/gio/gio-autocleanups.h:69:1,
 inlined from ‘flatpak_get_certificates_for_uri’ at ../common/flatpak-utils-http.c:284:34:
/usr/include/glib-2.0/glib/gmacros.h:1361:10: warning: ‘enumerator’ may be used uninitialized [-Wmaybe-uninitialized]
 1361 | { if (_ptr) (cleanup) ((ParentName *) _ptr); } \
 | ^
/usr/include/glib-2.0/glib/gmacros.h:1379:3: note: in expansion of macro ‘_GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS’
 1379 | _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, TypeName, func)
 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/gio/gio-autocleanups.h:69:1: note: in expansion of macro ‘G_DEFINE_AUTOPTR_CLEANUP_FUNC’
 69 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileEnumerator, g_object_unref)
 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../common/flatpak-utils-http.c: In function ‘flatpak_get_certificates_for_uri’:
../common/flatpak-utils-http.c:284:34: note: ‘enumerator’ was declared here
 284 | g_autoptr(GFileEnumerator) enumerator;
```

(cherry picked from commit cd0212aa40)
2025-11-14 20:14:30 +05:30
Sebastian Wick
5ef65d31ee oci-registry: Fix leak by freeing certificates in finalize
(backported from commit 5a80ac679d)
2025-11-14 20:14:30 +05:30
taoky
228dfab479 utils: Don't pass NULL remote to ostree_repo_get_remote_option
Fixes: #4662
(cherry picked from commit dd2a04f978)
2025-11-14 20:14:30 +05:30
Michael Catanzaro
c3c611ce19 doc: update documentation of flatpak-spawn --watch-bus
The current documentation is misleading, and confused multiple
experienced developers for the past two years.

Fixes #5501

(cherry picked from commit 0152272d6c)
2025-11-14 20:14:30 +05:30
Simon Chopin
a13fc5b72f testlib: add expected argument to fcntl(F_DUPFD)
The F_DUPFD and its relative F_DUPFD_CLOEXEC both expect an int argument
as extra argument, being the minimal value for the new FD. This argument
must be within the accepted range (see ulimit -H -n).

This was detected in Ubuntu during testing against the latest glibc,
stracing resulted in:

107244 fcntl(1, F_DUPFD_CLOEXEC, 1847846346272) = -1 EINVAL (Invalid argument)

On the system in question (ppc64el machine running Ubuntu Questing), the
relevant limit is 524288.

For the fix we use 3 as a reasonable floor value, as in the first one
after stderr. It also happens to be the one used in revokefs/main.c.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/2121039
(cherry picked from commit 7399dea960)
2025-11-14 08:39:37 +05:30
Martin Schwenke
d02c0bbec5 session-helper: Avoid a memory leak
Apply the fix suggested more than a year ago in:

  https://github.com/flatpak/flatpak/issues/5821#issuecomment-2121673464

Signed-off-by: Martin Schwenke <martin@meltin.net>

Fixes: https://github.com/flatpak/flatpak/issues/5821
(cherry picked from commit cd80e84343)
2025-11-13 06:29:44 +05:30