Commit Graph

1257 Commits

Author SHA1 Message Date
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
Georgelemental
0772ab6c9f Make deprecation warning notice less confusing
Replace "in preference of" with "in favor of," as the former is not
widely used, but the latter is.

This problem was mentioned in issue #3139.
2019-11-01 23:49:45 -04:00
Matthias Clasen
0df03adbb7 Merge pull request #3203 from wjt/flatpak-remote-ls-app-runtime
builtins: hide runtimes with [list|remote-ls] --app-runtime
2019-10-30 13:11:04 -04:00
Will Thompson
e282cd98d2 builtins: hide runtimes with [list|remote-ls] --app-runtime
Currently, if you run:

    flatpak remote-ls flathub --app-runtime=com.endlessm.Platform//eos3.2

you see no apps (correct) but hundreds of runtimes. This is inconsistent
with the documentation for the '--app-runtime' option, which says:

> List applications that use the given runtime

To fix this, default to not showing runtimes if '--app-runtime' is
given. This is consistent with the behaviour if just '--app' is
specified. If you run 'flatpak list --app-runtime=com.example.Foo
--runtime' then you get apps using that runtime, plus all other
runtimes, which seems fair enough to me.
2019-10-29 17:44:16 +00:00
Philip Withnall
cc7474d0e9 config: Rework handling of extra-languages to change locale format
Accept the locale format as documented by `setlocale(3)`, rather than
another arbitrary format.

This reworks the validation code, and was tested to accept all the
locales on my F30 system using:
```
flatpak config --user --set extra-languages $(locale -a | tr -s '\n' ';' | head -c -1)
```

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-24 13:54:05 +01:00
Philip Withnall
a3a7f3214c config: Accept bokmal as a language
It’s listed in `locale -a` output, even though it should canonically be
represented as `nb`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-24 13:54:05 +01:00
Philip Withnall
e78a53fede config: Accept C and POSIX as languages
They are listed as languages in `locale -a` output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-24 13:54:05 +01:00
Mazen Asef
65912f27fe app: Allow locales to be stored in the extra-languages key
In order to configure gnome-software to show specific apps in one region
without showing to all language speakers, we allow the storage of full
locales on the extra-languages key. However, these locales are ignored when
calling flatpak_installation_get_default_languages, so locales will be reduced
to their language identifier (eg. en_IN locale will be returned as 'en', and
az_Latn_AZ will be returned as 'az'). In order to get the full locales, we can
call flatpak_installation_get_default_locales instead, which can return languages
and locales.
2019-10-16 16:25:06 -03:00
Matthias Clasen
ea8ecdbeb9 eol: Use the right ref in the confirmation message
We were using the old ref here, instead of the new
one, when asking whether to go ahead.

Closes: https://github.com/flatpak/flatpak/issues/3139
2019-10-02 14:56:44 +02:00
Alexander Larsson
178845d6d6 mask: Support masking of updates
In addition to just masking auto-downloads, masking now also means
pinning of the currently installed version of an already installed ref.
2019-09-30 10:52:06 +02:00
Alexander Larsson
f9fad17b51 Add flatpak mask command
This commands lets you selectively disable auto-download of extensions
based on patterns. With this we can have extensions that install
by default, yet still allow the user to not have them re-installed
each time flatpak update is run.

This fixes https://github.com/flatpak/flatpak/issues/3090
2019-09-30 10:52:06 +02:00
Alexander Larsson
161a13951b Add flatpak install --or-update operation
This allows you to ensure that a particular app/runtime is installed
and with the latest version in a single operation, which is useful
for instance in automatic use, like CI systems.
2019-09-27 09:07:13 +02:00
Matthias Clasen
bbd4bedecc Take char width into account for formatting
When formatting text for terminal output, take
character width into account.

Fixes https://github.com/flatpak/flatpak/issues/2910

Closes: #3124
Approved by: alexlarsson
2019-09-23 08:39:49 +00:00
Matthew Leeds
d647bc105e installation: Make fetching remote refs work offline
Currently flatpak_installation_fetch_remote_ref_sync() does not work
offline. It returns an error when it fails to fetch the remote's summary
in flatpak_dir_get_remote_state(). This is a problem since GNOME
Software (or at least the Endless fork) uses this library function to
display apps it finds on a USB drive (see gs_plugin_refine_item_origin()
in gs-flatpak.c) and that's something that should work even offline.

So this commit changes flatpak_dir_get_remote_state_optional() so that
it accepts the only_cached option, and updates the call sites. Also have
fetch_remote_ref_sync() use flatpak_dir_get_remote_state_optional(),
which means that when we're offline we will use the xa.cache data in the
ostree-metadata ref as a list of refs list instead of using a summary.
However since the commit checksums are not in xa.cache, we don't have
enough information to form a FlatpakRemoteRef. So also call
ostree_repo_find_remotes_async() to get the commit from any LAN or USB
sources that may be available. This may not be very performant but at
least it only happens if the ref wasn't found in a remote summary; see
https://github.com/flatpak/flatpak/issues/1862

It's sad this code is so long-winded but it's difficult to break out a
helper function that could be shared with
list_remotes_for_configured_remote() above. Longer term we could improve
the ostree_repo_find_remotes_async() API and add options to remove the
need to manually handle OstreeRepoFinder objects.

Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthias Clasen
d346fa6b7e Avoid suggesting titles
The commands array contains entries that serve
just as section titles; avoid returning those
when looking for misspelt commands.

Pointed out in https://github.com/flatpak/flatpak/issues/3040

Closes: #3107
Approved by: matthiasclasen
2019-09-18 15:24:11 +00:00
Matthias Clasen
535e1a66b1 Include options in 'Did you mean...' suggestions
Suggest --help for 'flatpak help' and similar for
other options.

Suggested in https://github.com/flatpak/flatpak/issues/3040

Closes: #3106
Approved by: alexlarsson
2019-09-18 07:42:15 +00:00
Matthew Leeds
13279af129 Merge pull request #3058 from mazen-asef/add_default_languages_key
Add extra-languages config key
2019-09-13 13:19:08 -07:00
Mazen Asef
a0666034db app: Add new extra-languages key
If xa.languages is set, use these, and no others. Otherwise, take the union
of xa.extra-languages, and the system default locales for system repos;
xa.extra-languages for user repo and the langs based on the user's locale

Fixes https://github.com/flatpak/flatpak/issues/3043
2019-09-13 15:31:14 -03:00
Matthew Leeds
20c9d8477d app: Fix a use-after-free in flatpak_find_installed_pref()
Currently "flatpak --installation=default info ..." leads to an
assertion failure:

$ flatpak --installation=default info us.zoom.Zoom

(flatpak info:24593): GLib-GObject-CRITICAL **: 10:01:36.040: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

This is because in flatpak_find_installed_pref(), we set "dir =
installation_dir" but then installation_dir is freed by g_autoptr before
we try to return dir.

Fix the problem by stealing the pointer, and doing the same for the
other places dir is set.

Closes: #3077
Approved by: alexlarsson
2019-09-09 10:01:15 +00:00
Matthew Leeds
f88a9d9585 Use defined macro SYSTEM_DIR_DEFAULT_ID more
Just replace hardcoded strings with the macro, no functional change.

Closes: #3077
Approved by: alexlarsson
2019-09-09 10:01:15 +00:00
Alexander Larsson
51fe0307ef OCI: Handle manifests without annotations in index.json
When we export a manifest to the index, always pass the ref we're
targeting instead of relying on the org.opencontainers.image.ref.name
annotation, because that may not be set if we're using labels instead.

This is no big deal, because we know what ref we're handling anyway.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8f4082df6d build-bundle: Add --oci-use-labels switch
This allows the user to pick at runtime whether to use
annotations or labels as OCI metadata carrier. For historical
reasons annotations is the default, but some registries don't
support this and then you can use labels instead.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
58d9a257aa OCI: Use labels as commit metadata source as well as annotations
We now pull the image config as well as the manifest and fall
back on the labels field if the keys we're looking for are not
in the annotations field.

This lets us support docker manifests too, which don't have
annotations (but do have labels).

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
be9961ecf6 oci: Always generate a history, quay needs this
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
8416add254 Put annotations also in the labels
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Alexander Larsson
af96ceb9eb OCI: Break out the annotation generation code into a helper
This doesn't change the behaviour, it just breaks out everything related
to flatpak-specific annotations into one place where it can be resued.

Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Bartłomiej Piotrowski
8f7c96f408 Default end-of-life-rebase prompt to yes
Closes: #3063
Approved by: mwleeds
2019-08-20 21:15:21 +00:00
Debarshi Ray
e82efa8603 Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by
flatpak(1) or applications running as Flatpaks. It's also used by
toolbox(1) for similar reasons:
 * To keep various configuration files inside the container
   synchronized with the host
 * To let the container request certain commands to be run on the host

The org.freedesktop.Flatpak D-Bus service itself doesn't need much in
the way of dependencies, but inherits a lot of unused shared library
linkages through the libflatpak-common.la convenience library. Removing
these unused shared libraries reduces the footprint of toolbox(1) for
those who care about such things. eg., Fedora CoreOS.

This commit brings down the number of shared libraries to 19 from 62.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +00:00
Matthew Leeds
5e65174e8d build-bundle: Fix resolving refs
Unfortunately in commit 253fcc6e3 I broke the build-bundle command so
that it is unable to resolve remote refs (as opposed to local ones).
This means in the normal case of building a bundle for an app installed
from a remote it fails:

$ flatpak build-bundle /var/lib/flatpak/repo gnome-calculator.flatpak org.gnome.Calculator stable
error: Refspec 'app/org.gnome.Calculator/x86_64/stable' not found

This is because flatpak_repo_resolve_rev() interprets a NULL remote name
to mean the ref is local (in refs/heads/) but in this case we just don't
know which remote it's from. This commit fixes the issue by using
ostree_repo_resolve_rev() directly which searches refs/heads/ and
refs/remotes/, and if that fails falling back to iterating over refs
returned by ostree_repo_list_collection_refs() to catch collection-refs
that may be in refs/mirrors/.

Also, add a unit test that fails without this patch.

Fixes https://github.com/flatpak/flatpak/issues/3026

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Andre Moreira Magalhaes
eaec3a8203 cli-transaction: Fix some leaks
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>

Closes: #3025
Approved by: matthiasclasen
2019-07-23 14:54:59 +00:00
Simon McVittie
75b5b7c763 Don't register polkit agent if we cannot connect to system bus
This works around an old polkit client library bug which would cause
a segfault in this situation. The bug was fixed long ago in upstream
polkit, but is still present in Debian 10 'buster', Ubuntu 19.04 'disco'
and all older releases, due to Debian/Ubuntu using a branch of polkit
to avoid the mozjs dependency. It should finally get fixed in Debian 11
and Ubuntu 19.10.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug-Debian: https://bugs.debian.org/923046

Closes: #2997
Approved by: matthiasclasen
2019-07-11 18:11:21 +00:00
Matthew Leeds
4fd7d7d209 main: Handle double slashes in $XDG_DATA_DIRS
When checking for Flatpak directories in $XDG_DATA_DIRS, treat
/example//path/ as equivalent to /example/path/.

Fixes https://github.com/flatpak/flatpak/issues/2989

Closes: #2990
Approved by: alexlarsson
2019-06-28 08:44:41 +00:00