Commit Graph

5523 Commits

Author SHA1 Message Date
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
Alexander Larsson
69fae3b380 Work around github repo issue
See:
https://github.community/t5/GitHub-Actions/ubuntu-latest-Apt-repository-list-issues/m-p/41163/highlight/true#M4513
2019-12-13 16:28:37 +01:00
AsciiWolf
b6f9c8c235 Update Czech translation 2019-12-13 15:41:37 +01:00
Alexander Larsson
88c4c403bb Work around github repo issue
See:
https://github.community/t5/GitHub-Actions/ubuntu-latest-Apt-repository-list-issues/m-p/41163/highlight/true#M4513
2019-12-13 15:25:16 +01:00
Alexander Larsson
260c6f713d tests: Test passing of arguments to authenticator 2019-12-13 15:08:29 +01:00
Alexander Larsson
9f1582b09b Authenticator: Pass collection-id with the request 2019-12-13 15:07:58 +01:00
Alexander Larsson
9cc1b41d9d Update pofiles for release 1.5.2 2019-12-13 11:05:31 +01:00
Alexander Larsson
ba6daa08c9 Update NEWS for 1.5.2 2019-12-13 10:24:58 +01:00
Alexander Larsson
b9a3f06c4a Bump version to 1.5.2 2019-12-13 10:24:49 +01:00
Matthias Clasen
f5b6365f40 Merge pull request #3295 from matthiasclasen/permission-set-wrap
doc: Add an example for permission-set
2019-12-12 14:31:17 -05:00
Matthias Clasen
1957d4473e doc: Add an example for permission-set
This shows how --data formatting works on the commandline.
2019-12-12 12:45:53 -05:00
Alexander Larsson
9a4f5084ad run: (re-)allow forwarding fds into flatpak run
It turns out d91660fe2a accidentally
broke the inheritance of non-stdin/out file descriptor into children
of "flatpak run" which broke the fd passing in the flatpak spawn portal.

This reverts that, allowing all fds not specifically marked as CLOEXEC
by other means to be inherited into the child.

Fortunately the regression was not in any stable release.
2019-12-12 17:02:02 +01:00
Alexander Larsson
3666eb0950 portal: Make sure we inherit the passed thought fds in Spawn()
In the start of child_setup_func we set CLOEXEC on everything > 3, so
we need to undo this for the things we actually want to pass in.
2019-12-12 17:02:02 +01:00
Alexander Larsson
e08cee0e82 authenticator: Use g_app_info_launch_default_for_uri() to launch browser
This way we get the system default. We still respect BROWSER if set
which is useful for e.g. the tests or scripts.
2019-12-12 14:27:59 +01:00
Alexander Larsson
4902acbebf authenticator: Change how authenticator options are stored
We used to store all options as a gvariant format string like so:

 xa.authenticator-options={"key1": <"a string value">, "key2": <"foo">}

But nobody really knows how to write these things, so now we
have instead multiple options with a common prefix that
get collected like so:

 xa.authenticator-options.key1="a string value"
 xa.authenticator-options.key2="foo"

This means all options are strings, but most options are, and
if not you can just parse them.
2019-12-12 14:27:59 +01:00
Alexander Larsson
bdf734edb2 utils: flatpak_dir_list_remote_config_keys() helper
Lists all the config key for a specified remote (if any)
2019-12-12 14:27:59 +01:00
Alexander Larsson
c6aa7f56a1 password prompt: Emit newline (as we stole it during input) 2019-12-12 14:27:59 +01:00
Alexander Larsson
474b0573e3 authentication: Remove accidental leftover debug spew 2019-12-12 14:27:59 +01:00
Alexander Larsson
38c86bdf0f Authenticator: Add extra a{sv} args for future use
These are not used atm, but make the APIs future proof.
2019-12-12 14:27:59 +01:00
Alexander Larsson
134e01f606 OCI: Extract token-type and eol metadata into generated summary 2019-12-12 12:16:53 +01:00
Alexander Larsson
05067a42a4 Authenticator: Update docs for changes 2019-12-12 12:16:53 +01:00
Alexander Larsson
328b793c5a oci authenticator: Lookup up auth tokens in predefined files
We look in these, in this order:
 ~/.config/flatpak/oci-auth.json
 /etc/flatpak/oci-auth.json
 /run/user/$uid/containers/auth.json
 /run/containers/$uid/auth.json
 ~/.docker/config.json

The first two are flatpak specific, and the others are what
skopeo and docker use.
2019-12-12 12:16:53 +01:00
Alexander Larsson
39ee9bc594 oci authenticator: Pass registry url as realm 2019-12-12 12:16:53 +01:00
Alexander Larsson
c56e1c4646 oci-authenticator: Use basic authentication to log in if no other auth 2019-12-12 12:16:53 +01:00
Alexander Larsson
8818f08fd1 oci-authenticator: Add helpers for sending responses 2019-12-12 12:16:53 +01:00
Alexander Larsson
5b58f7f7c2 Auth: Add flatpak_auth_request_emit_basic_auth() helper 2019-12-12 12:16:53 +01:00
Alexander Larsson
1ec4232fd5 CLI: Handle basic auth in transactions 2019-12-12 12:16:53 +01:00
Alexander Larsson
6e6c122cb2 Authenticators: Add BasicAuth operation and handle it in transaction
This adds a new way for authenticators to trigger interactive authentication
in the client for simple user/password dialogs. These are not recommended
to use as a webflow is often better. However, for OCI remotes that
use http basic auth this is useful and allows the CLI experience to work
with that.
2019-12-12 12:16:53 +01:00
Alexander Larsson
ba9d607a92 transaction: Rename active_webflow* to active_request*
We want to use this for other types of interactive requests too.
2019-12-12 12:16:53 +01:00
Alexander Larsson
2601b4cb1a utils: Add helpers for text prompts and password prompts 2019-12-12 12:16:53 +01:00
Alexander Larsson
d25f65e968 OCI: Add an authenticator for OCI remotes
Given a configuration like:

[remote "oci-remote"]
url=oci+http://some.server.com/api/v1/organization/foo?index=labels
xa.authenticator-name=org.flatpak.Authenticator.Oci
xa.default-token-type=1
xa.authenticator-options={"auth": <"a-token-here">}

I was able to install an app from an OCI remote that required a login
2019-12-12 12:16:53 +01:00
Alexander Larsson
461a592b8e OCI: Add flatpak_oci_registry_get_token() method
This tries to do a HEAD request to the repository and if that fails
with 401 uses the OCI mechanism to (given a basic auth token) generate
a token for the download.
2019-12-12 12:16:53 +01:00
Alexander Larsson
b1a8852895 authenticator: Pass xa.oci-registry-uri from summary to authenticator
OCI will need this.
2019-12-12 12:16:53 +01:00
Alexander Larsson
73ea55c638 authenticator: Add per-commit summary info
In the non-p2p case add the per-commit summary info into the autheticator
request. This rewrites the keys with a "summary." prefix.

In the p2p case this doesn't make sense, so nothing there.

This will be needed for the OCI case where we need the
xa.oci-repository key.
2019-12-12 12:16:53 +01:00
Alexander Larsson
4dba1c389b authenticator: Add more data to token request
This adds the remote uri, and the per-ref commit id, as well
as extensible per-ref and per-request dicts we can add stuff to
as needed.

These will be used for the OCI case.
2019-12-12 12:16:53 +01:00
Alexander Larsson
976c88cf56 oci: Pass down token into OCI http operations
This is needed for pull operations to actually use the token if one
is given by an authenticator.
2019-12-12 12:16:53 +01:00
Alexander Larsson
6563b83704 Add xa.default-token-type remote option
This allows us to specify on a remote that all refs need a token
2019-12-12 12:16:53 +01:00
Matthias Clasen
54b5e39a96 permission-set: Auto-apply wrapping for data
It is confusing if we explicitly have to specify
the <> GVariant wrapping with --data, but
flatpak permissions strips it when displaying the
result.

Make it transparent by auto-applying the wrapping,
so what you need to pass to --data is the same
as what flatpak permissions shows you.
2019-12-12 09:08:07 +01:00
Matthias Clasen
6f8dc02bca permissions: Don't skip 'empty' rows
Don't skip entries that have no permissions.

I was wasting some time to track down why my
permission-set --data command wasn't working,
when in reality, the permissions command was
just not listing the entries I was adding :(
2019-12-11 17:21:36 +01:00
Matthias Clasen
cdf3c33293 permission-set: Add an option to set data
This is useful for debugging permission store functionality
and will be more so when the openuri portal starts using
per-entry data.
2019-12-11 17:21:36 +01:00
Matthew Leeds
0ab953a2f9 enter: Fix invalid arg error message
I think this was mistakenly changed in commit 4718bcccf.
2019-12-10 14:36:58 +01:00
Matthew Leeds
e0e9996370 doc/flatpak-build-bundle: Add an example for the user installation 2019-12-10 14:36:58 +01:00
Matthias Clasen
e7f0e09783 Merge pull request #3282 from ptomato/various-fixes
Minor fixes
2019-12-06 18:03:12 -05:00