Commit Graph

2496 Commits

Author SHA1 Message Date
Miguel Angel Ajo e234b630f8 Support overlayfs whiteouts on checkout
Introduces an intermediate format for overlayfs storage, where
.wh-ostree. prefixed files will be converted into char 0:0
whiteout devices used by overlayfs to mark deletions across layers.

The CI scripts now uses a volume for the scratch directories
previously in /var/tmp otherwise we cannot create whiteout
devices into an overlayfs mounted filesystem.

Related-Issue: #2712
2022-09-28 12:26:31 +02:00
Luca BRUNO ace973186c
lib/sign: convert invariant checks to assertions
This converts several invariant checks to asserts. Most of the
functions in this file were already using assertions, so this aligns
the remaining few outliers to the rest.
2022-09-09 13:20:43 +00:00
Luca BRUNO 542b79cfeb
otutil: add error handling to variant builders
This enhances a bunch of helpers related to GVariant building, in
order to properly handle errors and avoid some potential cases of
unexpected NULL results.
2022-09-08 13:53:05 +00:00
Colin Walters 6873a2511b
Merge pull request #2708 from nikita-dubrovskii/sh_to_c
s390x: drop shell code for `initrd` modification in SE case
2022-09-08 07:45:04 -04:00
Nikita Dubrovskii c6a53ef6e8 s390x: use 'libarchive' to modify initrd in SE case 2022-09-08 11:41:34 +02:00
Luca BRUNO 642efe924f
lib/mtree: drop redundant name checks
This drops several NULL checks against filename input argument.
Those checks are both redundant (as filename validation already
checks for that) and dangerous (as they return early without
setting an error value).
2022-09-07 12:33:37 +00:00
Luca Bruno 73eda79662
Merge pull request #2707 from lucab/ups/libostree-bootloader-asserts
lib/bootloader: assert invariants
2022-09-06 00:36:11 +00:00
Nikita Dubrovskii 769ac686f1 s390x: simplify 's390x-se-luks-gencpio' script 2022-09-05 12:08:35 +02:00
Luca BRUNO 273089d9e4
lib/bootloader: assert invariants
This tweaks some invariants checks into full assertions, in order
to avoid returning to the caller in case of known invalid states.
2022-09-05 09:27:38 +00:00
Nikita Dubrovskii 49ce9b0289 s390x: ensure both 'root' and 'boot' luks keys exist 2022-09-05 10:46:13 +02:00
git-bruh 35d6ea88f6
ostree-fetcher-curl: check for HTTP2 support before trying to use it 2022-09-03 12:50:00 +05:30
Huijing Hei 37aa2ac287 Fix `ostree admin kargs edit-in-place` assertion when deployments
are pending

This is to support pending deployments instead of rasing assertion.
For example:
```
$ sudo rpm-ostree kargs --append=foo=bar
$ sudo ostree admin kargs edit-in-place --append-if-missing=foobar
```
After reboot we get both `foo=bar foobar`.

Fix https://github.com/ostreedev/ostree/issues/2679
2022-08-29 11:31:32 +08:00
Colin Walters fb826346fe
Merge pull request #2692 from GeorgesStavracas/gbsneto/transaction-leak
lib/commit: Unref repo on success
2022-08-22 14:25:07 -04:00
Luca BRUNO ff7d9a8a6d
libostree: fix a typo in annotation
This fixes a typo in the `allow-none` annotation on
`ostree_sysroot_deployment_set_kargs_in_place` argument.
2022-08-19 10:39:09 +00:00
Georges Basile Stavracas Neto 092421fabf lib/commit: Unref repo on success
Commit 540e60c3 introduced _ostree_repo_auto_transaction_new(), a
private constructor to OstreeRepoAutoTransaction, by factoring out
some code from _ostree_repo_auto_transaction_start(). This factored
code increased the refcount of the 'repo' variable.

Subsequent commit 71304e854c made ostree_repo_prepare_transaction()
use ths newly introduced constructor. However, in this function, the
happy path assumed no ref was taken, and therefore did not unref it.
Commit 71304e854c didn't add the corresponding unref either.

This leaks a reference to OstreeRepo when calling
ostree_repo_prepare_transaction().

Plug this leak by using g_clear_object() to clear the repo field
of OstreeRepoAutoTransaction, instead of simply setting it to NULL.

Closes https://github.com/flatpak/flatpak/issues/4928
2022-08-16 19:54:29 -03:00
Jonathan Lebon 93e47f88f4 lib/commit: Directly use FICLONE for payload link
The idea of payload linking is to reflink between objects where
possible. Instead of relying on `glnx_regfile_copy_bytes` to hit the
`FICLONE` path, just call `FICLONE` directly. At that point in the code,
we've already established that the source and dest repos are on the same
filesystem and that it supports `FICLONE`.

Related: https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/41
Related: https://github.com/ostreedev/ostree/pull/2684#issuecomment-1204068437
2022-08-15 14:00:08 -04:00
Colin Walters 0a908a180f Move FIFREEZE/FITHAW ioctl invocations into linuxfsutil.c
Should help avoid conflicts between glibc and linux headers.

Closes: https://github.com/ostreedev/ostree/issues/2685
2022-08-03 10:44:51 -04:00
Colin Walters edba4b33be Remove unused `linux/fs.h` includes
Prep for fixing conflicts introduced by newer glibc.
cc https://github.com/ostreedev/ostree/issues/2685
2022-08-03 10:37:40 -04:00
Colin Walters 15740d042c Release 2022.5 2022-07-22 15:08:25 -04:00
Colin Walters 83e6357186 sign/ed25519: Verify signatures are minimum length
The ed25519 signature verification code does not
check that the signature is a minimum/correct length.
As a result, if the signature is too short, libsodium will end up
reading a few bytes out of bounds.

Reported-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Co-authored-by: Demi Marie Obenour <demi@invisiblethingslab.com>

Closes: https://github.com/ostreedev/ostree/security/advisories/GHSA-gqf4-p3gv-g8vw
2022-07-14 17:13:51 -04:00
Colin Walters ed1146738b
Merge pull request #2669 from HuijingHei/fix-kargs
Fix `ostree admin kargs edit-in-place` fails issue
2022-07-13 16:35:28 -04:00
Colin Walters a3749efb1a
Merge pull request #2672 from cgwalters/initialize-sysroot-cleanups
sysroot: Have `ensure_writable` also always initialize
2022-07-13 16:35:17 -04:00
Colin Walters 60853219d5 sysroot: Add a few more assertions about `boot_fd`
These places are all safe, but it would catch bugs in the future
more clearly to trip an assertion here.
2022-07-13 15:38:59 -04:00
Colin Walters 75aa7a22f6 sysroot: Have `ensure_writable` also always initialize
For historical reasons we have a fair bit of distinct sysroot
initialization going on.  A lot of code is calling *just* the new
`ensure_writable()` API, which does basically what you'd expect...
except if we're not using a mount namespace.

Which is the case in unit tests and legacy setups.
Change this API to also ensure the sysroot is fully initialized
even in those cases.  Specifically we'll have `self->sysroot_fd`.

For now, callers that need `/boot` also need to separately
call `_ensure_boot_fd()`.
2022-07-13 15:35:00 -04:00
Colin Walters 2c71655205 deploy: Ensure sysroot is initialized for kargs in place
Even without a mount namespace set up.
2022-07-13 15:32:05 -04:00
Huijing Hei 7b7b6d741b Fix `ostree admin kargs edit-in-place` fails issue
Add func to set kernel arguments in place, instead of create new
deployment
Fix https://github.com/ostreedev/ostree/issues/2664
2022-07-12 16:27:00 +08:00
Saqib Ali d7107e3036 ostree-repo: bls-append-except-default followup
This PR is followup from https://github.com/coreos/coreos-assembler/pull/2863
Summary of changes:
- Moved bls-append-except-default parsing logic to reload_sysroot_config()
- Made sure heap allocated memory is being freed
2022-07-07 16:06:11 -04:00
Colin Walters becc18936f lib: Stop using old `ostree_sysroot_get_repo()` API
It's falliable, and in one place we were actually ignoring
the error and leaving a `NULL` repo object which is just a trap
for people coming along later since it's rarely nullable.

Quite a while ago we switched to loading the repo at the same time
as the sysroot; convert callers in the library to use this infallible
accessor.

Prep for another patch which will use the repo object.
2022-07-06 07:47:57 -04:00
Colin Walters 0d911bf91f
Merge pull request #2632 from saqibali-2k/pr/prune-commit-only
lib/prune: speed up pruning by retrieving only commits
2022-06-30 09:08:54 -04:00
Saqib Ali a984871237 lib/prune: speed up pruning by retrieving only commits
After landing the new --commit-only functionality, we still noticed
exceedingly long pruning times in large repos. Lets add an optimization
that will only retrieve commit objects when --commit-only flag is used.
2022-06-27 08:04:50 -04:00
Nikita Dubrovskii 14a7c0c74b s390x: rename sd-boot to sdboot
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-06-24 15:15:57 +02:00
Huijing Hei 3bc59a5206 RFE: Add a hidden option to `ostree admin kargs edit-in-place` to
update all existing deployments in place

Example:
$ sudo ostree admin kargs edit-in-place --append-if-missing=rw
See https://github.com/ostreedev/ostree/issues/2617

This will not add duplicate key, if there is `TESTARG=VAL1` in the
kernel arguments, `--append-if-missing=TESTARG=VAL2` will be ignored.
2022-06-23 22:31:39 +08:00
Colin Walters a13d812368 repo: Document non-obvious way to list all commits
I was going to add an API for this and then realized the empty
string does it.
2022-06-09 18:34:51 -04:00
Joseph Marrero Corchado a6ecd96cda
Merge pull request #2638 from cgwalters/fix-symbol-versioning
lib: Fix symbol versioning inheritance
2022-06-08 17:17:28 -04:00
Colin Walters 145d91d1c9 lib: Fix symbol versioning inheritance
I messed this up; the last release should inherit from the previous
release (N-1) and not the previous to that (N-2).

I think (hope) this isn't an ABI break...

Just noticed this when I was going to add a new symbol.
2022-06-08 16:44:51 -04:00
Colin Walters fffb111633 prune: Also use object set API in `ostree_repo_prune_from_reachable()`
I missed the second prune path when working on
https://github.com/ostreedev/ostree/pull/2635
2022-06-08 16:22:26 -04:00
Colin Walters a71915e436 repo: Further optimize `ostree_repo_list_objects_set()`
In a prior change we discovered that for bad historical reasons
libostree was returning a mapping "object type+checksum" => "metadata"
but the "metadata" was redundant and pointless.

Optimize the prune API to use a (currently internal) object listing
API which returns a set, not a map.  This allows `GHashTable` to
avoid allocating a separate array for the values, neatly cutting
memory usage in half (from ~13MB to ~6MB) on my test case of a
dry-run prune of a FCOS build.
2022-06-08 10:18:55 -04:00
Colin Walters c2baa6d10b repo: Optimize memory use of `ostree_repo_list_objects()`
I was looking at https://github.com/ostreedev/ostree/pull/2632
and confused at the usage of
`GVariant *value = g_variant_new ("(b@as)", TRUE, g_variant_new_strv (NULL, 0));`
which looked strange - why the empty strv?

It turns out that this is a historical legacy of the time when
ostree had pack files.  And nothing actually cares about the values
of these variants; we should have an API that returns a proper set,
and not a hash.

But...since all of these things have exactly the same value, instead
of allocating lots of redundant copies on the heap, just have
them all hold a refcount on a shared value.

This cuts the heap usage from 20MB to 13MB on a test FCOS repository
build.
2022-06-07 20:35:37 -04:00
Colin Walters 5fa364d399 Release 2022.4 2022-06-06 11:04:44 -04:00
Joseph Marrero Corchado 8bd1c88013
Merge pull request #2625 from cgwalters/drop-features-introspection
Drop `OSTREE_BUILT_FEATURES` from introspection
2022-06-03 09:22:48 -04:00
Colin Walters 3e645ad950 Drop `OSTREE_BUILT_FEATURES` from introspection
It inherently depends on the individual build, and can't
really be an official stable API for introspection users.
I've noticed the value of this flip flop when doing local builds.

I'm fairly certain no one is trying to use it from a higher level
language.

It'd probably make sense to even drop from the official C API,
but I'm trying to be conservative with that.
2022-06-02 19:44:40 -04:00
Colin Walters 32ee82133b Rename ostree-cmdprivate to drop out of introspection
I was looking at our `.gir` and noticed we had the cmdprivate bits
because the pattern for excluding headers is `-private.h`, which
didn't match `cmdprivate.h`.
2022-06-02 17:13:17 -04:00
James Westman 03d592b116
Fix annotations on ostree_mutable_tree_lookup()
(nullable) and (optional) were missing on lookup()'s out parameters,
which caused the rust bindings for the function to not work. Due to the
missing (nullable), it would return a Result<(GString, MutableTree), _>,
not a Result<(Option<GString>, Option<MutableTree>), _>, which led to
panics.
2022-05-30 17:36:07 -05:00
Nikita Dubrovskii 972f00e483 s390x: do not unpack existing initrd, just append LUKS keys to its copy
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-05-27 12:06:33 +02:00
Jonathan Lebon 9aca8816c6
Merge pull request #2615 from nikita-dubrovskii/handle_errors 2022-05-25 13:38:23 -04:00
Colin Walters 2363d3ad98
Merge pull request #2605 from saqibali-2k/pr/bls-append
ostree-systroot-deploy: parse bls-append-except-default key
2022-05-25 11:33:10 -04:00
Nikita Dubrovskii b03fa626f1 s390x: fail on error during reading of SecureExecution sysfs flag 2022-05-25 11:00:34 -04:00
Nikita Dubrovskii d000569859 s390x: ensure SecureExecution is enabled before sd-boot generation
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-05-23 18:24:43 +02:00
Saqib Ali 326d89752a ostree-systroot-deploy: parse bls-append-except-default key
We want to parse a new "bls-append-except-default" key from ostree config. The
key-value pairs specified by this key will be added to the generated
BLS fragments of non-default deployments. They must follow the format
"key1,value1;key2,value2" and so on.

This change will allow us to land GRUB password support in FCOS.

Relevant: https://github.com/coreos/fedora-coreos-tracker/issues/134
2022-05-19 09:59:38 -04:00
Nikita Dubrovskii 7a5c604ca3 s390x: generate sd-boot at its own partition
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-05-18 13:06:29 +02:00