4304 Commits

Author SHA1 Message Date
Dan Nicholson
0c63f30783 tests/test-gpg-signed-commit: Test more key states
Extend test-gpg-signed-commit.sh to test various key states. If gpg is
found that supports the required options, keys will be generated on the
fly and changed in various ways to exercise the output from
`ostree_gpg_verify_result_describe_variant` used in `ostree show`.

I tested this using gnupg 2.2.12, so I hope it works well enough on
various gpgs found in the wild.

Closes: #1872
Approved by: cgwalters
2019-06-19 17:17:11 +00:00
Dan Nicholson
d8649f4d56 tests/libtest: Allow specifying GPG homedir to cleanup
In case the tests want to use a custom GPG homedir, allow passing in the
homedir to use when cleaning up a running gpg-agent.

Closes: #1872
Approved by: cgwalters
2019-06-19 17:17:11 +00:00
Dan Nicholson
d0ec319b6b lib/gpg: Show if GPG key has been revoked
Rather then showing the incorrect `BAD signature`.

Closes: #1872
Approved by: cgwalters
2019-06-19 17:17:11 +00:00
Dan Nicholson
d714e622b8 lib/gpg: Show information for expired keys
Introduce a new signature attribute for the key expiration timestamp and
display it when the key has a non-zero expiration time. Without this,
the error shown is `BAD signature`, which isn't correct.

Closes: #1872
Approved by: cgwalters
2019-06-19 17:17:11 +00:00
Dan Nicholson
901c2f5e5f lib/gpg: Factor out expiration timestamp formatting
This will be reused to format a key expiration message.

Closes: #1872
Approved by: cgwalters
2019-06-19 17:17:11 +00:00
Allen Bai
be2572bf68 lib/kargs: Make API public and upstream new rpm-ostree APIs
This change makes public the current kargs API in src/libostree/ostree-kernel-args.c
and adds documentations.

Upstreams the new kargs API from rpm-ostree/src/libpriv/rpmostree-kargs-process.c

Merges libostree_kernel_args_la_SOURCES to libostree_1_la_SOURCES in Makefile-libostree.am

Upstreams tests/check/test-kargs.c from rpm-ostree.

Closes: #1833

Closes: #1869
Approved by: jlebon
2019-06-18 14:29:14 +00:00
Rafael Fonseca
2db79fb398 admin: allow multiple args for pin subcommand
Fixes #1816

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>

Closes: #1874
Approved by: rfairley
2019-06-17 15:06:09 +00:00
Dan Nicholson
d916383953 bin/refs: Allow overwriting existing ref
Currently if you want to update a non-alias ref, you need to first check
if it exists and use either `ostree refs --create` or `ostree reset` as
appropriate. That's unnecessarily complicated and is much less
convenient than the old `write-refs` builtin that simply called
`ostree_repo_set_ref_immediate()` without any checks.

Add a `--force` option to be used with `--create` that does not raise an
error when the destination ref already exists.

Closes: #1870
Approved by: jlebon
2019-06-12 15:00:19 +00:00
Allen Bai
6733843f87 lib/util: Fix segfault when validating filename
This change fixes the segfault issue when calling ostree_repo_checkout_tree with
empty GFileInfo. A simple condition check for NULL value is added at
src/libotutil/ot-unix-utils.c:46. Closes: ostreedev#1864.

Closes: #1868
Approved by: jlebon
2019-06-06 16:05:19 +00:00
Philip Withnall
e0ddaa811b ostree-repo-finder: Clarify immutability after construction
I think this was the intention, but I forgot to document it.

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

Closes: #1863
Approved by: mwleeds
2019-05-29 03:36:06 +00:00
Tristan Van Berkom
b847cc37bb tests: Test committing archives from stdin
This updates test-libarchive.sh to test committing archives from
stdin and verifying their content is correct.

Closes: #1862
Approved by: jlebon
2019-05-28 17:03:22 +00:00
Tristan Van Berkom
1c7bddd57a man: Document ability to commit archives from stdin
Closes: #1862
Approved by: jlebon
2019-05-28 17:03:22 +00:00
Tristan Van Berkom
bebd8d6980 bin/commit: Support committing archives from stdin
This commit interprets archive filenames specified as '-' to
indicate that the input should be read from stdin.

Closes: #1862
Approved by: jlebon
2019-05-28 17:03:22 +00:00
Tristan Van Berkom
da4d0245af lib/commit: Added new ostree_repo_write_archive_to_mtree_from_fd()
Similar to ostree_repo_write_archive_to_mtree(), but takes
a file descriptor to read the archive from instead of mandating
a file path.

Usefull for importing archives into an OSTree repo over a socket
or from standard input in command line tools.

Closes: #1862
Approved by: jlebon
2019-05-28 17:03:22 +00:00
Robert Fairley
1c0933b40c ci: Split out installdeps.sh from build.sh
This script is useful to run individually when setting up a
development environment for OSTree.

Closes: #1865
Approved by: jlebon
2019-05-27 16:07:07 +00:00
Robert Fairley
4929fc38e9 lib/fetcher-util: Use GIOErrorEnum instead of GIOError
Use GIOErrorEnum as the return value for
_ostree_fetcher_http_status_code_to_io_error(), to avoid an
implicit cast from GIOError.

Closes: #1857
Approved by: cgwalters
2019-05-20 13:09:28 +00:00
Robert Fairley
e493505ade tests: Drop unused variable
Closes: #1857
Approved by: cgwalters
2019-05-20 13:09:28 +00:00
Felix Krull
2c1658538f lib: add parameter annotations for sysroot_load_if_changed
Closes: #1861
Approved by: cgwalters
2019-05-19 14:50:08 +00:00
Felix Krull
aa5df8995e lib: add some missing (out) annotations
Closes: #1861
Approved by: cgwalters
2019-05-19 14:50:08 +00:00
Felix Krull
0872708ea1 lib: fix up some nullability annotations
Closes: #1861
Approved by: cgwalters
2019-05-19 14:50:08 +00:00
Felix Krull
e607e79f4e lib: add minimum version to various symbols based on libostree-released.sym
Closes: #1861
Approved by: cgwalters
2019-05-19 14:50:08 +00:00
Felix Krull
4aeba118b0 lib: fix doc comment for ostree_repo_get_min_free_space_bytes
Closes: #1861
Approved by: cgwalters
2019-05-19 14:50:08 +00:00
Felix Krull
01c471a6f3 README: update link to ostree-rs
Closes: #1860
Approved by: jlebon
2019-05-17 16:27:16 +00:00
Richard Hughes
f31d779690 lib: mmap the summary to reduce RSS in clients
Closes: #1855

Closes: #1856
Approved by: cgwalters
2019-05-08 19:36:24 +00:00
Tristan Cacqueray
82eccad945 docs: fix missing as typo
This change fixes a typo in the adapting-existing doc.

Closes: #1850
Approved by: cgwalters
2019-05-06 13:29:48 +00:00
Tristan Cacqueray
27b7d468e6 prepare-root: remove ignored MS_MGC_VAL flag
Since Linux 2.4 this is no longer required and the flag is ignored.

Closes: #1851
Approved by: cgwalters
2019-05-05 20:53:17 +00:00
Tristan Cacqueray
b35f337dc7 docs: fix switchroot source link
This change updates the switchroot source relative url to an absolute url so
that it works from the readthedocs service. This change also removes
redundant switchroot.sh reference.

Closes: #1849
Approved by: cgwalters
2019-05-05 20:38:58 +00:00
Jonathan Lebon
3ca1035e98 Post-release version bump
Closes: #1844
Approved by: rfairley
2019-04-25 16:47:40 +00:00
Jonathan Lebon
80435e12a7 Release 2019.2
Also add `ostree_repo_get_bootloader` to the public API, which was
missed when it was initially merged.

Closes: #1844
Approved by: rfairley
v2019.2
2019-04-25 16:47:40 +00:00
Colin Walters
304abee9eb prepare-root: Fix compilation with --with-static-compiler
Closes: https://github.com/ostreedev/ostree/issues/1845

Closes: #1846
Approved by: akiernan
2019-04-25 13:00:40 +00:00
Jonathan Lebon
586cc2deee lib/deploy: Support locking deployment finalization
Teach `ostree-finalize-staged.service` to check for a file in `/run` to
determine if it should do the finalization. This will be used in
RPM-OSTree, where we want to be able to separate out "preparing updates"
from "making update the default" for more fine-grained control. See:
https://github.com/projectatomic/rpm-ostree/issues/1748

Closes: #1841
Approved by: cgwalters
2019-04-24 21:38:24 +00:00
Jonathan Lebon
405d9ef9e0 lib/deploy: Write to journal if nothing to finalize
This can happen if a deployment was staged and later cleaned up. Though
just as a helper when debugging issues, let's explicitly mention that
case.

Closes: #1841
Approved by: cgwalters
2019-04-24 21:38:24 +00:00
Jonathan Lebon
5464535205 lib: Add ot_journal_* helper macros
Rather than wrapping each instance of `sd_journal_*` with
`HAVE_SYSTEMD`, let's just add some convenience macros that are just
no-op if we're not compiling with systemd.

Closes: #1841
Approved by: cgwalters
2019-04-24 21:38:24 +00:00
Robert Fairley
d69214ade3 grub2: Generate config from pending deployment
Generate a grub2 config using the pending deployment, if a grub2
bootloader is detected in the sysroot. Allows grub2-mkconfig
to run if there are no previous deployments.

Fixes: #1774

Closes: #1831
Approved by: jlebon
2019-04-24 21:29:39 +00:00
Robert Fairley
42573eae59 tests/test-admin-deploy-none: Split grub.cfg directory and file creation
Split the creation of the directory containing grub.cfg, and the creation
of the file, so that a failure in the mkdir command will fail the test
and not attempt the touch command.

Closes: #1831
Approved by: jlebon
2019-04-24 21:29:39 +00:00
Robert Fairley
144e99ce47 tests/test-admin-deploy-none: Update comment for #1774 status
Closes: #1831
Approved by: jlebon
2019-04-24 21:29:39 +00:00
Jonathan Lebon
ba96d7ed7a lib/sysroot: Match deployment /usr mode for overlay
Rather than hardcoding 0755, let's directly look at what `/usr`'s mode
is and copy it when creating the overlay.

Closes: #1843
Approved by: cgwalters
2019-04-24 13:48:14 +00:00
Jonathan Lebon
794f75ca61 lib/sysroot: Call chmod on overlay dirs when unlocking
Otherwise, we'll be subject to whatever `umask` is currently. Normally,
processes should respect `umask` when creating files and directories,
but specifically for `ostree admin unlock` (or `rpm-ostree usroverlay`),
this poses a problem since e.g. a `/usr` with mode 0700 will break any
daemon that doesn't run as root and needs to read files under `/usr`,
such as polkitd.

This patch just does a `chmod()` after the `mkdir()`. An alternative
would be to do `umask(0000)` after forking into the child process
that'll call `mount()`, but that'd require also moving the `mkdir()`
calls into there, making for a more intrusive patch.

Closes: #1843
Approved by: cgwalters
2019-04-24 13:48:14 +00:00
Robert Fairley
498a8bd404 tests/test-config: Fix regex causing Debian test failure
Fix CI failure due to mismatching quotes in the error output given
between Fedora and Debian test suites.

Example of the error in Debian Stretch:
https://api.travis-ci.org/v3/job/519335717/log.txt

Closes: #1839
Approved by: cgwalters
2019-04-23 06:11:39 +00:00
Robert Fairley
95d6701fb9 travis: Update to Debian Stretch
Update to Stretch to use updated version of glib2.0. Fixes CI
failure when parsing error output in tests/test-config.sh. See:

https://github.com/ostreedev/ostree/pull/1838#issuecomment-482186680
https://api.travis-ci.org/v3/job/518830164/log.txt

Closes: #1839
Approved by: cgwalters
2019-04-23 06:11:39 +00:00
Jonathan Lebon
298c601d88 ostree-prepare-root: Log journal message after finding deployment
Log a structured journal message when resolving the deployment path.
This will be used by the `rpm-ostree history` command to find past
deployments the system has booted into.

Closes: #1842
Approved by: cgwalters
2019-04-18 06:11:10 +00:00
Matthew Leeds
78747a8a17 lib/repo-refs: Allow resolving local collection-refs
Currently for a "normal" refspec you can choose to use
ostree_repo_resolve_rev_ext() instead of ostree_repo_resolve_rev() if
you only want to look at local refs (in refs/heads/) not remote ones.
This commit provides the analogous functionality for
ostree_repo_resolve_collection_ref() by adding a flag
OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY and implementing it. This
will be used by Flatpak.

Closes: #1825
Approved by: jlebon
2019-04-15 15:56:40 +00:00
Matthew Leeds
0ecbc6f2a9 lib/repo-refs: Add a flag to exclude listing from refs/mirrors
Currently the flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES for
ostree_repo_list_collection_refs() means that refs in refs/remotes/
should be excluded but refs in refs/mirrors/ should still be checked, in
addition to refs/heads/ which is always checked. However in some
situations you want to exclude both remote and mirrored refs and only
check local "owned" ones. So this
commit adds a new flag OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS which
lets you exclude refs/mirrors/ from the listing.

This way we can avoid breaking API but still allow the listing of local
collection-refs.

The impetus for this change is that I'm changing Flatpak to make more
use of refs/mirrors, and we need a way to specify that a collection-ref
is local when using ostree_repo_resolve_collection_ref() in, for
example, the implementation of the repo command. The subsequent commit
will make the changes needed there.

Closes: #1825
Approved by: jlebon
2019-04-15 15:56:40 +00:00
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 21ebc7d21edd00c3fe0ce80ea68ba3f8f5e41ae3

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