Commit Graph

4261 Commits

Author SHA1 Message Date
Matthew Leeds 23304b8c15 lib/repo-refs: Fix resolving collection-refs
My last commit "lib/repo-refs: Resolve collection-refs in-memory and in
parent repos" changed ostree_repo_resolve_collection_ref() to check the
in-memory set of refs *after* failing to find the ref on disk but that's
not what we want. We want to use the in-memory set of refs first,
because those are the most up to date commits, and then fall back to the
on-disk repo and finally fall back to checking any parent repo. This
commit makes such a change to the order of operations, which is
consistent with how ostree_repo_resolve_rev() works.

Aside from this change being logical, it also fixes some unit test
failures on an unmerged branch of flatpak:
https://github.com/flatpak/flatpak/pull/2705

Also, tweak the comments here.

Closes: #1825
Approved by: jlebon
2019-04-15 15:56:40 +00:00
Jonathan Lebon a8754ae370 boot: Activate ostree-finalize-staged even earlier
Really, all `ostree admin finalize-staged` needs is access to `/sysroot`
and `/boot`. So let's activate it right after `local-fs.target` so that
it gets deactivated later in the shutdown process. This should allow us
to conflict with less services still running and possibly writing things
to `/etc`.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1672283

Closes: #1840
Approved by: cgwalters
2019-04-15 00:11:00 +00:00
Matthew Leeds 89c00e7eb7 tests: Put a regex in quotes
Closes: #1834
Approved by: rfairley
2019-04-11 14:28:32 +00:00
Matthew Leeds dd6844a61e tests: Escape periods when appropriate
Don't match any character in a regular expression when we only want to
match a period.

Closes: #1834
Approved by: rfairley
2019-04-11 14:28:32 +00:00
Laurent Bonnans 077b23cc98 lib/repo: fix leak of `bootloader` field
Added in 21ebc7d21e

Closes: #1837
Approved by: rfairley
2019-04-11 14:18:10 +00:00
Matthew Leeds da57956327 lib: Check for http_proxy being the empty string
On at least one user's computer, g_getenv("http_proxy") returns the
empty string, so check for that and treat it as no proxy rather than
printing a warning.

See https://github.com/flatpak/flatpak/issues/2790

Closes: #1835
Approved by: cgwalters
2019-04-02 20:44:08 +00:00
Matthew Leeds c9725d0bef lib/repo-pull: Allow the keyring remote to be overridden
Currently the P2P code requires you to trust every remote you have
configured to the same extent, because a remote controlled by a
malicious actor can serve updates to refs (such as Flatpak apps)
installed from other remotes.[1] The way this attack would play out is
that the malicious remote would deploy the same collection ID as the
victim remote, and would then be able to serve updates for it.

One possible remedy would be to make it an error to configure remotes
such that two have the same collection ID but differing GPG keys. I
attempted to do that in Flatpak[2] but it proved difficult because it is
valid to configure two remotes with the same collection ID, and they may
then each want to update their keyrings which wouldn't happen
atomically.

Another potential solution I've considered is to add a `trusted-remotes`
option to ostree_repo_find_remotes_async() which would dictate which
keyring to use when pulling each ref. However the
ostree_repo_finder_resolve_async() API would still remain vulnerable,
and changing that would require rewriting a large chunk of libostree's
P2P support.

So this commit represents a third attempt at mitigating this security
hole, namely to have the client specify which remote to use for GPG
verification at pull time. This way the pull will fail if the commits
are signed with anything other than the keys we actually trust to serve
updates.

This is implemented as an option "ref-keyring-map" for
ostree_repo_pull_from_remotes_async() and
ostree_repo_pull_with_options() which dictates the remote to be used for
GPG verification of each collection-ref. I think specifying a keyring
remote for each ref is better than specifying a remote for each
OstreeRepoFinderResult, because there are some edge cases where a result
could serve updates to refs which were installed from more than one
remote.

The PR to make Flatpak use this new option is here[3].

[1] https://github.com/flatpak/flatpak/issues/1447
[2] https://github.com/flatpak/flatpak/pull/2601
[3] https://github.com/flatpak/flatpak/pull/2705

Closes: #1810
Approved by: cgwalters
2019-03-29 21:41:57 +00:00
Colin Walters 8d2e9b8f9e static-delta: Change `show` to display from/to commits
When writing a delta to a file this may not always be recorded
in the filename, and it's useful data.

Ref: https://mail.gnome.org/archives/ostree-list/2019-February/msg00000.html

This also required teaching `show` to accept a file path.

Note...for some reason `test-deltas.sh` breaks when run from
a tty - we get `SIGTTIN` which implies something is reading from
the tty but it wasn't obvious to me what.

Closes: #1823
Approved by: jlebon
2019-03-11 13:59:27 +00:00
Jonathan Lebon 978cffed70 lib/deploy: Don't include version twice in bootmenu title
In Silverblue right now, the boot menu title looks like this:

    Fedora 29.20190301.0 (Workstation Edition) 29.20190301.0 (ostree)

This is because RPM-OSTree's `mutate-os-release` feature is enabled,
which injects the OSTree version string directly into `VERSION` and
`PRETTY_NAME`. So appending the version string again is a bit redundant.
Let's just do a simple substring check here before adding the version to
the title.

Closes: #1829
Approved by: cgwalters
2019-03-09 19:44:15 +00:00
Robert Fairley 21ebc7d21e Add sysroot.bootloader repo config key
The sysroot.bootloader key configures the bootloader
that OSTree uses when deploying a sysroot. Having this key
allows specifying behavior not to use the default bootloader
backend code, which is preferable when creating a first
deployment from the sysroot (#1774).

As of now, the key can take the values "auto" or "none". If
the key is not given, the value defaults to "auto".

"auto" causes _ostree_sysroot_query_bootloader() to be used
when writing a new deployment, which is the original behavior
that dynamically detects which bootloader to use.

"none" avoids querying the bootloader dynamically. The BLS
config fragments are still written to
sysroot/boot/loader/entries for use by higher-level software.

More values can be supported in future to specify a single
bootloader, different behavior for the bootloader code, or
a list of bootloaders to try.

Resolves: #1774

Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Robert Fairley 99cf13b225 libotutil: Add ot_keyfile_get_value_with_default_group_optional()
Add ot_keyfile_get_value_with_default_group_optional() which allows
getting values from keys where the group is optional in the config
file. This is preparatory to add the sysroot.bootloader repo config
key, where the sysroot group is optional.

Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Robert Fairley 91892e3c3f libotutil: Rename to ot_keyfile_get_string_list_with_separator_choice()
Rename ot_keyfile_get_string_as_list() to
ot_keyfile_get_string_list_with_separator_choice() which expresses
more clearly why the function is needed. Also shorten the
function comment.

Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Robert Fairley 52987b532c tests/test-config: Remove extra space
Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Robert Fairley b0af96c80a ostree-grub-generator: Comment wording fix
Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Colin Walters 6e1588c022 ci/rpmostree: Bump to 2019.1
Should fix the issue that CI broke due to libsolv not being sync'd.

Closes: #1806
Approved by: jlebon
2019-03-01 16:41:09 +00:00
Colin Walters bb141d38da ci/rpmostree: Fix use of `fatal`
We're not using libtest, just inline it.

Closes: #1806
Approved by: jlebon
2019-03-01 16:41:09 +00:00
Matthew Leeds cfc6046689 ostree/config: Check for too many args
Currently it's not an error to provide too many arguments to an ostree
config command. Change it so we print usage information in that case,
and update the unit tests.

Closes: #1743
Approved by: cgwalters
2019-03-01 16:29:44 +00:00
Matthew Leeds 656853a98a man/ostree-config: Consistently use GROUPNAME placeholder
It doesn't make much sense to use SECTIONNAME in some places and
GROUPNAME in others when they mean the same thing.

Closes: #1743
Approved by: cgwalters
2019-03-01 16:29:44 +00:00
Matthew Leeds fe6b197516 ostree/config: Use g_autoptr instead of goto
It seems cleaner to make the GKeyFile a g_autoptr variable and just
return rather than using the "goto out;" idiom.

Closes: #1743
Approved by: cgwalters
2019-03-01 16:29:44 +00:00
Matthew Leeds eecd989d46 ostree/config: Add an "unset" operation
Currently there's a way to set a key to the empty string but there's no
way to unset it completely (remove the key from the group). This might
be helpful for instance if you want to temporarily set
"core.lock-timeout-secs" to a specific value for the duration of one
operation and then return it to the default after that operation
completes.

This commit implements an "unset" operation for the config command, adds
a unit test, and updates the man page.

Closes: #1743
Approved by: cgwalters
2019-03-01 16:29:44 +00:00
Matthew Leeds 77f91d6c6b lib/repo-refs: Resolve collection-refs in-memory and in parent repos
Currently the behavior of ostree_repo_resolve_rev() is that it tries to
resolve a ref to a commit by checking the refs/ directories, but also by
checking for in-memory ref-checksum pairs which are part of an
in-progress transaction and also by checking the parent repo if one
exists. Currently ostree_repo_resolve_collection_ref() only checks the
refs/ directories, so this commit makes its behavior analagous since it
is the analagous API which supports collection-refs.

The impetus for this was that currently Flatpak uses
ostree_repo_resolve_rev() to load a commit after doing a P2P pull in
flatpak_dir_do_resolve_p2p_refs(), but that assumes the ref came from
the same remote that originally provided it, which might not be the case
if more than one remote has the same collection ID configured. And
changing Flatpak to use ostree_repo_resolve_collection_ref() doesn't
work without this patch.

Closes: #1821
Approved by: pwithnall
2019-02-18 13:42:08 +00:00
Matthew Leeds f5c86c834b man: Document ostree --version
Closes: #1820
Approved by: rfairley
2019-02-14 19:52:13 +00:00
Matthew Leeds 2738bbb6d2 tests: Remove unused includes in libostreetest.c
Since commit a06bd82cd we no longer use OVERLAYFS_SUPER_MAGIC or
statfs() so remove the includes for linux/magic.h and sys/vfs.h

Closes: #1815
Approved by: cgwalters
2019-02-11 13:44:07 +00:00
Jeremy Bicha 1ec4945c2d tests: Update for glib 2.59.2
glib 2.59.2 uses a non-breaking space instead of a space to
separate the quantity and unit in g_format_size() so update
our test to handle both a plain space and a non-breaking space.

See https://gitlab.gnome.org/GNOME/glib/issues/1625

Closes: #1818
Approved by: cgwalters
2019-02-11 13:26:32 +00:00
Matthew Leeds f7a0ec9bf7 tests: Don't skip collection-based summary test
OSTree's P2P support used to be a compile time option but is now always
enabled. One of the tests was still checking for the old feature flag,
"experimental", which has been renamed to "p2p" and skipping for that
reason. Delete the check so the test always runs.

Closes: #1804
Approved by: pwithnall
2019-02-11 00:14:45 +00:00
Matthew Leeds 27d354da86 lib/repo: Fix Since: annotation for REMOTE_CHANGE_REPLACE
Closes: #1813
Approved by: jlebon
2019-02-08 21:57:13 +00:00
Dan Nicholson b33a4e9b1e remote-add: Add --force option to add or replace remote
This uses the OSTREE_REPO_REMOTE_CHANGE_REPLACE operation to add a
remote or replace an existing one. This is roughly the opposite of
--if-not-exists and will raise an error if both options are passed.

Closes: #1166
Approved by: cgwalters
2019-02-08 14:36:41 +00:00
Dan Nicholson 8431bb5406 man: Document remote add --if-not-exists option
Closes: #1166
Approved by: cgwalters
2019-02-08 14:36:41 +00:00
Dan Nicholson 15ba2007a1 repo: Add OstreeRepoRemoteChange replace operation
Add the OSTREE_REPO_REMOTE_CHANGE_REPLACE operation to the
OstreeRepoRemoteChange enum. This operation will add a remote or replace
an existing one. It respects the location of the remote configuration
file when replacing and the remotes config dir settings when adding a
new remote.

Closes: #1166
Approved by: cgwalters
2019-02-08 14:36:41 +00:00
Matthew Leeds 6e935ee26f lib/repo-pull: Fix docs for n-network-retries option
Add "Since: 2018.6" and copy the docs to
ostree_repo_pull_from_remotes_async() which also supports it.

Closes: #1812
Approved by: jlebon
2019-02-07 14:36:08 +00:00
Colin Walters 6649032a37 lib/commit: Don't set user.ostreemeta for bare → bare-user-only imports
The point of `bare-user-only` is it doesn't have xattrs; it's a
special case in import handling.

Closes: #1803
Approved by: jlebon
2019-01-16 14:37:15 +00:00
Colin Walters c63ee3cef4 lib/commit: Set xattr on correct fd for bare-user → bare-user imports
Another fix to https://github.com/ostreedev/ostree/pull/1771

Closes: #1803
Approved by: jlebon
2019-01-16 14:37:15 +00:00
Colin Walters c79d792fd5 lib/commit: Fix bare → bare imports
Regression from https://github.com/ostreedev/ostree/pull/1771

This broke rpmostreepayload in Anaconda where we import a bare repo:
https://openqa.fedoraproject.org/tests/345339#step/_do_install_and_reboot/4

Reported-by: Adam Williamson <adamwill@fedoraproject.org>

Closes: #1803
Approved by: jlebon
2019-01-16 14:37:15 +00:00
Micah Abbott 620a3138ae README: add note about Liri OS
Closes: #1802
Approved by: rfairley
2019-01-15 17:41:34 +00:00
Colin Walters 40a54e3d27 Post-release bump
Closes: #1800
Approved by: jlebon
2019-01-11 15:49:45 +00:00
Colin Walters 13bcc49603 Release 2019.1
Closes: #1800
Approved by: jlebon
2019-01-11 15:49:45 +00:00
Colin Walters 308d30d080 pull: If built with --disable-http2, allow enabling via http2=1
We have a `http2=[0|1]` remote config option; let's have the
`--disable-http2` build option define the default for that.  This way
it's easy to still enable http2 for testing even if
we have it disabled by default.

Closes: #1798
Approved by: jlebon
2019-01-09 15:04:27 +00:00
Colin Walters fa35ec38b7 fixup! admin/status: test GPG signature check 2019-01-08 15:24:10 +00:00
Rafael Fonseca 6e8377cbd1 admin/status: test GPG signature check
Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>

Closes: #1797
Approved by: cgwalters
2019-01-08 14:47:08 +00:00
Sinny Kumari cd9138d9a0 atomic-upgrades doc: fix example url to fetch a ref checksum
Signed-off-by: Sinny Kumari <sinny@redhat.com>

Closes: #1795
Approved by: cgwalters
2019-01-02 14:26:03 +00:00
Ricardo Salveti b6795c93ea grub2: add support for devicetree
Similar as available for u-boot (ce2995e1dc)
and syslinux (c5112c25e4), enable parsing
and writing devicetree filename into grub.cfg.

This is required by arm64-based devices running edk2 instead of u-boot
as the main bootloader (e.g. 96boards HiKey and HiKey960).

Signed-off-by: Ricardo Salveti <ricardo@foundries.io>

Closes: #1790
Approved by: cgwalters
2018-12-21 14:00:42 +00:00
Matthias Clasen ee988f69aa Fix a small leak in ostree_repo_remote_list_collection_refs
g_variant_iter_loop would free the value for us,
but not if we're returning from the middle of the
loop body.

Closes: #1788
Approved by: cgwalters
2018-12-20 18:10:16 +00:00
Matthias Clasen f0719681f9 Fix a small leak in ostree_repo_pull_with_options
Spotted in a flatpak valgrind log.

Closes: #1788
Approved by: cgwalters
2018-12-20 18:10:16 +00:00
Jonathan Lebon c62232c09d boot/grub2: Add some more explanation in ostree-grub-generator
Even with the previous docstring, I didn't understand at first the
relationship between the `ostree-grub-generator` script and
`ostree-bootloader-grub2.c`. Throw some more docs to clarify things a
bit.

Closes: #1791
Approved by: cgwalters
2018-12-20 18:09:36 +00:00
Rafael Fonseca f2d4537ffb admin/status: Correctly check GPG signature
Closes: #1770

Closes: #1787
Approved by: jlebon
2018-12-14 15:23:53 +00:00
Umang Jain c25b1c7063 man/ostree.repo-config: Update min-free-space-* docs
Docs should reflect the changes done in PR:
https://github.com/ostreedev/ostree/pull/1779

Closes: #1786
Approved by: jlebon
2018-12-12 14:25:16 +00:00
Umang Jain 963395217a lib/repo-commit: Relax min-free-space check in prepare_transaction()
We want a case where we can disable the min-free-space check. Initially,
it felt like to add a OSTREE_REPO_PULL_FLAGS_DISABLE_FREE_SPACE_CHECK but
the problem is prepare_transaction() does not have a OstreeRepoPullFlags
parameter which we can parse right here. On top of it, prepare_transaction()
enforces min-free-space check and won't let the transaction proceed if
the check failed.

This is pretty bad in conjunction with "inherit-transaction" as what
Flatpak uses. There is no way to disable this check unless we remove
it altogether from prepare_transaction.

This issue came out to light when flatpak wasn't able to write metadata
after fetching from remote:

[uajain@localhost ~]$ flatpak remote-info flathub org.kde.Platform//5.9
error: min-free-space-size 500MB would be exceeded

Metadata objects helps in housekeeping and restricting them means
restricting crucial UX (like search, new updates) functionalities
in clients like gnome-software. The error banners originated from
these issues are also abrupt and not much helpful to the user. This
is the specific instance of the issue this patches tries to address.

See https://github.com/flatpak/flatpak/issues/2139 for discussion.

Closes: #1779
Approved by: mwleeds
2018-12-10 20:04:17 +00:00
Luca Bruno 3ecbdd8197 lib/kargs: allow empty-list arguments
This adds support for empty-list arguments (e.g. `acpi_osi=`), which
are semantically different from simple-keyword arguments.

Ref: https://github.com/projectatomic/rpm-ostree/issues/1706

Closes: #1785
Approved by: cgwalters
2018-12-10 19:39:23 +00:00
Alexander Larsson d044bfeb30 Fix leak in ostree_content_stream_parse()
We need to ref_sink new GVariants for autoptr to work

Closes: #1784
Approved by: cgwalters
2018-12-10 14:12:24 +00:00
Colin Walters 416007e766 ci/papr: Drop insttests
This didn't quite work out, and is now always failing because Ansible
changed.

For now we have some OK coverage via the rpm-ostree suite, let's just
drop this and revisit later.

Closes: #1783
Approved by: jlebon
2018-12-10 14:01:47 +00:00