Commit Graph

3562 Commits

Author SHA1 Message Date
Colin Walters 0ff4bee743 sysroot: Add a public `#define OSTREE_PATH_BOOTED`
This is public API.  Motivated by
https://github.com/coreos/rpm-ostree/pull/3325/files#diff-56528694f6f3213d6fb88d872f77291412dceec263b57166519843b13eca9a4dR30
2022-01-12 12:47:11 -05:00
Colin Walters 8aeceb9b88
Merge pull request #2514 from lucab/ups/drop-setenv
libostree/sepolicy: get rid of a g_setenv() call
2022-01-12 06:51:14 -05:00
Colin Walters 998154f8ff main: Also support CLI extensions in `/usr/libexec/libostree/ext`
In fixing https://github.com/coreos/rpm-ostree/pull/3323
I felt that it was a bit ugly we're installing `/usr/bin/ostree-container`.

It's kind of an implementation detail.  We want users to use
`ostree container`.

Let's support values outside of $PATH too.

For example, this also ensures that TAB completion for `ost` expands
to `ostree ` with a space.
2022-01-11 20:13:33 -05:00
Luca BRUNO 840cd7ab2d
libostree/sepolicy: get rid of a g_setenv() call
This removes a 'g_setenv()' call, which could potentially be unsafe
in a multi-thread context.
The current libselinux codebase does not seem to check for
`LIBSELINUX_DISABLE_PCRE_PRECOMPILED`, so I think this has no effects
nowadays.
Additionally, I could not find any reference to it in libselinux
git history, so I'm not sure if it ever played any role at all.

My current understanding is that this is coming from version
incompatibilities between an older libselinux in the build environment
and a newer policy (with precompiled regexs) in the target.
But from the ML discussion I found, I think it eventually got
solved in a different way, possibly by avoiding the policy binary
caches.

Refs:
 * https://www.spinics.net/lists/selinux/msg14822.html
 * https://github.com/ostreedev/ostree/pull/2513#discussion_r781042884
2022-01-11 15:56:13 +00:00
Luca BRUNO 0bdba574d7
ostree: check g_setenv return value
This adds proper return-value checks on g_setenv calls.
It fixes a static analysis warning highlighted by Coverity.
2022-01-10 13:33:36 +00:00
Luca BRUNO 0b1a085692
libotutil: avoid leaking builder memory on error
This swaps the order of a couple of input sanity checks, in order
to fix a minor memory leak due to an early-return on the error
path.
Memory for the result is now allocated only after input has been
sanity-checked.
It fixes a static analysis warning highlighted by Coverity.
2022-01-10 09:30:11 +00:00
Simon McVittie 43859b58f6
rofiles-fuse: Build using FUSE 3 if possible, falling back to FUSE 2
This adds build-time configuration logic to automatically detect
and switch between libfuse 2.x and 3.x.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Luca BRUNO <luca.bruno@coreos.com>
2022-01-04 09:41:38 +00:00
Luca BRUNO eae35b7f6e
lib/static-delta: throw a proper error on bspatch failure
This makes sure that a populated GError is returned when bsdiff
patching fails. The human-friendly label also helps in debugging.
2022-01-03 17:38:51 +00:00
Luca BRUNO cf814284e0
lib: use ostree-content-writer header
This installs and exposes the content of `ostree-content-writer.h`,
so that library consumers can properly reference symbols defined
in that header.
2022-01-03 14:20:58 +00:00
Colin Walters 27c14f2be6 soup-uri: Fix clang-analyzer warning by dropping dead code
Fixes `Argument with 'nonnull' attribute passed null` by making
the code not exist at all anymore.

In upstream libsoup this code is gone too; it uses `GUri` from glib
which we probably could now too, but one thing at a time.
2021-12-21 15:13:56 -05:00
Luca BRUNO 513b3c09a5
main: add support for CLI extensions via external binaries
This adds some logic to detect and dispatch unknown subcommands to
extensions available in `$PATH`. Additional commands can be
implemented by adding relevant `ostree-$verb` binaries to the system.

As an example, if a `/usr/bin/ostree-extcommand` extension is provided,
the execution of `ostree extcommand --help` will be dispatched to that
as `ostree-extcommand extcommand --help`.
2021-12-20 10:00:02 +00:00
Colin Walters b56786c415
Merge pull request #2496 from lucab/ups/repo-asserts
lib/repo: fix problematic invariant checks
2021-12-07 19:58:23 -05:00
Colin Walters 490f515e18
Merge pull request #2494 from jmarrero/fsf-address
Update FSF license notices to use URL instead of address
2021-12-07 15:51:48 -05:00
Luca BRUNO 58bdfb90c9
lib/repo: do no return a NULL on failure
This turns an existing check into an assert. The previously returned
NULL may result in confusing callers, as none of them is checking for
that.
2021-12-07 16:24:56 +00:00
Luca BRUNO 4a0ebe507f
lib/repo: do no return an arbitrary mode on failure
This turns the existing check into an assert. Otherwise, the previous
code may return an arbitrary repo mode (bare) on failure.
2021-12-07 16:23:02 +00:00
Luca BRUNO f1e24945fa
lib/repo: assert that writable state and error agree
This adds an assertion to check that writable stable and error
are in sync. The subsequent logic uses them interchangeably.
2021-12-07 16:21:21 +00:00
Joseph Marrero 581a58067b Update FSF license notices to use URL instead of address 2021-12-07 08:34:25 -05:00
Colin Walters 2c39bd88a9 repo: Change locking for summary regeneration to be shared
This is trying to address:
https://pagure.io/fedora-iot/issue/48

Basically we changed rpm-ostree to start doing a shared lock during
commit by default, but this broke because pungi is starting a process
doing a commit for each architecture, and then trying to regenerate
the summary after each one.

This patch is deleting a big comment with a rationale for why
summary regeneration should be exclusive.  Point by point:

> This makes sure the commits and deltas don't get
> deleted while generating the summary.

But prune operations require an exclusive lock, which means that
data still can't be deleted when the summary grabs a shared lock.

> It also means we can be sure refs
> won't be created/updated/deleted during the operation, without having to
> add exclusive locks to those operations which would prevent concurrent
> commits from working.

First: The status quo *has* prevented concurrent commits from working!

There is no real locking solution to this problem. What we really
need to do here is regenerate the summary after each commit *or*
when the caller decides to do it and e.g. include deltas at the same
time.

It's OK if multiple threads race to regenerate the summary;
last-one-wins behavior here is totally fine.
2021-12-03 14:42:03 -05:00
Luca BRUNO cefc1d7854
lib: misc static analysis fixes
This fixes a few warnings from coverity, none of which really
interesting.
2021-11-26 15:11:00 +00:00
Jonathan Lebon 947acbf178 app: Only remount /sysroot if needed
We should only try to remount `/sysroot` if we're actually handling the
sysroot repo and the repo isn't writable. We already have public APIs to
check each of those, so let's use them.

Closes: #2485
2021-11-19 11:01:18 -05:00
Dan Nicholson 47d32d9ead lib/prune: Avoid unnecessary object serialization
`repo_prune_internal` was deserializing each object and passing the
components to `maybe_prune_loose_object`, which promptly reserialized
it.
2021-11-18 11:04:06 -07:00
Ryan Gonzalez 9c1fe55bbc lib: Avoid dereferencing NULL error values
Otherwise, this will segfault when callers don't need any exact errors.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2021-11-12 08:29:05 -06:00
Colin Walters 1a86517d65
Merge pull request #2476 from valentindavid/valentindavid/glib-fix
lib: Fix a bad call to g_file_get_child
2021-11-09 09:27:18 -05:00
Valentin David adc097a2ed
lib: Fix a bad call to g_file_get_child
In Glib, since commit 3a6e8bc8876e149c36b6b14c6a25a718edb581ed,
`g_file_get_child` does not accept absolute path as paramater anymore.

The broken assertion was encountered during `ostree admin deploy`
command for the checkout of subpath `etc`.

Example of error log:
```
(ostree admin deploy:1640): GLib-GIO-CRITICAL **: 03:42:00.570: g_file_get_child: assertion '!g_path_is_absolute (name)' failed

(ostree admin deploy:1640): GLib-GIO-CRITICAL **: 03:42:00.570: g_file_query_info: assertion 'G_IS_FILE (file)' failed
**
OSTree:ERROR:src/ostree/ot-main.c:232:ostree_run: assertion failed: (success || error)
Bail out! OSTree:ERROR:src/ostree/ot-main.c:232:ostree_run: assertion failed: (success || error)
```
2021-11-03 21:40:35 +01:00
Colin Walters c553b5c69a
prepare-root: Set up sysroot readonly in initramfs
Let's ensure things are right from the start in the initramfs;
this closes off various race conditions.  Followup to
3564225917

Closes: https://github.com/ostreedev/ostree/issues/2115
2021-11-03 16:37:20 +00:00
Luca BRUNO 63d0c4c781
prepare-root: check for read-only sysroot status early on
This moves read-only sysroot checks upfront, so that they are not
intermixed with mount operations.
It has no immediate side-effects, but allow these check to be
independent from the rest of the mounting logic (and future changes
to it).
2021-11-01 09:42:36 +00:00
Jonathan Lebon b7efd16cc5
Merge pull request #2472 from lucab/ups/prepare-root-checked-printf 2021-10-26 15:14:21 -04:00
Luca BRUNO 7c17daad17
prepare-root: get rid of a global variable
This moves a global mutable variable to a smaller local scope,
as it is not really used outside of that.
2021-10-26 16:27:22 +00:00
Luca BRUNO ca84da679a
prepare-root: check return codes for errors when assembling paths
This adds checks around all `snprintf` calls in order to detect
failures and gracefully abort.
2021-10-26 16:16:34 +00:00
Luca BRUNO 848fe542af
prepare-root: make all mount operations silent
This adds a `MS_SILENT` flag to all `mount(2)` calls, reducing the
amount of kernel logs produced on each boot.
Those messages do not contain actionable details, and in the "mount
plus read-only remount" case they can easily become highly redundant.
2021-10-26 10:51:37 +00:00
Luca Bruno 6b8295ada1
Merge pull request #2463 from cgwalters/fix-fanalyzer
Fix various mostly theoretical gcc `-fanalyzer` issues
2021-10-14 08:30:25 +00:00
Colin Walters 029a9d56c3 variantutil: Fix gcc `-fanalyzer` warnin
Add some not-NULL assertions for return values from glib,
and upgrade some `g_return_if_fail` to `g_assert`.
2021-10-13 17:13:14 -04:00
Colin Walters 54bf42c3e5 utils: Fix unreachable `NULL` deref by adding assertion
Again this one is just in theory, but let's add an assertion.
2021-10-13 17:13:14 -04:00
Colin Walters f355482e1f static-delta: Fix probably not actually possible NULL deref
Flagged by `gcc -fanalyzer`.  I didn't study this really deeply
but I think it's not actually reachable.  Anyways, let's catch
it on general principle.
2021-10-13 17:13:14 -04:00
Colin Walters 3159e04980 fetcher/soup: Fix gcc `-fanalyzer` warning
In general, we're probably going to need to change most of our
`g_return_if_fail` to `g_assert`.  The analyzer flags that
the function can return `NULL`, but the caller isn't prepared for
this.

In practice, let's abort.
2021-10-13 17:13:14 -04:00
Colin Walters 520b45afdd sysroot: Fix gcc `-fanalyzer` warning
In general, we're probably going to need to change most of our
`g_return_if_fail` to `g_assert`.  The analyzer flags that
the function can return `NULL`, but the caller isn't prepared for
this.

In practice, let's abort.
2021-10-13 17:13:14 -04:00
Colin Walters 9a7f9c2095 deployment: Fix gcc `-fanalyzer` warning
In general, we're probably going to need to change most of our
`g_return_if_fail` to `g_assert`.  The analyzer flags that
the function can return `NULL`, but the caller isn't prepared for
this.

In practice, let's abort.
2021-10-13 17:13:14 -04:00
Colin Walters a8eed03a19 remote: Fix gcc `-fanalyzer` warning
In general, we're probably going to need to change most of our
`g_return_if_fail` to `g_assert`.  The analyzer flags that
the function can return `NULL`, but the caller isn't prepared for
this.

In practice, let's abort.
2021-10-13 17:13:14 -04:00
Luca BRUNO 8a9737aa6e
repo/private: move OstreeRepoAutoTransaction to a boxed type
This defines `OstreeRepoAutoTransaction` as a boxed type, in order
to support auto-generating bindings for it.
That first requires adding internal reference-counting to it, to
allow freely copying/freeing references to a single transaction guard.
2021-10-11 06:52:25 +00:00
Luca BRUNO f4be52ba24
prepare-root: tweak log messages to clarify errors
This rewords errors and log messages in the functions which take care
of preparing sysroot in initramfs.
Depending on the boot flow, it is possible to reach this logic
with a sysroot mounted (unexpectedly) as read-only.
In that case, let's clearly point out the problematic mountpoint.
2021-10-07 14:56:47 +00:00
Colin Walters a73a28634d Remove OstreeTlsCertInteraction bits from introspection
We filter out everything named `-private.h` from scanning,
which differs from the gtk-doc exclude.  Eventually this will
be solved when we switch to the new gir-based docs.

Came up in https://github.com/ostreedev/ostree-rs/pull/34#discussion_r723337772
2021-10-06 12:42:56 -04:00
Colin Walters 63bf5e606b Release 2021.5 2021-10-05 15:59:43 -04:00
Jonathan Lebon 8cb5d920c4
Merge pull request #2449 from cgwalters/mtree-from-commit 2021-10-05 11:56:02 -04:00
Colin Walters cf2eef8486
Merge pull request #2454 from lucab/ups/auto-txn-complete
repo/private: allow committing/aborting through a transaction guard
2021-10-05 10:49:01 -04:00
Luca BRUNO c987534595
repo/private: allow committing/aborting through a transaction guard
This enhances the auto-transaction logic, augmenting the scope of a
transaction guard.
It allows committing or aborting a transaction through its guard.
It also supports tracking the completion status of a transaction
guard, avoiding double commits/aborts, while retaining the auto-cleanup
logic.
2021-10-05 12:23:22 +00:00
Colin Walters e6a560b407 deploy: Ignore sockets, fifos in /etc during merge
https://bugzilla.redhat.com/show_bug.cgi?id=1945274 is an issue where a privileged
kubernetes daemonset is writing a socket into `/etc`.  This makes ostree upgrades barf.

Now, they should clearly move it to `/run`.  However, one option is for us to
just ignore it instead of erroring out.  Some brief investigation shows that
e.g. `git add somesocket` is a silent no-op, which is an argument in favor of ignoring it.

Closes: https://github.com/ostreedev/ostree/issues/2446
2021-10-01 11:28:11 -04:00
Colin Walters 868776a296 lib: Add an API to construct a `MutableTree` from a commit
This is nicer than having the caller parse the commit
object, or indirect via the `OstreeRepoFile*` object of the root.

Will be used in ostree-rs-ext around tar parsing.
2021-10-01 09:34:19 -04:00
Colin Walters 5bf4b1dabc
Merge pull request #2447 from cgwalters/sepolicy-for-commit
repo: Add an API to init `OstreeSePolicy` from commit directly
2021-09-30 17:25:30 -04:00
Colin Walters ddc0d54b78 sepolicy: Add deprecation comment for `_get_path()`
Came up in review
https://github.com/ostreedev/ostree/pull/2447#issuecomment-931428312
2021-09-30 15:54:48 -04:00
Colin Walters 1b9e3a9375 repo: Add an API to init `OstreeSePolicy` from commit directly
This is part of `OstreeCommitModifier`, but I'm not using
that in some of the ostree-ext Rust code.

It just makes more sense as a direct policy API, where it should
have been in the first place.  There's already support for
setting a policy object on a commit modifier, so that's all the
old API needs to do now.
2021-09-30 15:54:48 -04:00
Colin Walters 1ed290c7d9 fsck: Print a success message
There's a general Unix philosophy that "silence is golden".
However, when one is explicitly invoking an error check it's nice
to see explicit success.

We already print various statistics, so ending with a happy
note has no extra cost.
2021-09-30 14:09:22 -04:00
Colin Walters ab12e380fc bin/commit: Fix --tree=tar with --selinux-policy
The logic for `--selinux-policy` ended up in the `--tree=dir`
path, but there's no reason for that.  Fix the imported
labeling with `--tree=tar`.  Prep for use with containers.

We had this bug because the previous logic was trying to avoid
duplicating the code for generic `--selinux-policy` and
the case of `--selinux-policy-from-base --tree=dir`.

It's a bit more code, but it's cleaner if we dis-entangle them.
2021-09-30 11:44:27 -04:00
Colin Walters 55090f108d Release 2021.4 2021-09-08 14:00:12 -04:00
Colin Walters ce36e05d38
Merge pull request #2434 from cgwalters/custom-remote
Add support for "custom remotes"
2021-09-08 09:27:26 -04:00
Colin Walters 511c7a13ee Add support for "custom remotes"
This will be helpful for the "ostree native container" work in
https://github.com/ostreedev/ostree-rs-ext/

Basically in order to reuse GPG/signapi verification, we need
to support adding a remote, even though it can't be used via
`ostree pull`.  (At least, not until we merge ostree-rs-ext into ostree, but
 even then I think the principle stands)
2021-09-08 07:42:25 -04:00
Luca Bruno 7e4c4f2a69
Merge pull request #2435 from RBuddel/fix-delta-files-resume-legacy-transaction
repo-pull: legacy_transaction_resuming flag ignored
2021-09-08 08:52:54 +00:00
Buddelmann, Richard RB 744bf94369 repo-pull: legacy_transaction_resuming flag ignored
for deltafiles the legacy_transaction_resuming flag is not used,
which will mark the commit as done, even if files are missing.
using already existing commitstate_is_partial function as fix
2021-09-08 08:41:05 +02:00
Colin Walters 8821ec6e56 upgrade: Stabilize deployment staging
We're waaay overdue for this, it's been the default
in rpm-ostree for years, and solves several important bugs
around not capturing `/etc` while things are running.

Also, `ostree admin upgrade --stage` (should) become idempotent.

Closes: https://github.com/ostreedev/ostree/issues/2389
2021-09-07 16:12:43 -04:00
Colin Walters 3691a23a41
Merge pull request #2340 from cgwalters/sign-verify-api
Add an API to verify a commit signature explicitly
2021-08-31 08:04:21 -04:00
Colin Walters 359435de84 Add an API to verify a commit signature explicitly
We have a bunch of APIs to do GPG verification of a commit,
but that doesn't generalize to signapi.  Further, they
require the caller to check the signature status explicitly
which seems like a trap.

This much higher level API works with both GPG and signapi.
The intention is to use this in things that are doing "external
pulls" like the ostree-ext tar import support.  There we will
get the commitmeta from the tarball and we want to verify it
at the same time we import the commit.
2021-08-30 13:27:38 -04:00
Luca Bruno cfa2aec839
Merge pull request #2426 from cgwalters/xattrs-bareuseronly-union
checkout: Also ignore xattrs for union in bare-user-only mode
2021-08-27 07:34:46 +00:00
Luca Bruno 7fb0266df6
Merge pull request #2425 from cgwalters/hardlink-correct-errno
checkout: Save errno when re-throwing
2021-08-27 07:33:27 +00:00
Colin Walters dd506fe2c8 checkout: Also ignore xattrs for union in bare-user-only mode
Followup to PRs related to https://github.com/ostreedev/ostree/issues/2410

Since the test suite now covers this the test was failing on
a Fedora SELinux enabled host where we see `security.selinux`
even if not in the commit.
2021-08-26 17:42:29 -04:00
Dan Nicholson 6e32084b67
Merge pull request #2422 from cgwalters/allow-none-detached
lib: Change read_commit_detached_metadata to be nullable
2021-08-26 13:33:23 -06:00
Colin Walters 87d115706e checkout: Save errno when re-throwing
I was seeing an `EPERM`  here which was confusing.
It turned out the real error was `EEXIST`.

Since we're referring to the original error, but we do a
lot of computation in the middle, we need to save errno.
2021-08-26 15:17:36 -04:00
Colin Walters 3e30e72d33 lib: Change read_commit_detached_metadata to be nullable
Hit this while working on some Rust code.
2021-08-25 21:29:51 -04:00
Luca BRUNO c64b4bceba
lib: improve transactions auto-cleanup logic
This fixes some aspects of OstreeRepoAutoTransaction and re-aligns
it with the logic in flatpak. Specifically:
 * link to the underlying repo through refcounting
 * bridge internal errors to warning messages
 * verify the input pointer type

This is a preparation step before exposing this logic as a public API.
2021-08-25 16:17:52 +00:00
Luca BRUNO 3e2360e3bb
lib/commit: automatically skip xattrs in bare-user-only mode 2021-08-24 07:56:46 +00:00
Luca BRUNO f75552e15c
builtins/commit: set up relevant flags in bare-user-only mode
This detects bare-user-only mode and automatically enables a
commit modifier with relevant flags.
2021-08-24 07:56:19 +00:00
Luca BRUNO 0276f4dc0c
lib/diff: automatically skip xattrs in bare-user-only mode 2021-08-24 07:56:18 +00:00
Dan Nicholson 58a683f8f0 bin/remote: Rename list-gpg-keys to gpg-list-keys
As pointed out in the original review, `gpg-list-keys` fits better
alongside the existing `gpg-import`.

Changes were done with:

```
git grep -l list-gpg-keys | xargs sed -i 's/list-gpg-keys/gpg-list-keys/'
for src in $(git ls-files '*list-gpg-keys*'); do
  dst=${src/list-gpg-keys/gpg-list-keys}
  git mv "$src" "$dst"
done
```
2021-08-23 15:30:31 -06:00
Luca BRUNO 06ff77cfeb
lib/diff: ignore xattrs if disabled on either repos
This fixes the logic to detect whether xattrs should be automatically
ignored when diffing.
2021-08-23 13:31:13 +00:00
Colin Walters 2f675cf1b1
Merge pull request #2412 from lucab/ups/lib-commit-canonicalize
lib/commit: autofix permissions for bare-user-only
2021-08-20 15:12:21 -04:00
Colin Walters 98f3fe3d8e
Merge pull request #2401 from dbnicholson/gpg-key-info
Remote GPG key info
2021-08-20 15:11:11 -04:00
Luca BRUNO 8a5241dd6a
lib/commit: autofix permissions for bare-user-only
This tweaks commit logic to detect bare-user-only repositories and
canonicalize permissions automatically.
2021-08-20 16:11:04 +00:00
Luca BRUNO d41fcd17a7
lib/repo/checkout: use canonical perms in bare-user-only mode
This automatically enables canonical permissions for checkouts in
bare-user-only mode.
2021-08-19 16:09:54 +00:00
Luca BRUNO c6b72f527b
lib/core/checksum: add flag to use canonical permissions
This adds a new `OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS`
checksumming flag, which is needed in bare-user-only mode
to ignore local IDs.
2021-08-19 14:08:36 +00:00
Colin Walters cac4f2133b
Merge pull request #2414 from lucab/ups/cli-commit-modifier-autoptr
builtins/commit: move commit modifier to auto-cleanup
2021-08-18 09:10:17 -04:00
Luca BRUNO b079c11381
builtins/commit: move commit modifier to auto-cleanup
This reduces the usage of goto cleanup logic by porting the commit
modifier pointer to autoptr.
2021-08-18 09:06:26 +00:00
Luca BRUNO 5a3d5fb86f
builtins/commit: check for conflicting permissions options
This explicitly checks for commit command options asking for both
non-zero UID/GID and canonical permissions at the same time,
which are incompatible.
2021-08-18 08:16:26 +00:00
Jonathan Lebon 0f95e4e5ee ostree/dump: Fix free'ing a static string
Reported-by: Seth Arnold <seth.arnold@canonical.com>
2021-08-03 16:49:49 -04:00
Jonathan Lebon 738831c50b lib/sysroot: Fix error message about creating `/var/lib`
Reported-by: Seth Arnold <seth.arnold@canonical.com>
2021-08-03 16:49:49 -04:00
Jonathan Lebon 75b17937cf lib/sign-dummy: Handle incorrect signatures correctly
We need to check all signatures for one which passes, not just fail on
the first one.

Reported-by: Seth Arnold <seth.arnold@canonical.com>
2021-08-03 16:49:49 -04:00
刘建强 28174970c7 fix: Avoid wild pointers
Pointer command is dangerous if there is no assignment.

Log: Avoid wild pointers
2021-07-28 09:40:37 +08:00
Dan Nicholson 81df5c8aba fixup! lib/repo: Add ostree_repo_remote_get_gpg_keys() 2021-07-15 17:03:45 -06:00
Dan Nicholson 814e481fff fixup! bin/remote: Add list-gpg-keys subcommand 2021-07-15 16:25:13 -06:00
Dan Nicholson 30c054b521 fixup! lib/repo: Add ostree_repo_remote_get_gpg_keys() 2021-07-15 16:24:36 -06:00
Dan Nicholson 90a3bda1f8 bin/remote: Include update URLs in list-gpg-keys 2021-07-15 15:50:04 -06:00
Dan Nicholson 27dc5d7d38 lib/repo: Include WKD update URLs in GPG key listing
If the key UID contains a valid email address, include the GPG WKD
update URLs in GVariant returned by ostree_repo_remote_get_gpg_keys().
2021-07-15 15:50:04 -06:00
Dan Nicholson 4fa403aee5 libotutil: Add helper for GPG WKD update URLs
Calculate the advanced and direct update URLs for the key discovery
portion[1] of the OpenPGP Web Key Directory specification, and include
the URLs in the key listing in ostree_repo_remote_get_gpg_keys(). These
URLs can be used to locate updated GPG keys for the remote.

1. https://datatracker.ietf.org/doc/html/draft-koch-openpgp-webkey-service#section-3.1
2021-07-15 15:50:04 -06:00
Dan Nicholson fbff05e28d libotutil: Import implementation of zbase32 encoding
This will be used to implement the PGP Web Key Directory (WKD) URL
generation. This is a slightly cleaned up implementation[1] taken from
the zbase32 author's original implementation[2]. It provides a single
zbase32_encode API to convert a set of bytes to the zbase32 encoding.

I believe this should be acceptable for inclusion in ostree. The license
in the source files is BSD style while the original repo LICENSE file
claims the Creative Commons CC0 1.0 Universal license, which is public
domain.

1. https://github.com/dbnicholson/libbase32/tree/for-ostree
2. https://github.com/zooko/libbase32
2021-07-15 15:50:04 -06:00
Dan Nicholson 74fb0c5f78 bin/remote: Add list-gpg-keys subcommand
This provides a wrapper for the `ostree_repo_remote_get_gpg_keys`
function to show the GPG keys associated with a remote. This is
particularly useful for validating that GPG key updates have been
applied. Tests are added, which checks the
`ostree_repo_remote_get_gpg_keys` API by extension.
2021-07-15 15:50:04 -06:00
Dan Nicholson a50f6d0b9f lib/repo: Add ostree_repo_remote_get_gpg_keys()
This function enumerates the trusted GPG keys for a remote and returns
an array of `GVariant`s describing them. This is useful to see which
keys are collected by ostree for a particular remote. The same
information can be gathered with `gpg`. However, since ostree allows
multiple keyring locations, that's only really useful if you have
knowledge of how ostree collects GPG keyrings.

The format of the variants is documented in
`OSTREE_GPG_KEY_GVARIANT_FORMAT`. This format is primarily a copy of
selected fields within `gpgme_key_t` and its subtypes. The fields are
placed within vardicts rather than using a more efficient tuple of
concrete types. This will allow flexibility if more components of
`gpgme_key_t` are desired in the future.
2021-07-15 15:50:04 -06:00
Dan Nicholson fc073654dc lib/repo: Allow preparing GPG verifier without global keyrings
Currently the verifier decides whether to include the global keyrings
based on whether the specified remote has its own keyring or not. Allow
callers to exclude the global keyrings even when that's not the case.
This will be used in a subsequent commit in order to get the GPG keys
only associated with a remote.
2021-07-15 15:50:04 -06:00
Dan Nicholson c8715c123e lib/repo: Factor out GPG verifier preparation
In order to use the GPG verifier, it needs to be seeded with GPG keys
after instantation. Currently this is only used for verifying data, but
it will also be used for getting a list of trusted GPG keys in a
subsequent commit.
2021-07-15 15:50:04 -06:00
Dan Nicholson dba2cdcbac lib/repo: Factor out GPG verifier key imports
Currently the verifier only imports all the GPG keys when verifying
data, but it would also be useful for inspecting the trusted keys.
2021-07-15 15:50:04 -06:00
Luca BRUNO 38c14b3745
Release 2021.3 2021-07-12 08:38:38 +00:00
Jonathan Lebon 301b52704e ostree-remount: Order before systemd-rfkill.*
The `systemd-rfkill.*` service falls in the category of early things
that need write access to `/var`, so we need to make sure we run before
or it might hit the read-only sysroot.

The long-term fix for this is
https://github.com/ostreedev/ostree/issues/2115.

Closes: https://github.com/coreos/fedora-coreos-tracker/issues/746
2021-06-22 11:22:47 -04:00
Luca BRUNO 70a8f56ce1
lib/commit: respect SOURCE_DATE_EPOCH for commit timestamp
This tweaks `ostree_repo_write_commit` so that it checks for the
envinroment variable `SOURCE_DATE_EPOCH` as a way to override
the current time, which is used as the commit timestamp.

Ref: https://reproducible-builds.org/docs/source-date-epoch/
Ref: https://reproducible-builds.org/specs/source-date-epoch/
2021-06-22 12:15:18 +00:00
Dan Nicholson d9ef76a598 Don't fail build when systemd unit path not defined
In configure the systemd unit path is optional, but in the code it's
assumed to be defined. Add an `#ifdef` that throws an error when it's
not defined like the handling of `HAVE_LIBMOUNT` below it.
2021-06-18 12:35:41 -06:00