summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-impl-system-generator.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: Run clang-formatColin Walters2023-05-021-39/+38
| | | | | This is a one-time tree wide reformatting to ensure consistency going forward.
* Rename ostree-cmdprivate to drop out of introspectionColin Walters2022-06-021-1/+1
| | | | | | 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`.
* Add an `ostree-boot-complete.service` to propagate staging failuresColin Walters2022-04-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* Don't fail build when systemd unit path not definedDan Nicholson2021-06-181-0/+4
| | | | | | 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.
* Use generator to enable ostree-remount.service and ostree-finalize-staged.pathColin Walters2021-06-161-7/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We struggled for a long time with enablement of our "internal units", trying to follow the philosophy that units should only be enabled by explicit preset. See https://bugzilla.redhat.com/show_bug.cgi?id=1451458 and https://github.com/coreos/rpm-ostree/pull/1482 etc. And I just saw chat (RH internal on a proprietary system sadly) where someone hit `ostree-remount.service` not being enabled in CentOS8. Thinking about this more, I realized we've shipped a systemd generator for a long time and while its only role until now was to generate `var.mount`, but by using it to force on our internal units, we don't require people to deal with presets anymore. Basically we're inverting things so that "if ostree= is on the kernel cmdline, then enable our units" and not "enable our units, but have them use ConditionKernelCmdline=ostree to skip". Drop the weird gyrations we were doing around `ostree-finalize-staged.path` too; forking `systemctl start` is just asking for bugs. So after this, hopefully we won't ever again have to think about distribution presets and our units.
* Support mounting /sysroot (and /boot) read-onlyColin Walters2019-12-111-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We want to support extending the read-only state to cover `/sysroot` and `/boot`, since conceptually all of the data there should only be written via libostree. Or at least for `/boot` should *mostly* just be written by ostree. This change needs to be opt-in though to avoid breaking anyone. Add a `sysroot/readonly` key to the repository config which instructs `ostree-remount.service` to ensure `/sysroot` is read-only. This requires a bit of a dance because `/sysroot` is actually the same filesystem as `/`; so we make `/etc` a writable bind mount in this case. We also need to handle `/var` in the "OSTree default" case of a bind mount; the systemd generator now looks at the writability state of `/sysroot` and uses that to determine whether it should have the `var.mount` unit happen before or after `ostree-remount.service.` Also add an API to instruct the libostree shared library that the caller has created a new mount namespace. This way we can freely remount read-write. This approach extends upon in a much better way previous work we did to support remounting `/boot` read-write. Closes: https://github.com/ostreedev/ostree/issues/1265
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* tree-wide: Update to new libglnx fd APIsColin Walters2017-10-111-1/+1
| | | | | | | | | | | | | | | | | | | This ends up a lot better IMO. This commit is *mostly* just `s/glnx_close_fd/glnx_autofd`, but there's also a number of hunks like: ``` - if (self->sysroot_fd != -1) - { - (void) close (self->sysroot_fd); - self->sysroot_fd = -1; - } + glnx_close_fd (&self->sysroot_fd); ``` Update submodule: libglnx Closes: #1259 Approved by: jlebon
* tree-wide: Remove Emacs modelinesColin Walters2017-09-211-2/+1
| | | | | | | | | We added a `.dir-locals.el` in commit: 9a77017d87b74c5e2895cdd64ad098018929403f There's no need to have it per-file, with that people might think to add other editors, which is the wrong direction. Closes: #1206 Approved by: jlebon
* tree-wide: Remove trailing semicolon from autoptr declarationsColin Walters2017-08-071-1/+1
| | | | | | | It confuses `g-ir-scanner`, and isn't necessary. Closes: #1056 Approved by: pwithnall
* Update libglnx, port various bits to new APIColin Walters2017-07-181-2/+2
| | | | | | | | | | | | | | | | Using the error prefixing in the delta processing allows us to do new code style. Also strip trailing whitespace. Use error prefixing in a few other random places. I didn't hunt for all of them, just testing out the new API. Use `glnx_fchmod()`. Also note I dropped one `fchmod (tmpf, 0600)` which is no longer necessary. Update submodule: libglnx Closes: #1011 Approved by: jlebon
* Port to GLnxTmpfileColin Walters2017-06-271-8/+6
| | | | | | | | | | | | | | | | | | | | | There's lots of mechanically replacing `OtTmpFile` with `GLnxTmpfile`; the biggest changes are in the commit path. Symlink commits are now very clearly separated from regular files. Symlinks are `OtCleanupUnlinkat`, and regular files are `GLnxTmpfile`. The commit codepath separates those as `_ostree_repo_commit_path_final()` and `_ostree_repo_commit_tmpf_final()`. A nice aspect of all of this is that they both *consume* the temporary on success. This avoids an extra spurious `unlink()` call. One of the biggest bits of code motion is in `commit_loose_regfile_object()`, which no longer needs to care about symlinks. For the most parth though it's just removing conditionals. Update submodule: libglnx Closes: #958 Approved by: jlebon
* switchroot/generator: Add var.mount to local-fs.target.requiresColin Walters2017-05-171-0/+10
| | | | | | | | | | | Unbreaks mounting in CentOS. Newer systemd in Fedora pulls didn't need this, I think due to `RequiresMountsFor=`. Anyways, this is what the fstab generator does, and it's clearly right ✓. Closes: https://github.com/ostreedev/ostree/issues/867 Closes: #869 Approved by: jlebon
* tree-wide: Add a few missing O_CLOEXECColin Walters2017-05-161-1/+1
| | | | | | | | | I noticed an instance of this while working on https://github.com/ostreedev/ostree/pull/861 Which apparently I cargo-culted into the new system generator bits. Let's break this out as a small concise change. Closes: #866 Approved by: jlebon
* Switch to using a systemd generator for /varColin Walters2017-05-161-0/+219
If one wants to set up a mount for `/var` in `/etc/fstab`, it won't be mounted since `ostree-prepare-root` set up a bind mount for `/var` to `/sysroot/ostree/$stateroot/var`, and systemd will take the already extant mount over what's in `/etc/fstab`. There are a few options to fix this, but what I settled on is parsing `/etc/fstab` in a generator (exactly like `systemd-fstab-generator` does), except here we look for an explicit mount for `/var`, and if one *isn't* found, synthesize the default ostree mount to the stateroot. Another nice property is that if an admin creates a `var.mount` unit in `/etc` for example, that will also override our mount. Note that today ostree doesn't hard depend on systemd, so this behavior only kicks in if we're built with systemd *and* libmount support (for parsing `/etc/fstab`). I didn't really test that case though. Initially I started writing this as a "pure libc" program, but at one point decided to use `libostree.so` to find the booted deployment. That didn't work out because `/boot` wasn't necessarily mounted and hence we couldn't find the bootloader config. A leftover artifact from this is that the generator code calls into libostree via the "cmd private" infrastructure. But it's an easy way to share code, and doesn't hurt. Closes: #859 Approved by: jlebon