1744 Commits

Author SHA1 Message Date
Alexander Larsson
b03916f5bd setup-extra-data: Avoid extra work for ostree-metadata and appstream branches
We never have extra data for non app/ or runtime/ refs, so lets not
do an unnecessary pull there.
2020-02-13 14:47:00 +01:00
Alexander Larsson
9aecad7f4f p2p: Don't mirror ostree-metadata refs when pulling into the child repo
This breaks Deploy which can't find the ref. It used to work due to
the extra non-mirroring pull in flatpak_dir_setup_extra_data, but
this is not needed here.
2020-02-13 14:47:00 +01:00
Alexander Larsson
b371ef9007 Actually use from-scratch deltas
As noticed in https://github.com/flatpak/flatpak/issues/3412 we
regressed at some point and are no longer using from-scratch deltas.
This is caused by an optimization in ostree where it decides to not
use a from-scratch deltas if theres is *some* version of the ref
locally available.

This conflicts with some code in flatpak that pulls *only* the commit
object in order to look for extra data size information so that we can
get the progress reporting right. Unfortunately the existance of
just the object triggers the above causing us to *never* use from-scratch
deltas.

We fix this by throwing away the partial pull in an aborted ostree
transaction.
2020-02-13 14:47:00 +01:00
Patrick Griffis
1a735f2f1a run: Prevent accidentally running with sudo
It is a common user error to prepend many flatpak commands with sudo
and doing so with run is quite unsafe and can cause issues.

This check simply handles the `sudo flatpak run foo` case and does
not prevent running as root or even running in a shell created by
sudo.

See also #1357
2020-02-13 11:52:56 +01:00
Matthew Leeds
5d382f3211 dir: Avoid unnecessary _flatpak_dir_reload_config()
There's no point in reloading the config when it didn't change.
2020-02-12 16:41:06 +01:00
Matthew Leeds
5836de30e3 common: Properly reload config when it changes
In flatpak_dir_create_origin_remote() we reload the repo config after
adding an origin remote to it, but this only applies to the FlatpakDir
object used. In the case of flatpak_transaction_add_ref(), there is
another FlatpakDir object in the installation (priv->installation) which
needs to also be reloaded using flatpak_installation_drop_caches(). So
add a boolean out variable to flatpak_dir_create_origin_remote() and use
it to determine if it's necessary to call
flatpak_installation_drop_caches() (because if the origin remote already
exists we don't create another).

This commit also makes related changes at the other call sites of
create_origin_remote() (some indirectly via
flatpak_dir_ensure_bundle_remote()):
- in flatpak_dir_ensure_bundle_remote(), only set the out variable
  created_remote to TRUE if a new remote was actually created
- in flatpak_installation_install_bundle(), only drop the installation
  caches if a new remote was actually created
- in flatpak_transaction_resolve_bundles(), drop a redundant
  flatpak_dir_recreate_repo() call and only drop installation caches
  when necessary

Without these changes, this unit test failure occurs:
ERROR: testlibrary - Bail out!
flatpak:ERROR:tests/testlibrary.c:3311:test_transaction_install_local:
assertion failed (error == NULL): Remote "hello-origin" not found
(flatpak-error-quark, 7)
2020-02-12 16:41:06 +01:00
Matthew Leeds
04757e31d9 transaction: Fix a typo in a g_debug() 2020-02-12 16:41:06 +01:00
Matthew Leeds
3917ef8776 transaction: Fix use of uninitialized variable
This was reported by valgrind.
2020-02-12 16:41:06 +01:00
Patrick Griffis
b8d2271154 run: Fix TMPDIR env var not being passed through suid bwrap
Fixes #2641
Fixes flathub/org.electronjs.Electron2.BaseApp#4
2020-02-12 16:38:53 +01:00
Matthew Leeds
423a21271c Merge pull request #3374 from smcv/fix-home-host-confusion
exports: Fix a confusingly-named method
2020-02-07 16:47:44 -08:00
Umang Jain
fe8b3c4b33 nitpick: installation: Remove a blank line 2020-01-24 14:08:08 +05:30
Simon McVittie
1f9dc50e33 exports: Fix a confusingly-named method
It was called flatpak_exports_add_home_expose(), but it actually
exposed the entire host filesystem, to the extent possible.
Rename it to flatpak_exports_add_host_expose() to reflect that.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-01-23 18:33:57 +00:00
Alexander Larsson
b3bd501978 update-portal: Limit which filesystem access additions we allow
Don't allow adding access to things like ~/foo xdg-foo/bar or similar
things just because you used to have home access, because such files
may be outside the homedir (for instance, if they are symlinks or configured
via xdg-user-dirs).
2020-01-23 13:34:20 +01:00
Alexander Larsson
3c6c51f46b build-commit-from: Fix generation of download-size
In flatpak-builtins-build-commit-from.c we call flatpak_repo_collect_sizes()
without initializing the passed in download size to zero, which mean
we sum with sizes with some random value as the start.

This is fixed by having flatpak_repo_collect_sizes() always initialize
the counters to 0 at the start.

Fixes https://github.com/flatpak/flatpak/issues/3362
2020-01-23 09:04:29 +01:00
Alexander Larsson
39903eab40 Add --device=shm permission
This new permission exposes the host /dev, which is normally not visible
even with --device=all, as it is not really a device node but rather
a bunch of shared memory blocks available on the host.

This access is needed by jack, as explained at:
https://github.com/flatpak/flatpak/issues/1509

Long term I think a better solution for pro audio (like pipewire) is
a better solution, but for now we should at least allow jack apps to work.
2020-01-17 11:47:04 +01:00
Umang Jain
56787325ed dir: Return empty array instead of NULL while querying related-refs
Initialize the related-refs array with empty GPtrArray so that if
the remote has 'url= ' (for e.g., in case of flatpak bundle's remotes),
a empty array is returned instead of NULL.

(NULL mostly implies a operation has failed and error is set)

Also, this syncs the implementation of `if (*url == 0)` with
that of  flatak_dir_find_remote_related_for_metadata function.
2020-01-16 19:30:09 +05:30
Umang Jain
18626add02 dir: Return NULL instead of boolean when querying related refs
The related refs are returned as GPtrArray, hence return NULL
instead of FALSE on error paths.
2020-01-16 19:15:01 +05:30
Alexander Larsson
a98d655f4f Fix build on older glib
Don't use G_VARIANT_BUILDER_INIT() which is glib 2.50 only
2019-12-20 13:25:20 +01:00
Alexander Larsson
681ca88547 oci: Fix leak in index handling 2019-12-20 11:15:39 +01:00
Alexander Larsson
202b2508d5 filters: Fix some leaks 2019-12-20 11:15:39 +01:00
Alexander Larsson
aabcbfa586 flatpak_installation_list_unused_refs: Fix leak 2019-12-20 11:15:39 +01:00
Alexander Larsson
883f4bf177 oci: Fix leak 2019-12-19 17:42:32 +01:00
Alexander Larsson
0af22af913 transaction: Fix leak 2019-12-19 17:42:19 +01:00
Alexander Larsson
ca6c12d4dd authenticators: Fix leak 2019-12-19 17:42:04 +01:00
Alexander Larsson
7a8801da50 Fix leak in flatpak_repo_update() 2019-12-19 16:53:14 +01:00
Alexander Larsson
7c3e6f7214 appdata: Fix leak of id string. 2019-12-19 16:52:58 +01:00
Alexander Larsson
aabadfdc8e authenticator: Fix sandboxed authenticators
We rely on broadcast signals for authenticator replies rather than unicast
as these are not filtered by the sandbox (due to them being opt-in by the
receiver).

Actually this already worked fine in the flatpak side as the generated
code already subscribes to the signals, this just switches the internal
authenticators (test and oci) to using the new way to emit signals.
2019-12-19 10:33:21 +01:00
Alexander Larsson
1291663a5a transaction: Automatically install authenticator if needed
If the local config for the remote specifies an authenticator name
and that is should in installed, automatically add it to updates
in a transaction.

The local config can either be manually configured, or automatically
from a flatpakrepo file or the summary metadata.
2019-12-19 10:33:21 +01:00
Alexander Larsson
4bb2f0684a Support updating authenticator keys via remote config updates 2019-12-19 10:33:21 +01:00
Alexander Larsson
04162f3286 repo support for setting authenticator options
flatpak build-update-repo now lets you modify the
autenticator-name/install/options keys, and these are migrated to
the summary/metadata during update.
2019-12-19 10:33:21 +01:00
Alexander Larsson
798d90ef0c flatpakrepo files: Support Authenticator keys
This parses AuthenticatorName and AuthenticatorInstall
2019-12-19 10:33:21 +01:00
Alexander Larsson
af2ecb7335 transaction: Make metadata updates more efficient
When we call flatpak_dir_update_remote_configuration we pass it
the pre-existing FlatpakRemoteState (if known) and also take into
account if it actually changed anything before blowing away the
cached remote state.

We also ensure we have metadata in
flatpak_dir_update_remote_configuration_for_state to ensure the passed
in optional state has metadata in it.
2019-12-19 10:33:21 +01:00
Umang Jain
142a7fd855 dir: Immediately return if getting remote state is cancelled
Immediately return the error instead of saving the error and
continuing on an optional codepath if _flatpak_dir_get_remote_state
is cancelled.
2019-12-18 10:36:05 +01:00
Alexander Larsson
4c3e59cd12 utils: Fix chaining of progress
With the latest ostree that enables the chaining of progress the
testsuite broke because we were not getting changed events. Looking
into this the reason seems to be that when we run the
ostree_async_progress_finish() on the chained progress it is marked
as dead, which causes ostree_async_progress_copy_state() to not copy
any data when called from handle_chained_progress().

The fix is to copy the content manually before calling the finish().

Also, the entire callback chaining system seems wildly
overcomplicated, so I simplified it by relying on the existing change
notification of OstreeAsyncProgress.
2019-12-18 09:46:39 +01:00
Alexander Larsson
a9888574ec authenticator: Empty authenticator name means none 2019-12-17 15:25:42 +01:00
Alexander Larsson
4106fc4677 authenticators: For no-interaction dirs, send no-interaction flag
For apps that run in the backgroun without interaction, pass this info
to the authenticator.

This can be used to avoid sending unnecessary webflow or basic auth
request, but those were already silenced by FlatpakTransaction. However
this also allows the authenticator to avoid doing direct, native user
interaction which was otherwise not avoidable.
2019-12-17 14:59:43 +01:00
Simon McVittie
10ee004d77 dir: Don't leak result of flatpak_get_current_locale_langs()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-12-17 14:59:24 +01:00
Alexander Larsson
0b732ba111 dir: Fix leak in flatpak_remote_state_lookup_cache()
For some reason we're assigning refdata the same thing twice, leaking
the first copy.
2019-12-17 14:55:13 +01:00
Alexander Larsson
24558eec47 dir: Fix leak in flatpak_dir_p2p_state_free
We forgot to free the results_refs member
2019-12-17 14:55:13 +01:00
Alexander Larsson
f983ed616b dir: Actually free the main memory chunk in flatpak_dir_p2p_state_free 2019-12-17 14:55:13 +01:00
Alexander Larsson
d7474daaf2 dir: Fix leak
When recreating self->repo, also clear self->cache_dir, otherwise it was
leaking when we replaced it.
2019-12-17 14:55:13 +01:00
Alexander Larsson
510fbce093 Remove extraneous ostree_async_progress_finish()
These should only be called at the leaf level, because the first
time its called no more change events will ever be sent on that
progress, which is not right possibly in the middle of an operation.
2019-12-17 14:55:13 +01:00
Alexander Larsson
c322cbdbb6 Add and use OstreeAsyncProgressFinish helper
This is a g_autoptr version of OstreeAsyncProgress that also
calls ostree_async_progress_finish() before being freed.

This should be used in all "leaf" functions that creates an asyncprogress
to avoid leaking any idle change idle sources. Using a auto* means
some code can be cleaned up to avoid goto out style handling for this.

Also, this adds a missing finish() in
_flatpak_dir_fetch_remote_state_metadata_branch().
2019-12-17 14:55:13 +01:00
Alexander Larsson
b3ab31e18a FlatpakAsyncProgressChained: Don't leak chained progress
If we're using a chained progress, it will be unchained
in the destroy notifier. However, it was newly constructed so we
need to also unref it or we'll leak it.

This also makes some minor cleanups:

1) Centralize version checks to one place and replace users
   with #ifdef FLATPAK_DO_CHAIN_PROGRESS which makes it
   easier to read and to test the fallback.

2) Make flatpak_progress_chain return a FlatpakAsyncProgressChained
   to make it clear the two needs to be paired.
2019-12-17 14:55:13 +01:00
Alexander Larsson
dd6df7589e utils: Don't leak GMainContextPopDefault contextes
We're creating a new one, making it the default, and on destroy
we pop it, but since we're not also destroying it we're leaking the
entire context!
2019-12-17 14:55:13 +01:00
Alexander Larsson
93a7718678 test: Fix leak of OstreeRepo cachedir fd
It turns out ostree_repo_open() overwrites custom cachedir_fd we've
set for the system using installation in case the object dir is
writable. Normally this is not a problem, because it is not writable,
but in the testsuite is *is*, which means the initial cachedir fd is
leaked, as well as using the wrong dir for summary caches during the
tests.

We work around this by setting the cache_dir after a successful
ostree_repo_open().

This fixes #3303
2019-12-17 14:55:13 +01:00
Alexander Larsson
7fedf3578f OCI: Only use labels, never annotations
This is a slightly incompatible change, as we now only support
oci images generated with (what was before) build-export --oci-use-labels.
However, there are not a lot of OCI implementations in the wild, and
we can modify the ones in use to ensure there are labels (and
annotations if needed for older flatpak clients).

This also removes the --oci-use-label option from build-bundle --oci as
this is now the default.
2019-12-16 09:23:49 +01:00
Thiago Jung Bauermann
c3bd7bc855 Fix typo in /etc/timezone filename
flatpak_get_timezone () tries to access /etc/timezone if /etc/localtime
isn't a valid symlink, but gets the name wrong. Fix it.

Found by code inspection.
2019-12-16 09:07:23 +01:00
Matthew Leeds
f4337b9a4e Merge pull request #3298 from alexlarsson/authenticator-collection-id
Pass collection-id (if any) to authenticator when requesting tokens
2019-12-13 14:16:09 -08:00
Jan Grulich
a61f61870e Add support for CUPS socket 2019-12-13 17:56:22 +01:00