Commit Graph

6678 Commits

Author SHA1 Message Date
Eric Curtin
b258375f05
Merge pull request #2938 from cgwalters/dedup-ostree-parsing
generator: Deduplicate ostree= karg parsing
2023-07-18 14:35:45 +01:00
Eric Curtin
b548ff74a2
Merge pull request #2939 from cgwalters/ed25519-cleanups
sign-ed25519: Minor cleanups
2023-07-18 14:33:58 +01:00
Colin Walters
6966979c5e generator: Deduplicate ostree= karg parsing
Avoid having two copies of a regular expression for parsing
the `ostree=` kernel argument.  Because the `ostree-system-generator`
binary already has access to the internals because it's implemented
in the shared library, expose the sysroot version internally
and use that.

Motivated by an attempt to change one of these copies but not
the other.
2023-07-18 08:29:09 -04:00
Colin Walters
fc303da67d sign-ed25519: Don't set sk unless we've validated it
The semantics of this function now keep the key assigned
even if we fail to validate it, which is ugly.  Only assign
the key after verifying its length.
2023-07-18 08:25:36 -04:00
Colin Walters
3a18a5570d sign-ed25519: Add some comments for data structure
Like poor man's generics.
2023-07-18 07:55:14 -04:00
Colin Walters
fb40e55990 sign-ed25519: More verbose errors for invalid length
Add a helper to compare lengths which includes the found
and expected values.  Use it consistently.

The error message "Incorrect" is misleading; one might think
one had the *wrong* key.  "Ill-formed" makes it clearer that
we're not parsing it at all.
2023-07-18 07:55:14 -04:00
Colin Walters
1a2fac371b tests: Remove dead references to "SEED"
Nothing uses this.
2023-07-18 07:55:14 -04:00
Colin Walters
1c0fd7d458
Merge pull request #2937 from ericcurtin/ostree2androidboot.slot_suffix
android-boot: Remove dependency on ostree= karg, use androidboot.slot_suffix=
2023-07-17 09:46:02 -04:00
Eric Curtin
355cd72705 Remove steal_pointer and steal_pointer_impl as we link in glib now
These were necessary to keep initramfs small, but now we link in glib
anyway so these functions are now redundant.
2023-07-17 13:23:27 +01:00
Eric Curtin
a6f0a57134 android-boot: Remove dependency on ostree= karg, use androidboot.slot_suffix=
Given the kernel argument androidboot.slot_suffix= is required in
Android AB updates [1] there is no need to check for ostree= or ostree=aboot
at all in the aboot case. This also ensures if the dependancy on ostree=
is removed, the android-boot technique will work regardless.

[1]: https://source.android.com/docs/core/ota/ab/ab_implement
2023-07-17 13:22:49 +01:00
Eric Curtin
27a9fe30b3
Merge pull request #2936 from cgwalters/sign-from-file
commit: Add `--sign-from-file`
2023-07-16 22:22:20 +01:00
Eric Curtin
7bbe13cabb
Merge pull request #2931 from cgwalters/prepare-root-man
man: Add ostree-prepare-root
2023-07-16 21:59:32 +01:00
Eric Curtin
de81a7e71a
Merge pull request #2929 from cgwalters/prepare-root-drop-pivot
prepare-root: Drop dead `pivot_root` code
2023-07-15 17:33:56 +01:00
Eric Curtin
8302a8add0
Merge pull request #2927 from cgwalters/sysroot-errprefix-bootlinks
sysroot: Add some error prefixing for bootversion
2023-07-15 17:31:53 +01:00
Colin Walters
845d68d1d4
Merge pull request #2935 from cgwalters/prepare-root-config4
prepare-root: Refactor composefs config handling
2023-07-15 09:52:11 -04:00
Colin Walters
82d934916b commit: Add --sign-from-file
Passing the private key via a direct command line argument
is just a bad idea because it's highly likely to get logged
or appear in `ps`.
Spotted in review of work for composefs signatures.
2023-07-15 09:50:40 -04:00
Colin Walters
d4ca834b09 prepare-root: Refactor composefs config handling
- Convert the current enum into a struct, using `OtTristate` and
  two member variables (expected signature and digest)
- Factor out a helper function to parse this config
- Clean up the logging by consistently using `composefs:` as a prefix
- Add more assertions to more strictly verify our runtime state
  since this is security relevant
2023-07-14 14:37:03 -04:00
Eric Curtin
18d6f59793
Merge pull request #2934 from cgwalters/enable-composefs-default
build-sys: Enable composefs at *build time* by default
2023-07-14 16:40:42 +01:00
Colin Walters
592351d1b0 build-sys: Enable composefs at *build time* by default
There's no additional dependencies, and it's a small amount
of new code.

The riskiest thing is the changes to ostree-prepare-root, but
I believe that things are in a good state now there.

Again, this just enables it at *build time* - it's still
off at runtime by default.
2023-07-14 10:34:46 -04:00
Colin Walters
3d29f89c0e
Merge pull request #2928 from cgwalters/prepare-root-config
More prepare-root cleanups
2023-07-14 10:26:25 -04:00
Eric Curtin
c1ac6bc346
Merge pull request #2932 from cgwalters/aboot-fix-nullderef
mount: Fix gcc -fanalyzer warning for parsing androidboot.slot_suffix
2023-07-14 13:48:17 +01:00
Colin Walters
c078e8bea3 mount: Fix gcc -fanalyzer warning for parsing androidboot.slot_suffix
If the karg wasn't present, we'd do a NULL deref which is undefined
behavior.
2023-07-14 06:51:34 -04:00
Colin Walters
c4f1d18a30
Merge pull request #2920 from ostreedev/dependabot/submodules/composefs-1704f82
build(deps): bump composefs from `ac729b5` to `1704f82`
2023-07-13 17:53:10 -04:00
Colin Walters
1e4cb30c68 man: Add ostree-prepare-root
Add an overdue man page that describes this.  Prep for also
documenting composefs things here.
2023-07-13 17:24:52 -04:00
Colin Walters
0eda15ceff Use /run/ostree-booted metadata for sysroot-ro state passing
Just like we did with composefs, use the new metadata instead
of a "stamp file".
2023-07-13 13:58:25 -04:00
Colin Walters
79806a683e prepare-root: Drop dead pivot_root code
I think this was only ever used in the "static pid1" path which
is now split out into a separate file.

We always expect that e.g. systemd does the switchroot in
the initramfs, so drop this dead code.
2023-07-13 08:28:49 -04:00
Colin Walters
b8d66964a8 remount: Use new metadata in /run/ostree-booted for composefs
Since we now have a generalized more structured way of serializing
state in the initramfs instead of "stamp files", use it for
passing the composefs state.
2023-07-13 07:57:18 -04:00
Colin Walters
77acad246e remount: Don't overwrite /run/ostree-booted
Since it should always be written in the initramfs.
2023-07-13 07:28:39 -04:00
Colin Walters
93699cc546 prepare-root: Add metadata for composefs to /run/ostree-booted
Particularly for the signature case, having this metadata
acts as a reliable "proof of execution" of the signature verification
code (as opposed to parsing a log file or so).

Besides that, this is also just a stronger check for "we're using
composefs" instead of checking for "overlayfs on /".
2023-07-13 07:28:39 -04:00
Colin Walters
bafb551275 prepare-root: Use constant for ed25519 signature
Minor cleanup.
2023-07-13 07:28:39 -04:00
Colin Walters
6cdc5ce595
Merge pull request #2926 from cgwalters/otcore-cfs-constants
prepare-root: A few cleanups
2023-07-13 07:10:59 -04:00
Colin Walters
6769d66dcc sysroot: Add some error prefixing for bootversion
This came up in https://issues.redhat.com/browse/OCPBUGS-15955
and I'm 90% sure it's this readlink failing, but let's make
it extra clear.
2023-07-12 19:29:20 -04:00
Colin Walters
18cc447230 prepare-root: Drop unused verity flag querying
This logic got pushed down into libcomposefs.
2023-07-12 07:56:17 -04:00
Colin Walters
2b738a995d prepare-root: Use otutil and g_print
Now that we link to libotutil (and glib) we don't need separate
handling for conditionalizing on the presence of systemd.

Further, there's no value in `sd_journal_send(MESSAGE=)` over
just printing to stdout.
2023-07-12 07:56:17 -04:00
Colin Walters
1b7b4fbd2b Add an internal constant for the composefs image name
Just a minor cleanup.
2023-07-11 17:50:43 -04:00
Dan Nicholson
c0c2c9bd80
Merge pull request #2924 from cgwalters/drop-syntax-check
build: Drop `make syntax-check`
2023-07-11 13:31:14 -06:00
Colin Walters
6591210661 build: Drop make syntax-check
As of lately it emits a ton of errors from `grep` about having `*`
at the start of a line, but more generally it's only generally
found papercut-style issues that aren't worth carrying a distinct
checking system for.
2023-07-11 14:17:05 -04:00
Colin Walters
57fe33f07e
Merge pull request #2921 from alexlarsson/composefs-sign-v2
ostree-prepare-root: Validate ed25519 signatures when requested
2023-07-11 14:09:07 -04:00
Alexander Larsson
c29f4193cd ostree-prepare-root: Validate ed25519 signatures when requested
If requested, by specifying ot-composefs=signed=/path/to/pub.key then
the commit object is validated against the specified ed25519 public
key, and if valid, the composefs digest from the commit object is used
to ensure we boot the right digest.
2023-07-11 14:08:33 -04:00
Colin Walters
b8ff210941 Factor out a libotcore
This will contain logic shared between ostree-prepare-root
and libostree-1.so.  It will just link to libgio.so, so as
to avoid pulling in e.g. libcurl and other things.

In other words, `ostree-prepare-root` will not link to `libostree-1.so`,
but will pull in just what it needs from this library.
2023-07-11 14:08:32 -04:00
Colin Walters
265cf7d786 build-sys: Add libsodium to OT_DEP_CRYPTO
There's no reason to have these distinct really.  If we're using
libsodium, we want it in the same places we're using openssl.

Prep for further refactoring.
2023-07-08 15:42:12 -04:00
Colin Walters
a6d9c714c6
Merge pull request #2922 from alexlarsson/openssl-ed25519
Implement ed255519 using openssl too
2023-07-07 15:25:27 -04:00
Alexander Larsson
744967a6e4 libotutil: Link to crypto libs
The checksum utils uses the crypto lib, but we're not explicitly linking
to it. I think this is why the CI got this error when using openssl
on debian, during ostree binary linking:

/usr/bin/ld: ./.libs/libotutil.a(libotutil_la-ot-checksum-utils.o): undefined reference to symbol 'EVP_DigestInit_ex@@OPENSSL_3.0.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcrypto.so.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
2023-07-07 20:19:59 +02:00
Alexander Larsson
474c2b100b CI: Enable --with-crypto=openssl on debian testing to test openssl signatures 2023-07-07 17:16:30 +02:00
Alexander Larsson
7b85adfbbd sign-ed25519: Implement sign and verify using openssl
libsodium is used if configured to keep the old behaviour, but if
it is not enabled, and openssl is used, then ed25519 is now supported.
2023-07-07 17:16:30 +02:00
Alexander Larsson
501575c1e4 sign-ed25519: Drop some uses of libsodium
This adds some defines for ed25519 key sizes and drops uses
of the libsodium defines for these, as well as replacing sodium_bin2hex
use with ot_bin2hex. Some code that wes optionally built before are now
always built.

The goal for this is to support both libsodium and openssl.

Also fixes return value of _load_pk_from_stream(). It used
to always return FALSE.
2023-07-07 17:16:30 +02:00
Colin Walters
5b7277513b
Merge pull request #2923 from alexlarsson/fix-composefs-test
tests: Fix composefs test
2023-07-07 11:12:52 -04:00
Alexander Larsson
62e4f37653 tests: Fix composefs test
- Was using the wrong metadata key
- We were missing setting the canonical commit args which assigns
  e.g. owner uid 0, which is important for reproducibility
- Use the new --print-hex to make things easier to read
2023-07-07 09:57:00 -04:00
Colin Walters
eb01112083 show: Add --print-hex
The default GVariant output for byte arrays is illegible to humans,
and byte arrays are super common for us.
2023-07-07 09:22:30 -04:00
Joseph Marrero Corchado
6056ec130f
Merge pull request #2913 from cgwalters/tmpfile-not-on-revokefs
fetcher: Always open tmpfiles in repo (except on FUSE)
2023-07-05 20:00:30 -04:00