1451 Commits

Author SHA1 Message Date
Alexander Larsson
e66c9ed56c Support multiple versions in required-flatpak metadata key
Support a list of versions that are supported. This will be useful
for e.g. the extra_data for extensions once that is backported to
1.2, because that will require it to say that it is supported for
> 1.2.5 in the 1.2 series and > 1.4.2 otherwise.

Closes: #3112
Approved by: alexlarsson

(cherry picked from commit 5026f01153)
(cherry picked from commit 9bbe6fbb48)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Matthew Leeds
88f3ebcb3a dir: Ignore trailing slash in remote URIs
Currently if you have a remote configured with the URL
"https://dl.flathub.org/repo/" (as you would if you use the flatpakrepo
file) and you use a flatpakref file which specifies the URL
"https://dl.flathub.org/repo", Flatpak tries to add a duplicate remote
because it doesn't see those URLs as equal. So ignore the trailing slash
when comparing remote URLs. OSTree works equally well with both kinds
(it uses g_build_filename()).

Flathub served flatpakref files with URLs missing a trailing slash until
this commit:
https://github.com/flathub/ansible-playbook/commit/b20694f09

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

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

Closes: #3065
Approved by: alexlarsson

(cherry picked from commit 866ba643d2)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Alexander Larsson
0eea5370ba Handle 'versions' key when finding local related ref
We were only handling the old single-value 'version' key, even though
we handled the 'versions' key when finding remote related refs.

The result of this was that some extensions, such as the 19.08 opengl
default one was installed by default (as it was found as remote related)
yet still removed with --unused (as it was not locally related).

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

Closes: #3093
Approved by: mwleed

(manually cherry-picked from commit aa7b62a0bf)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Philip Withnall
7c29654abf flatpak-installation: Handle an unconfigured remote when listing remotes
This prevents a crash in flatpak_installation_list_remotes_by_type() if
the `FlatpakDir` can’t ensure it has a repo configured.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #3028
Approved by: alexlarsson

(cherry picked from commit 791f31898b)
(cherry picked from commit 12cecc852c)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Owen W. Taylor
843fb75ebd OCI: correctly handle locally present icons
If the download URL for an icon was already cached locally, the HTTP
code returned FLATPAK_OCI_ERROR_NOT_CHANGED - this was treated as a real
error, and after downloading missing icons, all present icons were
deleted!

See https://bugzilla.redhat.com/show_bug.cgi?id=1683375

Closes: #3048
Approved by: alexlarsson

(cherry picked from commit a794c07e18)
(cherry picked from commit 767a9d5a43)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Matthew Leeds
11070054b4 dir: Don't overzealously rewrite an error
It's an error to call g_set_error() on an error that's already set, and
flatpak_dir_get_deploy_data() already sets FLATPAK_ERROR_NOT_INSTALLED
for us when necessary, so just pass on any errors to the caller of
flatpak_dir_get_origin(). In the case that the error is something else,
that should be treated as an error, because we never expect the deploy
directory to exist but not have a deploy file (see the implementations
of flatpak_dir_deploy() and flatpak_dir_undeploy()).

Closes: #3032
Approved by: alexlarsson

(cherry picked from commit b44c1a5799)
(cherry picked from commit 8ed03ef61e)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Andre Moreira Magalhaes
e4a7b2e2fd transaction: Append bundle to correct list on flatpak_transaction_add_install_bundle()
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>

Closes: #3025
Approved by: matthiasclasen

(cherry picked from commit 37a7b6edfd)
(cherry picked from commit 47af6b39b9)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Ryan Gonzalez
4b7963f5b1 dir: Use ExtensionOf.runtime for apply_extra
Closes: #2954
Approved by: alexlarsson

(cherry picked from commit 9cd682b057)

Closes: #2992
Approved by: alexlarsson

(cherry picked from commit cdc8d2deb5)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Ryan Gonzalez
f7463733da transaction: Install an extension's required runtime
Closes: #2954
Approved by: alexlarsson

(cherry picked from commit c87c480a18)

Closes: #2992
Approved by: alexlarsson

(cherry picked from commit 1ca31146d3)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Will Thompson
b415f607c1 dir: include NULL url in flatpak_dir_log() call
I spotted this line in the output from `flatpak history`:

    Jun  4 16:17:20	deploy install	com.discordapp.Discord	x86_64	stable	system	flathub	8a0fc700c701		Installed %s from %s	root (test)	flatpak-system-helper (gnome-software)	1.3.3

This is because the format string is passed as the 'url' parameter, the
first format parameter (the ref) is passed as the 'format' parameter,
and 'origin' is ignored because (fortunately) as far as I know, no
character significant to printf (like '%') is permitted in ref names.

Fix this by passing a NULL 'url', like the neighbouring call in
flatpak_dir_deploy_update().

(cherry picked from commit dbc90df513)
(cherry picked from commit 5a16666bdc)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:54 +00:00
Alexander Larsson
50358545d3 update: Fix OCI updates in the system repo
We need to check whether the remote is gpg verified after handling
the oci case, because OCI is fine to update systemwide without gpg
verification (in fact it doesn't support verification).

This just reorders the code, matching what is done in the install
case already.

Closes: #2891
Approved by: alexlarsson

(cherry picked from commit 4c4c80b85d)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:53 +00:00
Matthias Clasen
10772b0786 oci: Handle cancellations for appstream
When an appstream update is cancelled while downloading
icons, properly fail. Otherwise, the next update attempt
will see an up-to-date timestamp, think everyhing is ok
and not download the missing icons.

Closes: https://github.com/flatpak/flatpak/issues/2835

Closes: #2836
Approved by: alexlarsson

(cherry picked from commit f28e62add1)

Closes: #3115
Approved by: alexlarsson
2019-09-19 09:48:53 +00:00
Ryan Gonzalez
8e0aaf4b70 run: Only compare the lowest 32 ioctl arg bits for TIOCSTI
Closes #2782.

Closes: #2783
Approved by: alexlarsson

(cherry picked from commit a9107feeb4)
2019-03-26 11:01:56 +01:00
Matthew Leeds
62d7c62779 dir: Fix GError handling in flatpak_load_deploy_data()
Commit b20ee7e26 introduced a bug where flatpak_load_deploy_data()
returns NULL without setting @error in the case that there's a problem
reading the deploy file. I think this is causing a seg fault in
flatpak_installation_list_installed_refs() which tries to print the
error message after calling get_ref() (which indirectly loads the deploy
file).

I didn't personally verify that this fixes the GNOME Builder seg fault
that was reported, but it seems almost certain looking at the provided
stack trace, since get_ref() only returns NULL if
flatpak_dir_get_deploy_data() returns NULL, and that function clearly
sets the error pointer on failure except in flatpak_load_deploy_data().

I'm not sure why the deploy file doesn't exist (or is unreadable) for
the user who reported this seg fault.

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

Closes: #2733
Approved by: matthiasclasen

(cherry picked from commit 7a5c024695)
2019-03-26 11:01:56 +01:00
Alexander Larsson
dbf3c00f53 Fix issues with XDG_RUNTIME_DIR being /var/run which is a symlink
Whenever we use $XDG_RUNTIME_DIR and expose it somehow in the sandbox
we fully resolve the path, because if (as happens on gentoo for instance)
it contains /var/run -> ../run, then flatpak thinks we need to
add the /var/run symlink in the runtime even though we already
exposed that.

Closes: #2710
Approved by: matthiasclasen

(cherry picked from commit 28e96288c4)
2019-03-26 11:01:56 +01:00
Patrick Griffis
84c2ffaa01 Support multiple nvidia cards
Closes: #2695
Approved by: alexlarsson

(cherry picked from commit d2dff2875b)
2019-02-14 10:08:33 +01:00
Alexander Larsson
dcd19956fc Don't expose /proc when running apply_extra
As shown by CVE-2019-5736, it is sometimes possible for the sandbox
app to access outside files using /proc/self/exe. This is not
typically an issue for flatpak as the sandbox runs as the user which
has no permissions to e.g. modify the host files.

However, when installing apps using extra-data into the system repo
we *do* actually run a sandbox as root. So, in this case we disable mounting
/proc in the sandbox, which will neuter attacks like this.

(cherry picked from commit 468858c1cbcdbcb27266deb5c7347b37adf3a9e4)
2019-02-11 14:37:24 +01:00
Alexander Larsson
29510435ea CLI: Handle consoles reporting zero size
For whatever reason, in the buildbot environment the TIOCGWINSZ
ioctl returns a 0x0 size, which causes a divide by zero. We
handle this by returning a default 80x24 size.

Closes: #2685
Approved by: alexlarsson

(cherry picked from commit 7c9368d100)
2019-02-06 11:25:44 +01:00
Alexander Larsson
06a2f4d82d Actually always return non-null from flatpak_dir_get_display_name()
This also changes this to a non-const as we need to generate it.

Closes: #2683
Approved by: alexlarsson
2019-02-05 11:45:54 +00:00
Matthias Clasen
d502d31a34 Add a define for green
Add a define for the Escape sequence for green.

Closes: #2676
Approved by: mwleeds
2019-02-02 01:38:32 +00:00
Matthias Clasen
228ee0bd0a appdata: Ignore allowed attributes
We only interested in a few of the attributes of some
tags, but we shouldn't fail if other valid attributes
are present.

Add some of the allowed attributes to the <release> element
in the appdata test and verify that we can still parse it.

The appstream spec is here:
https://www.freedesktop.org/software/appstream/docs/

Closes: #2674
Approved by: matthiasclasen
2019-02-02 00:52:32 +00:00
Alexander Larsson
f0c404d104 Add backported version of g_date_time_new_from_iso8601
Closes: #2642
Approved by: matthiasclasen
2019-01-28 16:36:38 +00:00
Alexander Larsson
7a4f36b5fb Make dconf optional on dconf 0.26
This is needed, because e.g. xenial only has dconf 0.24 which doesn't
have the API needed.

Closes: #2643
Approved by: matthiasclasen
2019-01-28 16:33:06 +00:00
Alexander Larsson
485d51e0a7 run: Generate /run/host/font-dirs.xml config file
This file lists the directories that are remapped in the sandbox,
allowing fontconfig to use the correct cache identifier for the
host-side caches.

As an example, this generates:

```
$ ./flatpak run --command=sh org.gnome.gedit
[📦 org.gnome.gedit flatpak]$ cat /run/host/font-dirs.xml
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
	<remap-dir as-path="/usr/share/fonts">/run/host/fonts</remap-dir>
	<remap-dir as-path="/home/alex/.fonts">/run/host/user-fonts</remap-dir>
</fontconfig>
```

Closes: #2635
Approved by: alexlarsson
2019-01-25 12:21:45 +00:00
Matthias Clasen
a0d579bb9b Add utilities to switch in and out of raw mode
Closes: #2638
Approved by: alexlarsson
2019-01-25 12:03:47 +00:00
Matthias Clasen
69212da002 Parse date attributes in appdata
The spec allowed either timestamp or date to
be specified for a release, so we should support
both.

Closes: #2614

Closes: #2619
Approved by: alexlarsson
2019-01-21 08:46:57 +00:00
Matthias Clasen
7b94d827d7 Allow multiple name segments after prefix
This lets us export D-Bus service files for
names like org.foo.Bar.Application.Tracker.service
when the app-id is org.foo.Bar.

Closes: #2615

Closes: #2616
Approved by: alexlarsson
2019-01-21 08:27:09 +00:00
Philip Withnall
d9eed092cf common: Mark an error message as translatable
All the other error messages in that file are.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #2609
Approved by: matthiasclasen
2019-01-18 12:49:56 +00:00
Matthew Leeds
2274242301 transaction: Refuse to let root modify a user repo
If the user (erroneously) runs as root while modifying their user
installation, e.g. with "sudo flatpak --user install ...", this can
cause "permission denied" errors later on when they try to operate on
the installation as their own user. So refuse to execute a transaction
on a user-owned installation as root. Root can still operate on their
own per-user installation.

This approach does have a weakness: if flatpak is running as root when the user
installation is first created, it will be owned by root and therefore
avoid this check. I'm not sure what could be done about that.

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

Closes: #2575
Approved by: alexlarsson
2019-01-17 07:40:29 +00:00
Matthew Leeds
2e76702879 dir: Fix a few "already/not installed" error messages
There was some confusion between branches and commits.

Closes: #2604
Approved by: matthiasclasen
2019-01-16 22:00:44 +00:00
Matthew Leeds
1ea2864088 Remove no longer needed #define directives
Now that we depend on libostree 2018.9, these aren't needed.

Closes: #2593
Approved by: matthiasclasen
2019-01-15 20:02:17 +00:00
Matthias Clasen
f2303ee4c5 Export dconf data
We want to move away from using dconf inside the sandbox,
and instead use the keyfile backend for GSettings, which
has gained the capability to read defaults and locks.

This change makes the dconf database contents and locks
available in a suitable format. The files appear inside
the sandbox in the /etc/glib-2.0/settings directory.

We only export the default values for keys in the dconf
subtree whose path matches the app id, as well as prefixes
listed in paths key from the X-DConf group in metadata.

This commit adds a new dependency, since we're now linking
against libdconf.

Closes: #2295
Approved by: alexlarsson
2019-01-14 15:34:11 +00:00
Matthias Clasen
f9c6a769ef Stop linking libflatpak against listappstream-glib
We no longer use it here. flatpak itself still links
against it. This avoids problems with consumers who
might also link against libappstream.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
5db64fe342 Add a minimal GMarkup-based appdata parser
This parser nderstands just enough appdata to pull
out the strings we want.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
728f917418 Move appdata parsing to its own file
This is just moving some code around for now.
It is still using libappstream-glib.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
9dff4bbb85 Move flatpak_dir_load_appstream_store
This function has libappstream-glib types in the
api, which we want to drop. And it is only used
in app/, so move it there.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
faab490f1e Improve FlatpakInstallation docs
Document the values returned by flatpak_installation_get_id()
and by flatpak_installation_get_display_name() for standard
installations.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Matthias Clasen
f7a566e2ab Make sure we have IDs and display names
Return non-NULL strings from flatpak_dir_get_id()
and flatpak_dir_get_display_name() for user installations,
to save library users the hassle of dealing with NULL
return values.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Matthias Clasen
eaebab1285 Translate the display name of the default installation
Change the terminology from 'directory' to 'installation',
and mark the string for translation.

Closes: #2583
Approved by: alexlarsson
2019-01-14 13:59:14 +00:00
Alexander Larsson
cb30e7ef4e Add deploy refs for currently deployed commit.
When we deploy e.g. app/org.foo.bar/x86_64/stable, then we
also create a deploy/app/org.foo.bar/x86_64/stable ref pointing to
the latest deployed commit. We also remove it when an app is uninstalled.

This means that a prune operation will not delete objects that are deployed
(which would not save any space anyway). This is nice because this can
happen for instance when you flatpak update --no-deploy.

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

Closes: #2563
Approved by: alexlarsson
2019-01-14 11:55:12 +00:00
Matthias Clasen
3598cce951 Add utilities for showing/hiding the cursor
Closes: #2570
Approved by: alexlarsson
2019-01-14 11:41:42 +00:00
Matthew Leeds
dd5b798428 dir: Delete some outdated comments
It's no longer true that it's the pull code's job to resolve a ref to a
specific commit. Ever since commit 66eee3c2c this is the job of the
resolve_ops() function used by FlatpakTransaction (at least, when a
transaction is being used). So update a couple comments to avoid
confusion.

Closes: #2587
Approved by: alexlarsson
2019-01-14 10:34:34 +00:00
Matthias Clasen
e8e31edea2 Make number parsing more robust
We were parsing 2-6 with an out-of-range end value
as 2. Fix that.

Closes: #2578
Approved by: matthiasclasen
2019-01-12 02:05:05 +00:00
Matthias Clasen
b098d683e5 Export flatpak_parse_numbers
Export this function privately, so we can test it.

Closes: #2578
Approved by: matthiasclasen
2019-01-12 02:05:05 +00:00
Matthias Clasen
4f6fef6d82 Don't return NULL without setting an error
Set the expected error when returning NULL from
flatpak_dir_get_config due to an empty repo.

Closes: #2576

Closes: #2577
Approved by: mwleeds
2019-01-12 00:40:14 +00:00
Matthew Leeds
9aae124ca3 transaction: Fix gtk-doc warning
Closes: #2574
Approved by: matthiasclasen
2019-01-11 22:57:15 +00:00
Matthias Clasen
402e2020d8 Add a way to force fancy output on
This will be used for testing the table printer formatting.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:44 +00:00
Matthias Clasen
f39b5a2795 dir: Be more careful with self->repo
It is possible for self->repo to be NULL, therefore
call flatpak_dir_ensure_repo() in a bunch more places,
before accessing self->repo.

Closes: #2483

Closes: #2484
Approved by: matthiasclasen
2019-01-11 16:12:33 +00:00
Matthias Clasen
9ff489519c Add a utility to prompty for multiple choices
This is a variant that allows to enter multiple numbers,
either individually, or as range. Parts can be separated
by space or comma. Examples:
1-3,5
1 2 4
6

Closes: #2559
Approved by: alexlarsson
2019-01-11 15:57:44 +00:00
Matthias Clasen
b4e68422bf dir: Don't write to the console
In some cases, when NULL was passed for an OstreeProgress,
the library code would instantate its own progress object
and write progress information out to the console. That
is not a good thing for a library to do - it has the
potential to mess up the cli tools output.

Stop doing this, and require that all callers pass
a non-NULL progress.

Closes: #2468
Approved by: alexlarsson
2019-01-11 14:16:37 +00:00