Commit Graph

7285 Commits

Author SHA1 Message Date
Dor Askayo
1dc334c8a9 instance: Use glnx_opendirat() where possible
Doing so adds the following flags to the openat() call:
O_RDONLY | O_NONBLOCK | O_NOCTTY

And removes the following flag: O_PATH

Also let libglnx handle the error message formatting.
2023-09-22 14:32:17 +01:00
Timo Eisenmann
02bef871c0 remote-info: Fix call to flatpak_dir_load_appstream_store()
Use architecture instead of id in call to
flatpak_dir_load_appstream_store ().

Without this, remote-info does not show AppStream metadata.

Fixes: adb3b61f "decomposed: Return FlatpakDecomposed from flatpak_dir_find_remote_ref()"
2023-09-18 19:42:13 -05:00
Philip Withnall
d6b10c26ef utils-http: Add transfer speed timeout for libcurl HTTP downloads
There was already a timeout set using `CURLOPT_CONNECTTIMEOUT`, but that
only affects the initial connection. Once a HTTP connection is
established, the timeout is ineffective.

That means that once a HTTP connection is established, there is no bound
on the length of time a download can take. Sometimes, downloads drop to
very low speeds (for Networking Reasons) and we need a way to give up on
a download if that happens.

So, set a low speed limit of 10KB/s for 60s. If a curl download goes
more slowly than this, it will be considered timed out, and the
`CURLE_OPERATION_TIMEDOUT` code path will be taken.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: https://github.com/flatpak/flatpak/issues/5519
2023-09-15 12:36:25 +01:00
Simon McVittie
106d2065c8 Update NEWS to date
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-10 13:59:24 +01:00
Simon McVittie
e6bd149c25 build: Generate Wayland glue code as private
The `code` argument to wayland-scanner is deprecated in favour of
`private-code`, which marks the symbols as private, avoiding them
leaking into the ABI of `libflatpak.so.0`.

`private-code` was new in wayland-scanner 1.15, which is available in
relatively old LTS distributions like CentOS 7, Debian 10 and
Ubuntu 18.04, and is much older than wayland-protocols 1.32.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-10 13:58:53 +01:00
Simon McVittie
bb8afb0328 build: Link Wayland code into full libflatpak-common only
This is only needed in flatpak-run-wayland.c, so we don't need it when
linking ancillary daemons that don't need any of flatpak-run, such as
the portal, session helper, system helper and OCI authenticator.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-10 13:58:53 +01:00
Forest
738a0b14de Add --device=input permission
This new permission exposes the host's /dev/input directory, providing
minimal game controller support without resorting to --device=all.
2023-09-08 19:03:24 +01:00
K.B.Dharun Krishna
0e2508a843 CI: bump actions/checkout to v4 2023-09-04 19:49:55 +01:00
Simon McVittie
d42d3e9772 dir: Use g_strv_equal()
This was new in GLib 2.60, but libglnx now provides a backport, so we
can use it unconditionally.

We still need a wrapper because g_strv_equal() is not NULL-safe, but
it's a very thin wrapper now.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-04 13:25:32 +01:00
Simon McVittie
5009857b5a Use g_steal_fd()
This was new in GLib 2.70, but libglnx now provides a backport, so we
can use it unconditionally.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-04 13:25:32 +01:00
Simon McVittie
17202b16e1 Update submodule: libglnx 2023-08-29
* Add g_steal_fd() backport
* Add g_strv_equal() backport
* Disable crash reporting when testing assertions

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-04 13:25:32 +01:00
EkaterinePapava
ff9af52b6f po: Add Georgian translation 2023-08-30 12:15:15 +01:00
EkaterinePapava
58b70e31ea Update LINGUAS: Add Georgian 2023-08-30 12:15:15 +01:00
Sabri Ünal
5a9a56b605 Update Turkish translation 2023-08-30 12:10:33 +01:00
Kukuh Syafaat
601e6e43a6 Update Indonesian translation 2023-08-30 12:09:27 +01:00
Philip Goto
431b79f52e Add Dutch translation 2023-08-30 12:08:52 +01:00
Simon Ser
f0e626a4b6 common: add support for Wayland security context
This exposes a reliable way for Wayland compositors to get
identifying information about a client. Compositors can then
apply security policies if desirable.

See: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/68
2023-08-24 12:17:53 +02:00
Simon Ser
b4822e2230 common: split Wayland socket setup to separate file
More complicated setup logic will be added next commit.
2023-08-24 12:17:53 +02:00
Simon Ser
522dd8b911 common: introduce flatpak_bwrap_add_sync_fd
The same logic will be used for Wayland security context.
2023-08-24 12:17:53 +02:00
Adrian Vovk
c6164ab269 meson: Properly install tmpfiles.d config 2023-08-16 11:50:37 +01:00
Simon McVittie
7a55b7c49f app: Use AS_FORMAT_STYLE_CATALOG if available
AS_FORMAT_STYLE_COLLECTION is a deprecated alias for ..._CATALOG, and
was removed entirely in appstream git main (presumably version 0.17
or 1.0).

Resolves: https://github.com/flatpak/flatpak/issues/5472
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-11 13:34:41 +01:00
Simon McVittie
556984e1c1 app: Provide a stub implementation of AS_CHECK_VERSION if needed
Our only code that is conditional on the libappstream version wants
version 0.14.0, which conveniently is exactly the version that
introduced AS_CHECK_VERSION.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-11 13:34:41 +01:00
Simon McVittie
ad17979018 tests: Move test coverage for app/ into a new executable
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:19:00 +02:00
Simon McVittie
ae2579637a app: Move terminal-related utility functions from common into app
These functions are to do with being an interactive, terminal-oriented
CLI/TUI, so it would be inappropriate for library code in libflatpak
to call them, and it would also be inappropriate for daemons like the
session and system helpers to call them.

In fact all calls to these were already isolated to app/, so we can
easily move the terminal-related utilities themselves into app/.

As well as shrinking libflatpak, this makes it obvious that the system
helper does not actually need to call flatpak_disable_fancy_output():
it does not link any code that would be affected by that API call.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:19:00 +02:00
Simon McVittie
36bc1bd382 common: Break circular dependency between context and dir/run
By giving the context a bit more knowledge of which directories Flatpak
uses for what, we can stop it from depending on the dir/run modules,
which themselves depend on FlatpakContext.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
a898065a66 common: Move metadata to its own header
This cuts more circular dependencies between flatpak-run and
flatpak-exports.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
846e109fb2 common: Explicitly include context's own header
Previously we were relying on flatpak-utils-private.h having a circular
dependency on this, but I'm intending to remove that during future
refactoring.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
bf8e91cedc common: Stop including utils-http in utils
utils-http is conceptually larger than utils.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
f6cf1b2bbb common: Remove unused functions
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
5522d19f4f common: Move flatpak_is_app_runtime_or_appstream_ref to ref-utils
This matches where it was declared.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
8032ca9d69 common: Move flatpak_abs_usrmerged_dirs to FlatpakExports
This will help to break circular dependencies between FlatpakExports
and flatpak-run.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Simon McVittie
f79f90e9c0 common: Move declaration of get_compat_arch_reverse back to -utils
The implementation never actually moved to -ref-utils.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-03 20:07:57 +02:00
Sebastian Wick
bbac52e6af dir: Document the apply_extra_data run flags
They are the same as `flatpak run --sandbox` with two exceptions:

  * `FLATPAK_RUN_FLAG_MULTIARCH` might be required so we just add it
    always
  * `FLATPAK_RUN_FLAG_NO_PROC` is added to prevent sandbox escapes via
    `/proc/self/exe`

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2023-07-03 19:47:00 +02:00
Dan Nicholson
c4738f8005 revokefs: Always bypass page cache for backend requests
By default, FUSE runs in cached I/O mode[1]. That means some I/O
responses will be taken from the page cache instead of being handled by
the FUSE process. For files opened for reading that's not a problem as
all the requests are just passed through.

However, that is problematic for files opened for writing since those
requests need to be handled by the backend. It's particularly bad for a
file opened `O_RDWR` since `read` responses from the page cache are
likely to be wrong. Instruct FUSE to use `direct-io` for those files so
that the page cache is bypassed.

1. https://docs.kernel.org/filesystems/fuse-io.html

Fixes: #5452
2023-06-28 13:26:27 +01:00
Piotr Drąg
4c6136ab21 Update POTFILES.in 2023-05-20 11:44:05 -05:00
Simon McVittie
dadd737381 common: Fix an uninitialized variable
This could be uninitialized if the app has --socket=fallback-x11 but
not --socket=wayland, although that's a combination that doesn't make
a great deal of sense. Regression introduced during recent refactoring.

Fixes: db7a8bb5 "common: Split up socket setup from flatpak-run into multiple files"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 15:15:31 -05:00
Simon McVittie
d9a3f34d44 common: Move json-glib backports to their own file
There is currently no source for this one, only a header.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
ecab882896 glib-backports: Use g_ascii_string_to_unsigned if GLib is new enough
Use the real GLib function if we can, and resync the backport with the
version in GLib 2.76.2: use a compatibility replacement for
G_NUMBER_PARSER_ERROR so that it can be textually identical to the
version in GLib, and revert Flatpak changes to the whitespace.

The only functional change is that if the function fails, we'll raise
G_NUMBER_PARSER_ERROR_INVALID if GLib is new enough.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
ba556fb98c glib-backports: Move flatpak_utils_ascii_string_to_unsigned to here
Currently this is used unconditionally, even if GLib is new enough.
That will be changed in a subsequent commit; no functional change
intended in this one.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
99878f6356 glib-backports: Resync g_get_language_names_with_category with GLib 2.76.2
- 0e7bf99e "Use "e" mode flag in fopen () calls for race-free setting of the close-on-exec flag"
- Add #ifndef G_OS_WIN32, which is irrelevant for Flatpak but keeps the
  code textually equivalent to GLib's

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
35e7e68200 glib-backports: Resync ISO8601 parsing with GLib 2.76.2
- 3384ed3f "Fixing signedness warnings in glib/gdatetime.c"
- faa1d63c "glib: Fix various compiler warnings when compiling with G_DISABLE_ASSERT"
- 4ddabfc6 "gdatetime: Avoid an assertion failure when parsing some ISO 8601 dates"
- b4eaac58 "gdatetime: Handle leap seconds in ISO8601 dates"
- f9d0135a "gdatetime: Port to use new g_time_zone_new_identifier() constructor"
  (partially reverted here)
- c3805d74 "gdatetime: Disallow NAN as a number of seconds in a GDateTime"
- 5d7f4b8f "gdatetime: Remove floating point from seconds parsing code"
- d5580edf "Fix non-initialized variable in glib/gdatetime.c"
2023-05-17 11:35:44 +01:00
Simon McVittie
9834f8991d glib-backports: Document which version we backported
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
717b7aec0c glib-backports: Add a note that a couple of functions aren't backports
We can't backport GLib's implementations of these, because they make use
of GHashTable/GPtrArray internals. Instead, we have a reimplementation
of the same API, which accepts the cost of some redundant work as a
reasonable price to pay for backwards-compatibility.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
b4038158f8 glib-backports: Make g_key_file_save_to_file match the GLib implementation
This just adds some assertions, no functional changes (assuming we're
calling it correctly).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
a0a3734f18 common: Move direct backports from GLib to a new translation unit
flatpak-utils.c is getting quite large, and is a mixture of code with
and without non-GLib dependencies, making it inconvenient to reuse in
other projects (like Steam's pressure-vessel) or link into Flatpak
services that don't need all of our dependencies (json-glib, appstream,
ostree). One obvious piece of low-hanging fruit for reducing the size
of this file is to move the GLib backports into their own
translation unit.

Sort them by GLib version, so that when we increase our GLib
dependency it's easy to delete the ones that are no longer applicable.

No functional changes intended in this commit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-17 11:35:44 +01:00
Simon McVittie
db7a8bb598 common: Split up socket setup from flatpak-run into multiple files
flatpak-run is large enough to be getting unwieldy, so separate it out
into various smaller modules.

A side benefit of these is that they'll be easier to reuse in other
projects, like Steam's pressure-vessel tool.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-15 19:54:51 +01:00
K.B.Dharun Krishna
1cbff35386 check.yml: bump Ubuntu runner for valgrind 2023-04-08 21:22:09 -05:00
K.B.Dharun Krishna
a98854b1a0 check.yml: bump actions/upload-artifacts to v3 2023-04-08 21:22:09 -05:00
K.B.Dharun Krishna
cb655ab336 check.yml: remove glib260 ppa
The required package is present in Ubuntu repos https://packages.ubuntu.com/focal/libglib2.0-dev
2023-04-08 21:22:09 -05:00
K.B.Dharun Krishna
dad39f61b5 block-autosquash-commits.yml: bump block-autosquash-commits-action version to 2.2.0 2023-04-08 21:22:09 -05:00