Commit Graph

6766 Commits

Author SHA1 Message Date
Alexander Larsson
445bddeee6 Make --nofilesystem=host/home remove access to subdirs of those
Previously --nofilesystem=host only removed specifically access to the
`host` permissions, and not necessarily other filesystems (like `home`
or `/some/path`). This isn't very useful to limit access because you
don't know what other filesystems the app may have access too.

We change this to mean that `--nofilesystem=host` removes *all* filesystem
access from the parent layer, and `--nofilesystem=home` removes all
file access to the homedir and paths inside it.

The available layers are, in order:

 * app permissions
 * overrides
 * commandline args

This allows you to start from scratch with the filesystem permissions
in the overrides or the commandline. This is a small change in
behaviour, but not a lot of things use --nofilesystem, and the ones
that do probably expects this behaviour.
2022-01-12 19:48:34 +01:00
Phaedrus Leeds
54ec1a482d Add test for metadata validation
This tests for invalid metadata, missing xa.metadata and mismatched
values in xa.metadata and the real metadata, including the embedded
null leading to the hidden permissions of CVE-2021-43860.
2022-01-12 19:48:16 +01:00
Alexander Larsson
65cbfac982 Ensure that bundles have metadata on install
If we have a bundle without metadata we wouldn't properly present
the permissions in the transaction.
2022-01-12 19:48:16 +01:00
Alexander Larsson
93357d3571 Require metadata in commit also for OCI remotes
This was disables a long time ago because the fedora remotes didn't
contain metadata, but that has been added since then. Requiring fixes
a security concern where an app claims to require no permissions (by
having no metadata in commit) but then actually requires permissions
in the installed app.
2022-01-12 19:48:16 +01:00
Alexander Larsson
d9a8f9d8cc Transaction: Fail the resolve if xa.metadata invalid or missing
If we fail to parse xa.metadata from the summary cache or the commit
xa.metadata we fail the resolve.

If xa.metadata is missing in the commit we fail the resolve (it is
always set in the summary cache, because summary update converts
missing xa.metadata to "", so we either get that, or cache miss which
leads to resolving from the commit.

This means that op->resolved_metadata is always set during install and
updates, which means we will show the app permissions. The transaction
will also always make sure that this data actually matches what gets
deployed.

Before this change an invalid metadata in the summary cache could lead
to a NULL resolved_metadata, which means we wouldn't print the app
permissions, yet we would still deploy some metadata file that could
have permissions. (NOTE: It would fail to deploy unless the
xa.metadata in the commit matched the metadata file, but in this
corner case we would't compare the summary and commit metadata, so
they may differ.)
2022-01-12 19:48:16 +01:00
Ryan Gonzalez
ba818f504c Fix metadata file contents after null terminators being ignored
In particular, if a null terminator is placed inside the metadata file,
Flatpak will only compare the text *before* it to the value of
xa.metadata, but the full file will be parsed when permissions are set
at runtime. This means that any app can include a null terminator in its
permissions metadata, and Flatpak will only show the user the
permissions *preceding* the terminator during install, but the
permissions *after* the terminator are applied at runtime.

Fixes GHSA-qpjc-vq3c-572j / CVE-2021-43860

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-01-12 19:48:16 +01:00
Phaedrus Leeds
2380309bf3 .github: Add checkbok for security sensitive issues 2022-01-10 23:15:03 +00:00
Ryan Gonzalez
47164fe477 dir: Cache the refs set when finding related refs
Previously, the code would rescan the list of refs many, many times.
Now, it only scans once per flatpak_dir_find_local_related_for_metadata
invocation, and it also only parses each refspec once. On my local
system with a large number of refs (>200) installed, this reduces the
time for a `flatpak remove org.freedesktop.Platform//21.08` to start
from ~7s to ~2s.

This does result in dropping an optimization where ostree_repo_list_refs
is already given the ref kind, but IME the overall speed gains are still
worthwhile.

Fixes #4191.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-01-10 10:09:20 +01:00
Phaedrus Leeds
3c63cac8f9 Export to share/metainfo not share/appdata
Read metainfo files from both share/appdata and share/metainfo to
support new and old versions of flatpak-builder
(https://github.com/flatpak/flatpak-builder/pull/441) but only export to
the new path.

Fixes https://github.com/flatpak/flatpak/issues/4599
2022-01-10 09:55:26 +01:00
Phaedrus Leeds
4d9fd30578 document-unexport: Finish implementing --doc-id
Picking up Matthias' commit from a few years ago to get it mergeable.
2022-01-10 09:40:40 +01:00
Matthias Clasen
9e090b845a document-unexport: Allow unexporting by docid
If the backing document has been deleted, then looking
up the doc-id fails. To work around this, allow specifying
the doc-id directly.

Closes: #1897
2022-01-10 09:40:40 +01:00
Phaedrus Leeds
45c7f5071c Add a test for the repair command
This should ensure that https://github.com/flatpak/flatpak/issues/4618
stays fixed.
2022-01-10 09:36:49 +01:00
Phaedrus Leeds
6fac58a9b9 repair: Properly mark invalid commits as partial
Commits that are found to have missing or invalid objects need to be
marked partial so that when the thing referencing them is reinstalled,
the missing objects will be pulled. libostree treats non-partial commits
as complete even if they're not, since verifying their completeness is
an expensive operation.

This exactly mirrors what the "ostree fsck" command does when it finds
corruption in a commit.

This fix is especially important because corrupt repos have been an
issue lately so we at least need repair to work properly.

Relatedly, delete invalid commit objects to ensure they are
re-downloaded, though it's not clear that code path is almost ever
reachable.

Fixes https://github.com/flatpak/flatpak/issues/4618
2022-01-10 09:36:49 +01:00
Phaedrus Leeds
417e3949c0 test-history.sh: Fix flakiness by moving sleep
The history test fails sometimes in the CI due to the remote add
operation being missing from the history command's output:

+ diff history-log -
0a1
> add remote			system (history-installation)	test-repo

Presumably this is due to that operation happening in the same second
that is passed to --since, so move the sleep statement to make sure a
second passes before we do anything.
2022-01-05 10:18:40 -08:00
lumingzh
bb09f3001e Update Chinese translation 2022-01-05 09:24:02 -08:00
TheEvilSkeleton
9e18120072 Add more translations and add last translator 2022-01-04 11:44:09 -08:00
TheEvilSkeleton
f4f2002e49 po: Add French translation 2022-01-04 11:44:09 -08:00
Phaedrus Leeds
e6702161da app: Don't use polkit agent in history command
There's no need to use polkit in the history command, so don't start the
agent in flatpak-main.c. This means we can avoid a test failure in
test-history.sh which was caused by old versions of valgrind being
unaware of syscall sched_getattr, which is used in g_bus_get_sync(),
itself called by install_polkit_agent().
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
dfda3f09ec doc/flatpak-history: Specify journalctl command 2022-01-04 11:42:00 -08:00
Phaedrus Leeds
8b05f6b365 Add a unit test for the history command 2022-01-04 11:42:00 -08:00
Phaedrus Leeds
2f13aabad6 history: Fix exclusion of temp repos
Without this change there are history entries showing pulls into
temporary repos which we don't want.
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
72aef63c58 history: Omit entries for appstream refs
Currently we include entries in the output of the history command for
pulls of appstream refs, e.g. "appstream2/x86_64". However since they
don't have an application ID the Application column shows up blank and
it seems like a pull of nothing which is confusing. These are basically
an implementation detail like the temp repo pulls we already exclude, so
I think it makes sense to exclude them from the output.

It would also make sense to exclude pulls of ostree-metadata refs, but
for some reason I don't see those in practice, even with a collection ID
set on the remote.
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
7b6dba8803 history: Fix printing refs
The history command seems to have been broken since it was changed to
use FlatpakDecomposed, since that type only works for app or runtime
refs, resulting in errors such as:
$ flatpak history
error: appstream2/x86_64 is not application or runtime

Fix this by making the logic a bit smarter, and don't let any one
invalid ref entry prevent the whole command from working.

Fixes #4332
2022-01-04 11:42:00 -08:00
Phaedrus Leeds
0c2cea75e8 dir: Make use of is_flatpak_ref() 2022-01-04 11:42:00 -08:00
Patrick Griffis
17b05b0c91 run: Fix session-bus and a11y-bus args being incorrect
This would incorrectly overwrite the a11y-bus option and not set the default
session-bus options.
2022-01-04 13:02:04 -06:00
Christian Kirbach
a5e8cfd1f6 Update proof-read German translation
from https://l10n.gnome.org/vertimus/flatpak/master/po/de/
2022-01-04 10:46:01 -08:00
lumingzh
5ee45fa7f1 Add zh_CN.po 2022-01-04 09:47:27 -08:00
lumingzh
223b197c6d Update LINGUAS
Add zh_CN
2022-01-04 09:47:27 -08:00
Phaedrus Leeds
6cc48e5ef9 dir: Fix a typo in a comment 2022-01-04 09:33:28 -08:00
Phaedrus Leeds
d4d4bcf6d8 dir: Fix another deploy error code path
This is another case where commit 4beaa990c seems to have mistakenly
turned an error code path into one where the deploy appears successful
to the caller of flatpak_dir_deploy() but the commit doesn't actually
get deployed.
2022-01-04 09:33:28 -08:00
Phaedrus Leeds
58f495b6e5 dir: Fix an error path when deploying malformed apps
If an app was created without a files/ directory, which shouldn't happen
with flatpak-builder but could happen if the commit is crafted manually,
currently the install operation exits successfully but the app is not
actually installed. Instead, error out, as we were doing before commit
4beaa990c2.
2022-01-04 09:33:28 -08:00
Phaedrus Leeds
4619bedfdb app: Refuse to work with sudo and --user
Have heard of people running Flatpak commands with both sudo and --user,
and not expecting it work on the root user's installation. Let's just
not allow it since it's not something people ever do intentionally.
2022-01-04 11:49:07 +00:00
Phaedrus Leeds
b6f627aa6e tests: Make grep assertions more specific
Maybe it's a bit pedantic but we shouldn't be matching
"org.test.Hello.Plugin.fun" when we're trying to match "org.test.Hello",
so add some trailing slashes to prevent that, and change the options on
a few commands so we're only parsing the columns we care about.
2022-01-04 11:47:20 +00:00
Ping
c9d4ec12bc Update Croatian translation 2021-12-20 09:06:45 -08:00
Aleix Pol
e28b1f3158 Do not forget to pass the actual error message
Several of our users have been reporting this error to me, can never
tell what could be wrong.
2021-12-17 12:32:14 -08:00
Jan Tojnar
973a909c84 run: Use URN for fontconfig DTD
It should not make any difference other than making it in sync with fontconfig
9c46ef4aac
2021-12-17 12:31:46 -08:00
Phaedrus Leeds
ef1c99a6ae Merge pull request #4627 from flatpak/fix-ci-variant-schema-compiler-update
Update variant-schema-compiler to fix build
2021-12-17 12:21:58 -08:00
Phaedrus Leeds
6cb4a2598e Update variant-schema-compiler to fix build
Fixes https://github.com/flatpak/flatpak/issues/4534
2021-12-17 12:07:20 -08:00
Phaedrus Leeds
d4b681ec6c Merge pull request #4612 from JakobDev/soukremove
Remove Souk from Readme
2021-12-03 10:02:03 -08:00
JakobDev
d9b57b9c95 Remove Souk from Readme 2021-12-03 18:16:02 +01:00
Phaedrus Leeds
f513bf4710 Merge pull request #4597 from haaninjo/l10n-sv
Update Swedish translation
2021-11-22 08:32:35 -08:00
Anders Jonsson
10f2be12c3 Update Swedish translation 2021-11-22 16:06:39 +01:00
Phaedrus Leeds
1e081bc411 Merge pull request #4592 from refi64/fix-fish-dir
Fix fish profile script install directory
2021-11-19 09:14:02 -08:00
Ryan Gonzalez
5927260823 Fix fish profile script install directory
Caught by @gasinvein on #4575 post-merge: I didn't realize fish has a
separate folder for config files provided by the vendor vs added by the
user. This changes the install directory to match the vendor config dir.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2021-11-19 09:34:57 -06:00
Phaedrus Leeds
6d74eec0a9 dir: Verify subsummary checksum from disk cache
Currently we verify the checksum of indexed summary files (which have
.sub file names) before writing them to the on-disk cache, so in theory
as long as the disk I/O is successful the data integrity should be
intact when we use it via the flatpak-variant-impl-private.h helpers
generated by variant-schema-compiler. However in practice people
sometimes hit assertion failures which are what you would expect to see
if the data is corrupt, since GVariant stores some metadata such as the
"offset size" toward the end of the data, and if we read this from
serialized user data instead it will obviously be incorrect. In one case
I was able to acquire the flathub.idx, flathub.idx.sig, and
flathub-x86_64-fad08cfb10713e749f02a0e894b5d577b7e9c4931fdf9d2fdc50364c002bc925.sub
files which reproduce one of the assertion failures, and the sub file
appears to be incomplete, like the writing of it was interrupted.

We use g_file_replace_contents() when saving these to the disk, and when
not replacing an existing file that function writes directly to the
final filename, so if interrupted it would be expected to leave an
incomplete file.

This commit changes the summary file handling so that we verify the
checksum of any indexed subsummary again after reading it from disk. If
it doesn't match we delete the on-disk cache and try fetching from the
network.

Fixes #4127
2021-11-18 15:22:00 +01:00
Phaedrus Leeds
470b321c63 list: Tweak logic for excluding Locale/Debug extensions
The man page states that the --all option for the list command includes
runtime extensions (e.g. that end in .Locale or .Debug) and this is the
case. When --all is omitted, we only show such extensions when the thing
they extend is not already in the list. However when you run a command
like "flatpak list --runtime --columns=application,branch", you get a
list that excludes runtime locale extensions but includes app locale
extensions, since the corresponding apps are not in the list despite
presumably being installed. This doesn't seem like the right behavior,
so tweak the logic so that app locale extensions are excluded when --all
is omitted and --runtime is used.

Strictly speaking the "extension-of" information is not guaranteed to be
present in the deploy data (which acquires it from the metadata), but in
practice it seems to be present for all but Sources extensions, and I
think it should be considered required since we are already using it to
implement functionality elsewhere in Flatpak:
https://github.com/flatpak/flatpak/issues/4585
2021-11-18 15:20:05 +01:00
Phaedrus Leeds
2c4c84ffee app: Don't tab-complete on aliases
Fixes https://github.com/flatpak/flatpak/issues/4036
2021-11-18 15:11:05 +01:00
Phaedrus Leeds
dfde010a49 tests: Fix a comment 2021-11-17 08:43:29 -08:00
Phaedrus Leeds
e5df71fb65 Merge pull request #4527 from flatpak/readme-specify-build-steps
README: Add more helpful build instructions
2021-11-16 13:50:37 -08:00
Phaedrus Leeds
8ebb79a2c6 Move build instructions to HACKING.md
The README was getting long and unweildy
2021-11-16 13:33:13 -08:00