Commit Graph

3664 Commits

Author SHA1 Message Date
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
Colin Walters 6a055f802f sysroot: Strengthen several `g_return_if_fail` into `g_assert()`
Similar to prior changes; motivated by testing out an updated
`gcc -fanalyzer`.
2022-05-16 11:00:08 -04:00
Colin Walters e27fed45fd sysroot: Quiet one gcc `-fanalyzer` warning
I don't think this can happen in practice, but add an assertion
to verify it.
2022-05-15 16:03:01 -04:00
Colin Walters f79b2cea91 Add APIs to get xattrs from disk
I'm aiming to do some more work on the Rust side around `fsck`
like functionality, and this is a useful primitive.  There isn't
a great Rust crate for xattrs, and I think it's better to share this
code.
2022-05-09 12:33:38 -04:00
Luca BRUNO 4b7fc4f1e9
lib/ostree-sysroot-deploy: add a missing include for stdint.h 2022-05-06 10:07:23 +00:00
Simon McVittie 71304e854c repo: Correctly initialize refcount of temporary transaction
Previously, the reference count was left uninitialized as a result of
bypassing the constructor, and the intended abort-on-error usually
wouldn't have happened.

Fixes: 8a9737a "repo/private: move OstreeRepoAutoTransaction to a boxed type"
Resolves: https://github.com/ostreedev/ostree/issues/2592
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-30 12:53:42 +01:00
Simon McVittie 540e60c3e3 repo: Factor out _ostree_repo_auto_transaction_new()
This will allow the direct allocation in
ostree_repo_prepare_transaction() to be replaced with a call to this
function, avoiding breaking encapsulation.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-30 12:20:11 +01:00
Colin Walters d3d3e4ea13 Add an `ostree-boot-complete.service` to propagate staging failures
Quite a while ago we added staged deployments, which solved
a bunch of issues around the `/etc` merge.  However...a persistent
problem since then is that any failures in that process that
happened in the *previous* boot are not very visible.

We ship custom code in `rpm-ostree status` to query the previous
journal.  But that has a few problems - one is that on systems
that have been up a while, that failure message may even get
rotated out.  And second, some systems may not even have a persistent
journal at all.

A general thing we do in e.g. Fedora CoreOS testing is to check
for systemd unit failures.  We do that both in our automated tests,
and we even ship code that displays them on ssh logins.  And beyond
that obviously a lot of other projects do the same; it's easy via
`systemctl --failed`.

So to make failures more visible, change our `ostree-finalize-staged.service`
to have an internal wrapper around the process that "catches" any
errors, and copies the error message into a file in `/boot/ostree`.

Then, a new `ostree-boot-complete.service` looks for this file on
startup and re-emits the error message, and fails.

It also deletes the file.  The rationale is to avoid *continually*
warning.  For example we need to handle the case when an upgrade
process creates a new staged deployment.  Now, we could change the
ostree core code to delete the warning file when that happens instead,
but this is trying to be a conservative change.

This should make failures here much more visible as is.
2022-04-26 13:02:46 -04:00
Colin Walters 4fd0d6b4c1 fetcher/curl: Consistently check return value `curl_easy_setopt`
Static analyzers don't like when we only check it sometimes.

And we definitely want to know if any of these are failing.
2022-04-20 15:16:22 -04:00
Colin Walters 2346d5f4d5 libarchive: Handle `archive_entry_symlink()` returning NULL
The `archive_entry_symlink()` API can definitely return `NULL`,
reading through the libarchive sources.

I hit this in the wild when using old ostree-ext to try to unpack
a chunked archive.

I didn't try to characterize this more, and sorry no unit test right
now.
2022-04-04 10:25:35 -04:00
Colin Walters c58a4fe661 deploy: Be a bit more verbose about SELinux bits
Let's log when we don't find the expected CLI argument which
will help debug things.
2022-03-28 17:46:59 -04:00
Ondrej Mosnacek edb4f38934 deploy: Try to rebuild policy in new deployment if needed
Whenever the user has SELinux enabled and has any local
modules/modifications installed, it is necessary to rebuild the policy
in the final deployment, otherwise ostree will leave the binary policy
files unchanged from last deployment as it detects difference against
the base content (in rpm-ostree case this is the RPM content).

To avoid the situation where the policy binaries go stale once any local
customization of the policy is made, try to rebuild the policy as part
of sysroot_finalize_deployment(). Use the special
--rebuild-if-modules-changed switch, which detects if the input module
files have changed relative to last time the policy was built and skips
the most time-consuming part of the rebuild process if modules are
unchanged (thus making this a relatively cheap operation if the user
hasn't made any modifications to the shipped policy).

As suggested by Jonathan Lebon, this uses bubblewrap (via
g_spawn_sync()) to perform the rebuild inside the deployment's
filesystem tree, which also means that ostree will have a runtime
dependency on bubblewrap.

Partially addresses: https://github.com/coreos/fedora-coreos-tracker/issues/701

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2022-03-28 17:18:03 -04:00
Daniel Kolesa aca9e8e6a7 glib: bump glib requirement to 2.66 and port to GUri
This removes the old SoupURI copypasta from previous generation
of libsoup and opens up a path for a simple libsoup3 port.
2022-03-12 04:44:18 +01:00
Colin Walters 0d020a7145 tmpfiles: Create `/run/ostree`
This is referenced by 9645cee4f2/lib/src/globals.rs (L16)
specifically used for the (container image) pull secret in
`/run/ostree/auth.json`.

Let's pre-create the directory so users don't have to.

Motivated by https://github.com/openshift/machine-config-operator/pull/3007#discussion_r824172564
2022-03-11 13:08:23 -05:00
Philip Withnall 8cc8e68768 ostree-repo-pull: Take correct out path on error
Like every other error return path in this function, jump to the `out`
label on error here. Returning directly will cause leaks.

Spotted by reading the code, not actually necessarily encountered in the
wild.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-08 15:36:27 +00:00
Simon McVittie a9a0110f44 s390x-se-luks-gencpio: Use interoperable path for bash
On OSs that do not consistently merge /usr/bin with /bin, the path to
bash has traditionally been /bin/bash.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-03-07 22:49:33 +00:00
Simon McVittie 084f8913f0 s390x-se-luks-gencpio: Fix shebang syntax
An indented `#!` is technically meaningless, although many shells will
run text files with the shell if asked to execute them.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-03-07 22:49:30 +00:00
Simon McVittie c27a45a449 New upstream version 2022.2 2022-03-07 19:15:17 +00:00
Colin Walters fbc6d21c2f Release 2022.2 2022-03-03 18:44:30 -05:00
Luca BRUNO 7e79b82ff8
lib/commit: disallow writing content in 'bare-split-xattrs' mode
This prevents writing content into 'bare-split-xattrs` repository,
while carving some space for experimenting via a temporary
`OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS` environment flag.
2022-03-02 16:45:02 +00:00
Luca BRUNO 14a6e6d8d0
lib/repo: read split xattrs content from file-xattrs-link objects 2022-03-02 16:45:01 +00:00
Luca BRUNO 08e98e9042
lib/core: introduce 'bare-split-xattrs' mode 2022-03-02 16:45:00 +00:00
Luca BRUNO 2c60f302f9
lib/core: introduce two new object types for split xattrs
This adds two new object types for storing xattrs separately from
content objects.

`.file-xattrs` are regular files storing xattrs content, encoded as
GVariant. Each object is keyed by the checksum of its content, allowing
for multiple references.

`.file-xattrs-link` are hardlinks which are associated to file objects.
Each object is keyed by the same checksum of the corresponding file
object. The target of the hardlink is an existing file-xattrs object.
In case of reaching the limit of too many links, this object could be
a plain file too.
2022-03-02 16:44:59 +00:00
Saqib Ali 725d50a3b5 src/ostree: Add --commit-only option to ostree prune
Recently we have noticed exceedingly long execution times
for multiple invocations of ostree prune. This is a result of
calculating full reachability on each invocation.

The --commit-only flag provides an alternative strategy. It will only
traverse and delete commit objects to avoid the more expensive
reachability calculations. This allows us to chain multiple --commit-only
commands cheaply, and then follow with a more expensive ostree prune
invocation at the end to clean up orphaned meta and content objects.
2022-02-25 18:32:25 -05:00
Jonathan Lebon 00e39ebedc
Merge pull request #2548 from cgwalters/mtree-load-ensured 2022-02-22 15:20:22 -05:00
Phaedrus Leeds c213dd3a84 lib/repo-refs: Remove misleading newline 2022-02-19 14:46:02 -06:00
Phaedrus Leeds 5d3b1ca37a Fix marking static delta commits as partial
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (https://github.com/flatpak/flatpak/issues/3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.
2022-02-19 08:11:23 -06:00
Colin Walters f36a940ed0 mtree: Load traversed subdirs when creating parents
I'm working on enhancing the ostree-rs-ext test suite and I hit
a bug where walking a mtree and creating a parent would fail to
load lazy intermediate directories, e.g.:

/ -> usr -> bin

If we walked we'd load `/` but keep `usr` lazy, and then invalidation
would crash because it wasn't loaded.

If we're going to mutate a subdir, we need to have all the parents
loaded.

I know this is missing tests, but...it's a bit tedious to do with
the existing C tests.  Eventually soon we'll execute on merging
all 3 repos, and better share test suites.
2022-02-18 10:30:27 -05:00
Colin Walters 929f62c59e mtree: Use declare-and-initialize style
Prep for further work.
2022-02-18 10:22:26 -05:00
Colin Walters 48104f76ee lib/tar: Add some error prefixing
We're trying to debug a problem with a tar stream with hardlinks,
and I think this will be helpful.
2022-02-15 15:33:04 -05:00
Colin Walters d61fdc7123
Merge pull request #2539 from chergert/main
lib/bootloader: use ot_journal_print() instead of sd-journal
2022-02-12 09:04:43 -05:00
Christian Hergert 6419c32334 lib/bootloader: use ot_journal_print() instead of sd-journal
This needs to use the helper so that USE_LIBSYSTEMD still works as
expected.
2022-02-11 15:40:26 -08:00
Christian Hergert 5d08032aec lib/util: add syslog.h for ot_journal_print()
If we aren't including sd-journal, we may need this too.
2022-02-11 15:40:19 -08:00
Colin Walters bea8d9a2b4
Merge pull request #2538 from cgwalters/dirmeta-not-floating
core: Mark `ostree_create_directory_metadata` as `(not nullable)`
2022-02-11 18:01:49 -05:00
Colin Walters 5f2ab097d5
Merge pull request #2491 from nikita-dubrovskii/secure-execution
s390x: add secure-execution support
2022-02-11 15:34:55 -05:00
Colin Walters ea5f7b0f38 core: Mark `ostree_create_directory_metadata` as `(not nullable)`
So I can drop an unnecessary use of `unwrap()` in Rust.
2022-02-11 14:09:49 -05:00
Nikita Dubrovskii d1ab18f327 s390x: add LUKS keyfile to 'sd-boot'
This allows to use Secure Execution with LUKS encrypted boot disk,
key and cryptab are stored only in 'sd-boot' encrypted image.

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-02-11 09:02:42 +01:00
Nikita Dubrovskii c27b98a2cb s390x: add "IBM Secure Execution for Linux" support
If system contains ibm-z-hostkey (fetched during ignition), than
ostree generates 'sd-boot' image and reboots into Secure Execution

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-02-11 09:00:38 +01:00
Jonathan Lebon c5ecef0aa4 lib/gpg-verify-result: Add missing floating annotation
I think I'm hitting issues due to this while using the Rust bindings:
https://github.com/coreos/rpm-ostree/pull/3406#issuecomment-1033084956

The bindings for those APIs use `from_glib_full` which says:

> Because ownership can only be transferred if something is already
> referenced, this is unsuitable for floating references.
2022-02-09 14:35:31 -05:00
Dan Nicholson 6fbf759279 lib/repo: Add commit version metadata to summary metadata
The commit metadata `version` key is well established but getting it for
a remote commit is cumbersome since the commit object needs to be
fetched and loaded. Including it in the summary additional metadata
allows a much more convenient view of what each of the remote refs
represents.
2022-02-04 14:28:11 -07:00
Luca BRUNO e6e9f14985
lib/commit: clean up assertions
This aligns all the assertion in the module. In particular, it gets
rid of all `g_return_val_if_fail` instances which may fail without
properly setting GError to the caller.
2022-02-01 17:33:28 +00:00
Simon McVittie 920f85cabc libotutil: Avoid infinite recursion during error unwinding
When we clean up from an error, for example copy_file_range() failing
while we generate a static delta (perhaps caused by
https://gitlab.gnome.org/GNOME/libglnx/-/issues/3 or by a
genuine write error), we might free a variant builder that has a
non-null parent. Previously, this caused infinite recursion and a stack
overflow, repeatedly freeing the same object, but Luca Bruno suggested
that the intention here appears to have been to free the parent object.

Partially resolves https://github.com/ostreedev/ostree/issues/2525
(the other bug reported in that issue needs to be resolved by updating
libglnx to a version where libglnx#3 has been fixed).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-28 11:08:00 +00:00
Luca Bruno 10ddf6e25f
Merge pull request #2524 from jlebon/pr/unlink-lock
lib/deploy: When deleting staged deployment, delete any lock
2022-01-26 08:36:45 +00:00
Luca BRUNO b27792ade3
lib/repo: open file only if required
This tightens up the logic for opening a file while inspecting its
xattrs. The only codepath fetching xattrs from a FD is the one
handling 'bare' mode.
It also rearranges the else-assert flow, mostly for future-proofing.
2022-01-24 16:54:54 +00:00
Jonathan Lebon baf838de22 ostree/deploy: Test finalization locking
Support for that file was added previously, but the testing lived in
rpm-ostree only. Let's add it here too.

In the process add a hidden `--lock-finalization` to `ostree admin
deploy` to make testing easier (though it could also be useful to update
managers driving OSTree via the CLI).
2022-01-21 13:48:35 -05:00
Jonathan Lebon 88dca03967 lib/deploy: When deleting staged deployment, delete any lock
Otherwise, any future staged deployment will also automatically be
locked even if not requested. Likely we should fold the locking into the
primary `staged-deployment` serialized GVariant instead.
2022-01-21 11:30:23 -05:00
Luca BRUNO 3f491a60c3
builtin: use GCancellable and GError everywhere
This reworks `ostree ls` top-level logic so that cancellation
tokens and error details are plumbed through all codepaths.
It also gets rid of all previous goto jumps.
2022-01-21 12:26:32 +00:00
Colin Walters 8c58195cc4 deploy: Also log to journal if we time out global sync()
We do implicitly have this data because we log timings via structured
metadata in a later journal entry, but it's quite common to lose
the structured metadata because a lot of tooling just grabs the default
syslog-compatible text from `journalctl`.

Let's be louder when we hit this case as a general rule too; I think
most people shipping ostree systems want to see if it's happening.
2022-01-20 10:52:04 -05:00
Luca BRUNO da72c245f4
lib/commit: reject empty metadata keys
This adds one more check to the metadata validation logic in order
to reject empty metadata keys.
2022-01-20 10:54:30 +00:00
Luca BRUNO 6230b3eeab
lib/commit: always validate metadata
This tweaks commit logic in order to always validate metadata,
including on commits where the expected checksum is already known.
2022-01-19 14:10:24 +00:00
Colin Walters cb73129483 deploy: Add a 5s max timeout on global filesystem `sync()`
https://bugzilla.redhat.com/show_bug.cgi?id=2003532

Basically there's a systemd bug where it's losing the `_netdev`
aspect of Ceph filesystem mounts.  This means the network is taken
down before Ceph is unmounted.  In turn, our invocation of `sync()`
blocks on Ceph, which won't succeed.

And this in turn manifests as a failure to transition to the new
deployment.

I initially did this patch to just rip out the global `sync()`.  I
am pretty sure we don't need it anymore.  We've been doing individual
`syncfs()` on `/sysroot` and `/boot` for a while now, and those
are the only filesystems we should be touching.  But *proving* that
is a whole other thing of course.

To be conservative, let's instead just add a timeout of 5s on
our invocation of `sync()`.  It doesn't return any information on
success/error anyways.

To allow testing without the `sync()` invocation, we also support
a new `OSTREE_SYSROOT_OPT_SKIP_SYNC=1` environment variable.  For
staged deployments, this needs to be injected via e.g. systemd unit
overrides into `ostree-finalize-staged.service`.

Implementing this is a bit hairy - we need to spawn a thread.  I
debated blocking in arecursive mainloop, but I think `g_cond_wait_until()`
is also fine here.
2022-01-18 09:19:20 -05:00
Jonathan Lebon 1af0150750
Merge pull request #2516 from cgwalters/define-ostree-booted 2022-01-12 13:39:59 -05:00
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 13edc15773 New upstream version 2022.1 2022-01-07 10:35:19 +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
Simon McVittie 3f5d22676d New upstream version 2021.6 2021-12-13 11:29:22 +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
Simon McVittie 75e180c3f8 New upstream version 2021.5 2021-10-10 17:35:12 +01: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
Simon McVittie 085ba80d7c New upstream version 2021.4 2021-10-05 21:01:43 +01: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