Commit Graph

6505 Commits

Author SHA1 Message Date
Alexander Larsson
540bcda3bd Transaction: Ensure we download the subsummary for the arch of added refs
By default we only download the main arch subsummary, so if you added
a ref for some other arch it failed to find the ref. This works with the
CLI, because it explicilty loads the subsummary when its trying to expand
the parial ref to the full ref. However apps using libflatpak don't do that
so they failed.
2021-05-19 09:49:30 +02:00
Alexander Larsson
ce9a1c4f6c Add FLATPAK_QUERY_FLAGS_ALL_ARCHES for list_remote_refs()
This allows flatpak_installation_list_remote_refs_sync_full() to list
refs for all arches on remotes that use the new subsummary format.

Fixes #4252
2021-05-19 09:49:25 +02:00
Simon McVittie
4c7d74ac57 doc: Add a release checklist for maintainers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-05-17 10:02:51 +02:00
Philip Withnall
d5daaa537d tests: Fix test-summaries.sh when running tests as root
If the tests are run as root, the system helper is not used even when
commands are run with `--system`. This means a different cache path is
used (see `_flatpak_dir_ensure_repo()`). The tests did not accommodate
for that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-17 10:00:33 +02:00
Philip Withnall
087dfe6630 Merge pull request #4269 from pwithnall/strcmp-crash
dir: Avoid a crash when looking up summary for a ref without an arch
2021-05-11 23:18:45 +01:00
Philip Withnall
a65e97c380 dir: Avoid a crash when looking up summary for a ref without an arch
If looking up the summary for a ref without an arch (for example,
`ostree-metadata`, which the Endless OS version of flatpak uses in some
backwards-compatibility code), avoid passing `NULL` to `strcmp()` and
hence crashing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-11 15:12:15 +01:00
Phaedrus Leeds
404d7c6941 Fix several memory leaks 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
4562627b04 utils: Add missing check for empty string collection id 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
66d00e1c47 list: Add a g_assert() for a coverity warning 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
a0188dee79 dir: Fix a GString leak 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
284510eabb remote-info: Fix memory leak of branch 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
75e60c5d8e remote-info: Fix printing of branch 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
756b9eae14 common: Fix several memory leaks 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
d191c2eb58 context: Fix leak of env var key/value pair 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
1120c7cb24 Fix memory errors w/ use of var_arrayofstring_to_strv() 2021-05-04 10:23:13 +02:00
Phaedrus Leeds
879c9b9008 utils: Fix use-after-free and logic error
Without this change, validate_component() might free the "component"
variable, but then go on to keep using it. This change also makes the
code work as intended, to only have a flatpak-specific "bundle" in the
appstream xml (where here bundle does not mean "flatpak single-file
bundle").
2021-05-04 10:23:13 +02:00
Phaedrus Leeds
bc27dcb518 remote-list: Check for unlikely libostree error 2021-05-04 10:23:13 +02:00
Simon McVittie
bcdc073041 Update translation files for v1.11.1 release
Signed-off-by: Simon McVittie <smcv@collabora.com>
1.11.1
2021-04-26 12:47:36 +01:00
Simon McVittie
d7cf0736e0 Release v1.11.1
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-26 12:47:17 +01:00
Simon McVittie
f9e5ab264d NEWS: Summarize changes since 1.10.2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-26 12:42:03 +01:00
Simon McVittie
9a35bbc91c Merge tag '1.10.2', omitting changes in po/
Release 1.10.2

Git-EVTag-v0-SHA512: 849c1f828b993144d61353fc8f233d5f62ef773d4ded35e406797260b55a371cd7dc77cba1a4de912e05e9530f40adf9963789ac896ed3fe19ebce352031b85b
2021-04-26 12:21:28 +01:00
Alexander Larsson
283a3b93a5 tests: Add test for the flatpak prune implementation 2021-04-26 10:30:14 +02:00
Alexander Larsson
0cd4656ea1 Add (and use) custom, high-perfomance prune implementation
This is an optimized version of ostree_repo_prune() specialized for
archive mode repos. It is faster and uses less memory so that we can
prune larger repos (like flathub) in a realistic timeframe.

The primary reason it is faster is that it creates and uses a
`.commitmeta2` file for each commit, containing information about what
objects are reachable from that commit. This means incremental prunes
need only traverse over newly created commits.

Secondly, it uses the variant parser compiled accessors for the
various GVariants that are involved in the prune which is quite a bit
faster, especially if the repo is very large.

It also merges the scan-for-all-objects and prune-unreachable objects
phases, which means that we don't have to allocate a hashtable for
all the objects in the entire repo saving a lot of memory.

To save memory the hashtable of reachable objects, which can be quite
big on a big repo, points to a custom, very compact format for object
names.

Additionally it does the scanning for reachable objects twice, first
with a shared lock and then again (if anything changed) it with an
exclusive lock. This allows us to avoid using an exclusive lock during
the slowest part of the prune.

Unfortunately there are currently no public APIs for the ostree repo
locks. We really need to take an exclusive lock during the whole prune
or we parallel modifications (say a commit) might get their newly
written objects deleted. To work around this we have a minimal custom
implementation of an exclusive lock. Once the public API is available
we can start using that.

I created a repo with a lot of small commits to test this.  It has 9M,
and pruning with depth=10 deletes 2M of them.

The original performance looks like:

 Finding reachable objects: 287 seconds
 Pruning unreachable: 69 seconds

Just using the pregenerated reachable data:

 Finding reachable objects: 15 seconds
 Pruning unreachable: 69 seconds

The final optimized prune (using pregenerated data):

 Finding reachable objects: 12 seconds
 Pruning unreachable: 51 seconds

The above are with the page caches cleaned, on a second run the performance
increase is even more noticeable.

As a comparison to the above, finding the reachable objects in the
actual flathub repo took 22 hours, but with the pregenerated reachable data
only 39 minutes.
2021-04-26 10:30:14 +02:00
Alexander Larsson
07e1fd096d Compiled variants: Add some ostree types
This adds the ostree object name and the object info (returned from
ostree_repo_list_objects) to the set of variants we compile accessors
for.
2021-04-26 10:30:14 +02:00
Phaedrus Leeds
4485364825 README: Add related projects 2021-04-22 09:57:42 +02:00
Simon McVittie
686af7d3b8 test-instance: Add more assertions
scan-build points out that bytes isn't read after it is assigned. While
this is not actually true (scan-build doesn't understand
__attribute__((__cleanup__)), which frees bytes), it's true that we
should ideally have an assertion here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
12d7855493 enter: Make it clearer that rest_argv_start always gets initialized
scan-build complained that rest_argv_start could be used uninitialized,
because it can't see that rest_argc >= 2 implies that rest_argv_start
got initialized at the same time rest_argc was set. Make this easier
to understand.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
bd5c2762cf testcommon: Assert that parse_datetime succeeds
scan-build detected that ret was written but never read.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
3a85ceecfc testlibrary: Fix an assertion
scan-build detected that res was written but never read. Presumably
the use of ref here (carried over from the previous test) is a
copy/paste error.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
2a01318e15 ref-utils: Remove dead store
We always set match_len before using it, discarding the result of this
assignment. Detected by scan-build.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
3071d2ada9 quiet-transaction: Remove unnecessary finalize
This hasn't done anything useful since 0978826c: it just takes a
new ref to the installation, and then releases that ref without doing
anything with it. Detected by scan-build.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
c26a48a9aa Fix various unused variables detected by scan-build
scan-build has a lot of false positives for this codebase because it
doesn't understand __attribute__((__cleanup__)) or GLib's GError
convention, but it seems to have been right about these.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Yuri Chornoivan
54e783b8cd Update Ukrainian translation 2021-04-19 09:07:32 +02:00
Hubert Figuière
9e7c5fa545 flatpak_dir_find_local_related_for_metadata: Skip invalid branch
Fixes #4234
2021-04-19 09:07:10 +02:00
Piotr Drąg
f552d9a397 Update POTFILES.in 2021-04-16 18:09:51 +01:00
Simon McVittie
c2490aad12 app: Use autocleanup for FlatpakTablePrinter
Fixes: https://github.com/flatpak/flatpak/issues/4223
Fixes: https://github.com/flatpak/flatpak/issues/4224
2021-04-16 14:51:47 +02:00
Simon McVittie
282647c81f transaction: Avoid a possible use-after-free
scan-build detected that mark_op_resolved() can be called with
op->resolved_commit == commit, in which case we incorrectly freed the
string before allocating the new copy.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 14:51:12 +02:00
Simon McVittie
a0eaaf77ad revokefs: Use the right variable name in an error message
scan-build detected that response_size is uninitialized here, presumably
a typo for response_data_size.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 14:50:27 +02:00
Simon McVittie
1b930e955e oci-registry: Fix error reporting
The intention here seems to have been that failing to close the http
stream provokes a warning but does not make the function fail, but we
were setting the wrong error, resulting in a NULL dereference if closing
the http stream somehow fails.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 14:49:15 +02:00
Simon McVittie
4c676e4e3a portal: Reject negative handle numbers
In D-Bus, handles are defined to be unsigned, but in GVariant, for some
reason they're signed. Make sure they aren't negative, which could
result in a NULL dereference for fds.

A handle used in the conventional way will never legitimately be
negative (in GVariant's interpretation) or have its high bit set
(in D-Bus' interpretation), because file descriptors are signed 32-bit
integers, so an array of distinct file descriptors can never be long
enough for the distinction between signed and unsigned to matter.
In practice fds are limited by the kernel to several orders of
magnitude fewer than that anyway.

Fixes: 3ebf371f "run: Allow caller to replace /app and/or /usr"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 14:47:43 +02:00
Simon McVittie
38eac07293 run: Create a shared XDG_RUNTIME_DIR for each app-ID
Like $XDG_RUNTIME_DIR/app/$FLATPAK_ID, this is shared between all
instances of the app, except for subsandboxed instances created by
flatpak-spawn --sandbox or equivalent. Unlike
$XDG_RUNTIME_DIR/app/$FLATPAK_ID, it does not exist at an equivalent
path on the host and in the sandboxed app.

Resolves: https://github.com/flatpak/flatpak/issues/4120
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
40510e8ae8 run: Populate XDG_RUNTIME_DIR with symlinks into /run/flatpak
If XDG_RUNTIME_DIR is under app control, as it will be with #4120, we
don't want to be mounting pieces of filesystem directly into it, because
that will mean that the app could create a symlink that will cause us
to create a mount point for it at the target of the symlink, potentially
elsewhere in the host filesystem.

Instead, we mount them in /run/flatpak, which is a per-instance
directory entirely controlled by Flatpak; and then create (relative)
symlinks in XDG_RUNTIME_DIR, pointing into /run/flatpak.

In this commit, we still know that the XDG_RUNTIME_DIR is a
per-instance tmpfs, so we can safely create the symlinks using
the --symlink option. In a subsequent commit this will change to
creating them in a shared XDG_RUNTIME_DIR, if any.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
e5aa260919 run: Normalize WAYLAND_DISPLAY to a reasonable name
If it doesn't start with wayland- or contains a directory separator,
then it's probably not something we want to be creating in the
sandbox's XDG_RUNTIME_DIR.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
d487db5e6a run: Put the AT-SPI bus socket in /run/flatpak
There's no real reason why this has to be in the XDG_RUNTIME_DIR: it's
located via environment variable AT_SPI_BUS_ADDRESS.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
0e0e98e7ef run: Create ssh-auth socket in /run/flatpak
There's no real reason why this has to be in the XDG_RUNTIME_DIR:
nothing looks for it via XDG_RUNTIME_DIR, it's located via environment
variable SSH_AUTH_SOCK.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
c96d73c32f run: Create Xauthority in /run/flatpak
There's no real reason why this needs to be in XDG_RUNTIME_DIR: nothing
relies on it being there, and applications find it via environment
variable XAUTHORITY.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
3ec0e7b483 run: Use a constant path for the reference to per-app directories
It's a bit simpler to get a per-app XDG_RUNTIME_DIR safely if we avoid
putting this in there. Nothing relies on it being in the
XDG_RUNTIME_DIR.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
a89aa1442a run: Delay allocation of per-app directory
If we call this after flatpak_run_add_app_info_args(), then the
garbage-collection code will have a chance to run, cleaning up after a
previous instance of the same app.

In a previous implementation of #4093 that also implemented #4120, we
had to allocate the per-app directory this early to avoid shadowing the
XDG_RUNTIME_DIR allocated in flatpak_run_add_app_info_args(), but I'm
taking a different approach to that now.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 09:13:18 +02:00
Simon McVittie
cb47d83b72 run: Add option to share /dev/shm between instances of an app-ID
Similar to /tmp, applications might well use /dev/shm as an IPC
rendezvous between instances, which wouldn't have worked without
--device=shm until now.

Because /dev/shm has specific characteristics (in particular it's
meant to always be a tmpfs), we offload the actual storage into a
subdirectory of the real /dev/shm. Because /dev/shm is a shared
directory between all uids, we have to be extra-careful how we
do this, which is why the test coverage here is important.

This is done on an opt-in basis because of its extra complexity.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-16 08:57:20 +02:00
Simon McVittie
70a3e44fb5 portal: Define constants for the D-Bus names and path
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-15 18:05:16 +02:00