Ensure boot directory is open before accessing it for early pruning #3213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found an issue while testing Aktualizr (an update client that supports OSTree) with the latest libostree version: basically, the program failed when deploying an update, something that didn't happen with older libostree versions. Through code bisection I found the program stopped working after the commit c561e61 on the ostree project repository:
With this version (and newer), what happens is that the call made by Aktualizr to
ostree_sysroot_simple_write_deployment()
fails, particularly in this call-chain:and the failure occurs inside
auto_early_prune_old_deployments()
which is a function added in the commit I referenced. The failure happens because the function tries tofstatat
on an invalid handle (-1) and that handle comes fromsysroot->boot_fd
which was not initialized with a proper directory handle yet.Apparently the function assumes the handle to be always set which appears not to be the case. I found a couple places in the code running before the failure point in the code that could have initialized the
boot_fd
field but they were protected by conditions that were not true when running from Aktualizr. From there I concluded a call to ensure the field was initialized was simply missing and added it; this solved the issue with Aktualizr.