Commit Graph

1288 Commits

Author SHA1 Message Date
Alexander Larsson
ca343957fc Update CLI to new authenticator options format
We're using a per-key format now, so switch from
  --authenticator-options=blob
to
  --authenticator-option=key=value

In both remote-modify and remote-add
2019-12-17 15:25:42 +01:00
Alexander Larsson
ecf4c3630a authenticator: Set the xa.authenticator-name-is-set key
This is set when the option is explicitly set and should not be
auto-overridden.
2019-12-17 15:25:42 +01:00
Alexander Larsson
e645424e69 Cli-transaction: Fix leak
We didn't free the table printer used.
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
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
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
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
1ec4232fd5 CLI: Handle basic auth in transactions 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
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
Philip Chimento
923beec024 Change "update-frequency" to "update-interval"
An event happens more often as its frequency gets higher, so these
values were confusing me.

Rename the constants to include their unit (ms) as well, to avoid
confusion.

Anything that affects public API (such as
flatpak_transaction_progress_set_update_frequency()) or libostree's
options passed to ostree_repo_pull_with_options(), is left as is.
2019-12-06 13:26:49 -08:00
Matthias Clasen
5ec73b9a9a ps: Allow showing compositor info
Show active and background state, based on information obtained
from the background portal backend about which apps have (active) windows.

This currently tries all known portal backends in turn. It might
be nicer to have a portal frontend api to query this, or to find
out which backend to talk to.
2019-12-04 13:33:52 +01:00
Matthias Clasen
653fce251f cli: Don't use \r in plain output
These show up as ^M in test logs, and that is irritating.
Just use \n when producing plain output.

Closes: https://github.com/flatpak/flatpak/issues/3226
2019-12-04 13:30:13 +01:00
Matthias Clasen
4765a78a87 Merge pull request #3270 from matthiasclasen/parent-pid-docs
run: Improve help output for --parent-pid
2019-12-02 07:28:28 -05:00
Matthias Clasen
b76a1bd0df Merge pull request #3265 from matthiasclasen/ps-instance
ps: Don't hardcode instance column
2019-12-02 07:27:23 -05:00
Matthias Clasen
4201a35081 Merge pull request #3266 from matthiasclasen/fail-message-period
Error message cosmetics
2019-12-02 07:26:41 -05:00
Matthias Clasen
76d23cca15 enter: Correct the help output
The COMMAND is not optional, so don't put it in brackets.

Closes: https://github.com/flatpak/flatpak/issues/2881
2019-12-01 23:14:27 -05:00
Matthias Clasen
cb2cadb3ad run: Improve help output for --parent-pid
Show a placeholder to indicate that this option
takes an argument. Update docs to match.
2019-12-01 16:12:36 -05:00
Matthias Clasen
35f023e2d0 build-commit-from: No period for error messages
We don't use periods at the end of error messages
elsewhere, and it looks wrong.
2019-12-01 09:47:53 -05:00
Matthias Clasen
0460d486a9 kill: No period for error messages
We don't use periods at the end of error messages
elsewhere, and it looks wrong.
2019-12-01 09:46:34 -05:00
Matthias Clasen
90c2d24127 ps: Don't hardcode instance column
We were unconditionally adding the instance column,
which causes table headers to be off-by-one when
instance is not among the requested columns.

Change things to only add the instance column
when requested.
2019-12-01 09:39:46 -05:00
Alexander Larsson
ae50843851 portal: Add EXPOSE_PIDS flag
This uses the new bwrap feature via flatpak run --parent-expose-pids to
make new new sandbox pid namespace be a child of the callers sandbox.

Pretty obvious, the only weird thing is that we can't get the peer pid
directly from the caller (as it goes via the dbus proxy) so we have
to look that up from the instance data.
2019-11-27 14:21:25 +01:00
Alexander Larsson
62797b4be9 flatpak run: Add --parent-pid=$pid --parent-expose-pids
Given the pid of an existing flatpak process, if --parent-expose-pids is
specified, the new sandbox is run such that its processes are visible in
the specified sandbox.

In all other senses the two are disjoint though. The new sandbox is
still isolated from the host and the existing sandbox.
2019-11-27 14:21:25 +01:00
Alexander Larsson
f420fad6a9 cli transaction: Handle webflow signals
This shows the url in the default browser. Currenly it just looks
at $BROWSER and falls back to xdg-open.
2019-11-26 16:37:01 +01:00
Alexander Larsson
8d02d86463 add/modify-remote: Add options to set authenticator options 2019-11-26 16:37:01 +01:00
Alexander Larsson
077006ecc8 Add token-type per-commit metadata key and export it to summary
We store this in the sparse cache, because we don't expect it to be
set for everything.
2019-11-26 16:37:01 +01:00
Alexander Larsson
e2379d20e2 Optionally return commit id in flatpak_remote_state_lookup_cache
This will only work if xa.commits is in the metadata, which is only
available in the p2p case and was only added recently.
2019-11-26 16:37:01 +01:00
Alexander Larsson
3c74199549 Print errors on stderr in install/update
If we're not doing fancy ui, print errors on stderr. This was biting me
in some tests where I'd like to grep for some strings in the stderr
output.
2019-11-26 16:37:01 +01:00
Alexander Larsson
2db1c6e6c4 Add defines for existing summary sparse cache keys
These are explicitly made short to save space, so lets have defines
for them to make sure we don't mistype them, especially as we
will be adding new keys.
2019-11-26 16:37:01 +01:00
Alexander Larsson
8cc737466f run: Allow overriding no-a11y/dbus for sandboxed runs 2019-11-26 09:52:07 +01:00
Alexander Larsson
66b2621297 run: Clean up code that sets flags
No changes, just make the code easier to read by using ifs
instead of a bunch of ?: ops.
2019-11-26 09:52:07 +01:00
Matthias Clasen
c503307ae0 Use DeletePermission when available
This avoids a racy client-side implementation.
2019-11-22 16:35:43 +01:00
Matthias Clasen
bb5b2de3f1 install: Always show the op column
Otherwise, it is not clear what changes the question below
the table refers to.

Fixes: https://github.com/flatpak/flatpak/issues/3075
2019-11-21 13:49:30 +01:00
Matthias Clasen
c917257a1c permission-remove: Allow removing a single row
Allow specifying an app-id to remove from a given
id in a given table.
2019-11-21 13:48:31 +01:00
Matthias Clasen
5a8489cefe Add a permission-set command
This command adds permissions for an app to one of the permission
store database(s).
2019-11-21 13:48:31 +01:00
Alexander Larsson
4718bcccfd enter: Make sure sudo -E works when using setuid brwap
This also updates the manpage so it is correct wrt permissions and
sudo.
2019-11-20 13:17:43 +01:00
Alexander Larsson
6d68094879 enter: Better error values if enter is not supported on your kernel 2019-11-20 13:17:43 +01:00
Alexander Larsson
a094aa0040 enter: Add comment about why NS_GET_USERNS ioctl is not used 2019-11-20 13:17:43 +01:00
Alexander Larsson
47e2718833 enter: Clean up namespace equality checks
There is no need to read the links, just look at the inode nr
which is the same info, and that also works on the bind-mounted
.userns thing where readlink fails.

Also, don't fail for non-existing namespaces.
2019-11-20 13:17:43 +01:00
Alexander Larsson
a0cb7f6964 enter: No need to fail if a pid is specified that it is not the primary pid.
We can enter from any pid in the sandbox.
2019-11-20 13:17:43 +01:00
Alexander Larsson
f568a068c6 enter: Support non-root flatpak enter
Assuming unprivileged namespaces works we can now user the .userns
bindmount to access the intermediate bubblewrap user namespace.

This also drops the warning about root, and make sure we drop all caps
at the end.
2019-11-20 13:17:43 +01:00
Alexander Larsson
e16b40dfec enter: Use the correct pid (child pid) as the target for entering
This is the one in a namespace, the other one is just the wrapper.
2019-11-20 13:17:43 +01:00
Alexander Larsson
180494ca41 run: Don't install polkit agent for enter/run/build
Neither of these ever need a polkit agent, and run/build are somewhat
performance sensitive and we don't want to connect to dbus unnecessarily.
For enter this is critical though, as the dbus connection starts a thread
which is not compatible with the setns syscall.
2019-11-20 13:17:43 +01:00
Matthew Leeds
eabc52456a Clean up duplicated mirror refs
Due to bug #3215 some systems have refs in refs/mirrors/ in addition to
the usual refs/remotes/ location. The remote refs are always at least as
new as the mirror ones since the repo_pull() invocation in
flatpak_dir_pull() which does not use OSTREE_PULL_FLAGS_MIRROR happened
after the one that did. Cleaning up these mirror refs is important since
otherwise when the remote ref is either updated or removed (by an
uninstall) disk space will be leaked since the mirror ref will point to
a no longer needed commit.

So, remove (almost) all mirror refs during flatpak repair, uninstall,
or update operations. And for the uninstall and update operations do it
in FlatpakDir so that it happens regardless of if the CLI of libflatpak
are used.

Also, add a unit test for this.

Fixes https://github.com/flatpak/flatpak/issues/3222
2019-11-20 13:17:27 +01:00
Matthew Leeds
2342a7d4be app/flatpak-quiet-transaction: Use "in favor of" phrasing
In commit 0772ab6c9 we changed "in preference of" to "in favor of" in an
informational message produced by FlatpakCliTransaction for clarity. Do
the same for FlatpakQuietTransaction.
2019-11-18 15:07:01 -08:00
Matthew Leeds
547443b13d Merge pull request #3185 from georgelemental/patch-1
Make deprecation warning notice less confusing
2019-11-01 21:45:14 -07:00