Commit Graph

1557 Commits

Author SHA1 Message Date
Chris Williams
cf76cb61ba ps: Add gnome to background portal backend list
This is used for the active and background columns.
2024-03-20 19:42:33 +00:00
Simon McVittie
8e63eda867 Remove Autotools build system
As discussed in #5695, I think we're reaching a point where removing
Autotools is preferable to fixing it.

1.14.x continues to use Autotools, so platforms whose Meson version is
too old can stay on that branch until it becomes unsupported. We have
a very conservative Meson dependency (Ubuntu 20.04).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 19:30:32 +00:00
Simon McVittie
2a363d7569 build: Consistently put libglnx.la last in lists of dependencies
It needs to be able to satisfy dependencies of higher-level Flatpak
static libraries.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 16:06:41 +00:00
Simon McVittie
2350ef1111 main: Return from flatpak_run() instead of calling exit()
This allows g_autoptr destructors to run, avoiding memory leaks being
reported by AddressSanitizer; they would be harmless, since we're about
to exit anyway, but AddressSanitizer can't tell the difference between
an O(n) problem and an O(1) harmless "leak".

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 11:06:30 +00:00
Simon McVittie
07ad6af5ac main: Use g_autoptr for the GOptionContext
No functional change, but it will make it easier to avoid leaking it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 11:06:30 +00:00
Hubert Figuière
6e3cc82af3 Fix memory leaks
Build with address sanitizer and run the tests

Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-02-13 08:20:57 -06:00
Chris Williams
4cb1ca834c info: display extensions found in other installations
Flatpak looks for extensions in all installations, but `flatpak info -e`
would display an error when an extension isn't present in the same
installation as the ref.

Also display the installation name for each extension.
2024-02-06 18:14:42 -06:00
Patrick Griffis
8c26798991 update: Make autopruned refs automatically removed
In order to maintain a system over time update automatically removes any EOL runtimes that are unused.

This extends it to also remove any autopruned refs. In practice this means removing no longer used driver versions as the system is updated.

Closes #5261
2024-01-07 18:51:46 -06:00
Dor Askayo
c262e5ff0b run: Save flatpak-run environment
Save the environment in which flatpak-run was executed in the private
instance directory.

The environment is saved in "env -0" format.
2023-10-27 17:09:52 +01:00
Dor Askayo
c5a4ec0fa9 instance: Create private instance directory
Unlike the instance directory, whose directory structure is
considered public API and is mounted in the sandbox, the private
instance directory is meant to hold private data or metadata about
an instance for use by internal components.

The private instance directory is not meant to be shared with any
external component, and provides no guarantees about its structure
or contents.

While the public instance directory is named "<instance-id>", the
private instance directory is named "<instance-id>-private". Both the
public and private instance directories share the same parent
directory.

The private instance directory relies on the same lock file as the
public instance directory, and both are garbage-collected together.
2023-10-27 17:09:52 +01:00
Matthias Klumpp
c0c466f269 Adjust to AppStream 1.0 API changes 2023-10-24 14:17:48 +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
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 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
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
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
Philip Withnall
9a2d0413f5 app: Port transaction subclasses to use add_rebase_and_uninstall()
This fixes the possible situation where an eol-rebase app can be
uninstalled and the new version not correctly installed (due to, for
example, the install op failing due to a lack of disk space).

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

Fixes: #3991
2023-03-30 14:54:18 +02:00
Simon McVittie
0e3e646839 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>
2023-03-20 12:19:15 +00:00
Simon McVittie
409e34187d 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:54:14 +00:00
Ryan Gonzalez
6cac99dafe 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:54:14 +00:00
Simon McVittie
628750d2de 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>
2023-02-08 21:14:17 +00:00
Simon McVittie
5e2e771ece 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>
2023-02-08 21:14:17 +00:00
Patrick Griffis
bb730ef8b8 Revert "Add support for files generated by appstreamcli compose (#5277)"
This reverts commit 88f7ecd000.
2023-02-04 12:30:15 -06:00
Luna
88f7ecd000 Add support for files generated by appstreamcli compose (#5277)
Co-authored-by: Bartłomiej Piotrowski <b@bpiotrowski.pl>
Co-authored-by: Jamie Murphy <hello@itsjamie.dev>
2023-02-04 10:40:07 -06:00
Phaedrus Leeds
523cedc275 trivial: Trim some long lines, etc. 2023-01-02 20:45:19 -06:00
Phaedrus Leeds
8ca1604a94 repair: Fix off-by-one error in fancy output
Fixes https://github.com/flatpak/flatpak/issues/5204
2023-01-02 20:45:19 -06:00
Simon McVittie
c2c034733e common: Make flatpak_debug2() use the same domain as g_debug()
Now that we are logging `flatpak -v` messages with log level INFO,
and printing INFO messages in the same way as DEBUG, we can reserve
log level DEBUG for `flatpak -v -v` messages. This means we no longer
need a weird secondary debug domain.

There is a very small behaviour change here: G_MESSAGES_DEBUG=flatpak
is now similar to `flatpak -v -v` (previously `flatpak -v`), and
G_MESSAGES_DEBUG=flatpak2 no longer has any effect. This seems more in
line with what would be expected from a GLib-based application.

In flatpak(1) and the system helper, this does not change behaviour
other than that: the same messages are logged by `-v` and by `-v -v`
as before.

In daemons that do not implement `-v -v` (the OCI authenticator, portal
and session helper), it continues to be necessary to use
G_MESSAGES_DEBUG to see flatpak_debug2() messages.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00:00
Simon McVittie
522a933bc9 app: Use g_info() for messages that will be shown by flatpak -v
This brings us one step closer to being able to stop using the flatpak2
log domain for messages that are exclusive to `flatpak -v -v`.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00:00
Simon McVittie
ac4e322629 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>
2022-12-14 20:02:35 +00:00
Simon McVittie
1eed25617c Replace calls to g_memdup() with g_memdup2()
g_memdup() is subject to an integer overflow on 64-bit machines if the
object being copied is larger than UINT_MAX bytes. I suspect none of
these objects can actually be that large in practice, but it's easier
to replace all the calls than it is to assess whether we need to
replace them.

A backport in libglnx is used on systems where GLib is older than 2.68.x.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-12 19:15:52 +00:00
Jan Alexander Steffens (heftig)
d83b262ded app/meson.build: Add missing dep
Since we include the base private headers, we need the common base
sources to be generated.
2022-11-03 15:27:58 -05:00
Simon McVittie
9eb824f863 Add a Meson build system
Resolves: https://github.com/flatpak/flatpak/issues/2241
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-24 16:12:14 +01:00
Robert Ancell
b204ed2466 app: Fix warning when listing a document with no permissions.
(flatpak documents:2965757): GLib-CRITICAL **: 11:27:35.128: g_variant_iter_next_value: must not be called again after NULL has already been returned.

This is due to the applications iterator being checked twice even though it is empty.
2022-09-06 13:18:09 +02:00
Phaedrus Leeds
600e18567c Add a vim modeline and .editorconfig
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.

The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
2022-08-22 19:48:10 -07:00
Phaedrus Leeds
ff8490a91e app: Add -u alias for --user
Save folks a few keystrokes. There is a command which already has a '-u'
option, document-export, but it doesn't support --user so there should
be no conflict. However '-s' is used by the info command among others,
so we can't use that for --system.
2022-08-16 10:50:29 +02:00
Simon McVittie
a03111a3d1 enter: Don't overwrite the DISPLAY
Now that we're using the same display number in the sandbox as on the
host, we can forget about overwriting it with :99.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-08-16 10:45:08 +02:00
Phaedrus Leeds
60005cfcc2 build-export: Don't warn on missing Exec= if DBusActivatable=true
The Desktop Entry spec says that Exec= is only required if
DBusActivatable= is not set to true, so don't emit a warning when Exec=
is missing but not required.
2022-08-16 10:42:06 +02:00
Danilo Bargen
298286be2d build-export: Explicitly allow empty Exec values in desktop file 2022-08-16 10:42:06 +02:00
Danilo Bargen
6dbc097ac5 build-export: Avoid segfault if Exec line is missing from desktop file 2022-08-16 10:42:06 +02:00
Phaedrus Leeds
6db7806762 build-export: Fully ignore stdout content of icon validation
The docs for g_spawn_sync() say:
"Note that you must set the G_SPAWN_STDOUT_TO_DEV_NULL and
G_SPAWN_STDERR_TO_DEV_NULL flags when passing NULL for standard_output
and standard_error."

So add in the stdout flag when calling flatpak-validate-icon in the
build-export command. Without this, there's output in the test logs
from when they're building the test app, due to
https://github.com/flatpak/flatpak/pull/4803
2022-07-25 16:58:16 -04:00
Phaedrus Leeds
cf8979b1b0 app: Un-split translatable strings again
As with the previous commits, try not to split translatable sentences.
See the discussion here about whether the "Warning: "/"Error: " prefix
should be separable:
https://github.com/flatpak/flatpak/pull/4963#discussion_r908326539

Also, don't translate the "(internal error..." message since internal
errors shouldn't be translated to make debugging easier.
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
0465c464af app: Remove a duplicated else if block 2022-07-23 14:18:50 -05:00
Phaedrus Leeds
da5a38c17c app: Un-split some translatable strings
Also make them a bit prettier while we're here

Fixes https://github.com/flatpak/flatpak/issues/4877
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
bf2a0cc2ec app: Un-split EOL translatable sentences
Fixes https://github.com/flatpak/flatpak/issues/4956
2022-07-23 14:18:50 -05:00
Phaedrus Leeds
e1e6465f26 uninstall: Prompt for confirmation on used runtime removal
It doesn't make a lot of sense to prompt for confirmation when an in-use
extension is requested to be uninstalled, but not do so for an in-use
runtime, even if (or perhaps especially since) the latter causes the
transaction to fail later on.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
bf99c266a8 app: Tweak messages about dependent apps
Use a "Info: " prefix which matches the message printed in
print_eol_info_message(). Also make the message accurately use either
the word "runtime" or "extension" as appropriate.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
65a4bb0a3d uninstall: Ask for confirmation for used runtime extensions
Based on discussions on the issue tracker, it seems that users sometimes
remove runtime extensions without really understanding whether they're
in use. Add a confirmation prompt to address this.

Helps: #4549
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
ae0de69b17 app: Improve checking for dependent apps in EOL messages
flatpak_dir_list_app_refs_with_runtime_extension() only works when the
runtime extension it is passed and the apps it returns are both
installed. Sometimes a end-of-life message is printed for a runtime that
is not installed but is being installed by the current transaction, or a
runtime that is installed but one of the apps that needs it is being
installed by the current transaction. To cover these cases, check the
operations in the current transaction when building informational
messages about EOL runtimes.
2022-07-21 14:32:45 -05:00
Phaedrus Leeds
e739773056 app: List apps that use a runtime extension when it's EOL
Currently if a runtime extension, e.g.
org.freedesktop.Platform.html5-codecs//18.08 is used by a runtime
org.kde.Platform//5.12 which itself is used by one or more apps, when we
print a message to the user about html5-codecs being EOL, we don't find
any apps using it and don't print any. Fix this by including apps that
indirectly use a runtime extension in the "Applications using this
runtime:" list.

In a later commit we can re-use the helper function added here to add a
confirmation dialog if the user tries to remove a runtime extension
that's being used; currently we just let them remove it.

This is limited to only looking in the current flatpak installation, so
a per-user app using a system-wide runtime extension would not be found.

This is implemented using in-memory caches because otherwise it is
horribly slow; see
https://github.com/flatpak/flatpak/pull/4835#discussion_r876425289

Helps: #3531
2022-07-21 14:32:45 -05:00