Repository navigation
Description
The ‘confext’ concept follows the same principle as the sysext functionality. sysext allows to extend the host filesystem (or a unit’s) at runtime with signed images that add new files to /usr and /opt, using OverlayFS. In the same fashion, confext will extend /etc (and only /etc).
And just like sysext, confext will be supported at the host level (e.g.: to update /etc/foo), at the system service level and at the portable service level. In the latter two cases, the update will happen only inside the private namespace of the relevant units. ExtensionImages will gain support for confexts, just as they already support sysexts.
confext volumes will support signed dm-verity, as sysext volumes already do, both with split artifacts (.raw, .verity, .roothash, .roothash.p7s), and in GPT volumes.
Host-wide images will be loaded from specific directories in /var and /run, like sysext. For units there will be a new unit setting that points to an individual image or to a directory containing multiple images, which can be located where desired.
The image names will follow the same rules as the sysext images, with an addition: unit-specific confext will need to be prefixed with the unit’s name.
The images will contain a /etc/extension-release.d/extension-release.<NAME>, where must match the image name (with the usual escape hatch of xattr), and with content being one or more of ID, VERSION_ID, and CONFEXT_LEVEL=. Config images will then be checked and matched against the base OS layer.
The systemd-sysext tools will be made multi-call, and when called with systemd-confext it will work on confext images instead of sysext images.
The systemctl reload, try-reload-or-restart, etc. verbs (and equivalent D-Bus APIs) will be enhanced to set up the new overlay for each unit, if a unit-specific new volume is found, before sending the reload/restart signal when the image is deployed.
Versioning will be fully supported, using the vpick mechanism. Following the RPM version comparison specification, the newest version of each image will be loaded automatically when a directory is specified.
There will be support for automatically marking every unit that is using ExtensionImages= with versioned confext for needs-reload, so that later the existing reload --marked can be issued.
For a rollback, it will happen automatically if the service fails after a try-reload-or-restart. For rollback protection, we have the dm-verity hash blocklist mechanism that is already used for all other verity images. The forthcoming TPM-based counter could also be used for this, after it has been implemented for UKIs (Unified Kernel Images).
Tasks:
- Implement
systemd-confextfunctionality tosystemd-sysextand tests inTEST-50-DISSECT - Implement confext support in
ExtensionImages= - Add support picking the newest image using vpick version comparison from directory
- Hook up systemctl
reloadand other methods with reloadingconfextimages configured viaExtensionImages=and tests inTEST-50-DISSECT - Add functionality that marks units using a confext with vpick, where a new version is available, with the 'needs-reload' marker
- Hook up rollback of vpick confext with
Restart=and good/bad counters
Activity
poettering commentedon Sep 30, 2022
hmm, I wonder if we should have something similar to the extension-release stuff. I think we need to make sure:
Hence dunno what to propose here, but I am pretty sure we want something like
/etc/configuration-release.d/or so?poettering commentedon Sep 30, 2022
also, i wonder if syscfg and sysext should be somehow validated against different keyrings. i.e. I'd assume sysext would come from a vendor, while syscfg might come from a tenant, if you so will, so they probably should by signed and validated against different keyrings.
poettering commentedon Sep 30, 2022
next question: mutability.
For sysext I think there's an easy case to be made that /usr/ is immutable, always.
But for syscfg/
/etc/I think immutability is much less of an obvious choice. There certainly usecases I agree with where a mutable /etc/ + syscfg makes a ton of sense. Think a ChromeBook style device that shall carry local settings in combination with employer settings (i.e. signed syscfg). While I don't think we have to support such "half-way" mutability of /etc/ right away I think we should at least think about it, and have an avenue for it. I mean, we have hostnamed/localed and so on, which make local system changes, we probably should allow them to do something useful somehow...So what could mutability with syscfg mean? I guess it could mean:
I think I dislike the first option, because it systematically changes what can override what. The second option sounds much better to me. So what about this: eventually add
--mutable=to systemd-sysext/systemd-syscfg that takes one of "no" (default), "local", "ephemeral", "auto". They would mean:/etc.local/if it is missing and put it on top of the overlayfs stack, and make the stack writable/etc.local/exists act likelocal, otherwise likeno.(and we might want to allow the same for /usr/ I guess, with /usr.local/, because there's little reason not to, and it's easy to add.)
bluca commentedon Sep 30, 2022
What would be the content? For sysext it's used to enforce ABI.
We can't quite do that kernel-wise right now, so it would have to be handled separately. Also keys used to sign can be changed, our implementation should be independent.
I'm not sure, for these use cases immutability (and changes via small additive images) is what we want? If changing things locally, unsigned, is allowed, then the whole concept of being able to track exactly what is changed by what and cryptographically verify it goes out of the window, no?
poettering commentedon Sep 30, 2022
Well, IMAGE_ID comes to mind, and I think something like sysext api level probably also makes sense: there's value in being able to say that some config is for some specific type of underlying image.
poettering commentedon Sep 30, 2022
Well, depends on the usecase. Being able to clearly say "this is local configuration" for stuff that was modified locally is worth a lot already. Really depends on policy.
The way I see it, configuration can come from different sources, different teams, and it is combined locally into one thing. Being able to say "hey, this is from source/team Y" and "this other stuff is from source team X" and "this other stuff was locally changed" is worth a lot. That doesn't mean one wants to allow Y, or Y or local stuff to always even make changes, but that's something to solve via keyrings, and the aforementioned
--mutable=switch.What I would love btw, if overlayfs would pass through the FS_IMMUTABLE_FL thing. If we had that then layers could mark files and directories with that, and this would disallow changes via the topmost, writable layer? I think that would be quite nice: allowing lower layers to control where the uppermost writable layer actually allows changes and where not.
daandemeyer commentedon Nov 1, 2022
Supporting some way of declaring global
ConfigurationImages=might make sense to reload/restart all services if a crucial "global" shared configuration file changes, with maybe an exclude mechanism for the few services that would need to ignore these global syscfgs. Global service overrides are already a thing which would enable this, and services that need to override the global list could assign the empty string to empty the list, so I'm not sure if we need to add anything specific to support this.pothos commentedon Feb 14, 2023
For
localit would be nicer to directly mount withupperdir=/etcinstead of creating a new separate folder. That leaves the same/etcpath usable with or without syscfg running. The only drawback I see is that the overlayfs marker device nodes for wiped out files will be in there but it prevents many other problems that would occur when the mount is not set up.With this done we could let
autocase be based on whether the workdir exists or not.poettering commentedon Feb 14, 2023
@pothos so far we said that any installed sysext override the underlying data in /usr/, though we try to tell people that sysext images should be additive, and thus not make changes or delete stuff. But we can't really stop people from doing so. I'd alaways assume that syscfg and sysext would use the same stacking order. Which conflicts with your proposal, since you'd put the local config top, not bottom...
But that certainly raises the question: should the stacking order for syscfg and sysext be different in this regard?
pothos commentedon Feb 14, 2023
Yes, I should have better quoted the first two items for this general question. Re-reading it I now understood that the original
/etccontents would be around in the other case, too, but changes are done in/etc.local? I'm not sure that is easy to handle for users when syscfgs don't load or aren't wanted anymore. While I think a read-only overlay mode that behaves exactly like sysext somehow makes sense, I see more use cases for the mutable mode because a vendor syscfg would supply the underlying configuration that the user can customize where needed and all other files still get updated when the vendor syscfg changes. So yes, the stacking order for the mutable case should be different from my perspective, and sysext contents always have a lower priority (that is also the case with the/etc.localproposal once something triggers the up-copy).The ready-only overlay mode could have a different stacking order in general compared to sysext but I think what makes sense depends on the nature of the underlying
/etc- it could be a full blown setup like in Debian as of now and we want to make sure that a syscfg takes priority because there could be stuff in/etcthat we are not aware of, or it could be that the local state in/etcis so minimal and intentional that it could be treated like a local syscfg that (while not dm-verity protected unless we have some on-the-fly-machine-id-syscfg generator) gets "sealed" on boot and could be layered on top no problem because of it's intentional and minimal content. To keep at least some consistency between syscfg and sysext I would say that for the read-only default we follow the current behavior of sysext but for the mutable mode we use a different order and support/etcor/usras direct upper dir (For/usrI really think that/usr.localis a bad idea because for traditional systems the package DBs get copied and can't expect sysext to be always on, e.g., in repair scenarios or after it got disabled for whatever reason).pothos commentedon Mar 17, 2023
We have done such a setup now in Flatcar for
/etcwhere we have/usr/share/flatcar/etcas lowerdir and the original/etcas upperdir. It works well to disable the overlay mount again and use the system as before. In our case we expect upcopies to be done because the lowerdir provides OS defaults which the user can change - I think providing OS defaults would be a nice usecase for syscfg and we would be happy to migrate away from our custom initrd mount logic. The upcopies are handled quite ok with theredirect_dir=on,metacopy=off,noatimeoptions. Of course, when stopping to use the overlay after upcopies were done, there remains are left in the original/etcbut shouldn't be a big problem (overlay xattrs for directories or the special masking character devices when deleting files from the lowerdir) compared to ending up in a split state as would be the case with, e.g.,/etc.localas upperdir.As mentioned before, such a mutable overlay setup would work well with sysext for
/usr, too, and allow sysext images to be used on Debian or Fedora. With sysext images only providing additional files, the system works exactly as before, just in the case where the sysext would provide same files the real/usrwins but that's anyway the case as soon as the file gets overwritten since the syscfg/sysext is not on top of the stack but changes in/etc.local//usr.localwould win. So I don't see a real benefit and would rather focus on making it easy for users to run syscfg/sysext and stop using them again without having to reconcile their broken system.[-]Signed, verity-protected, live configuration updates: syscfg[/-][+]Signed, verity-protected, live configuration updates: confext[/+]pothos commentedon May 31, 2023
@t-lo, @poettering, and myself got a chance to discuss the above in person. Here is a short summary:
Did I forget anything?
4 remaining items
poettering commentedon Jun 1, 2023
quick note: this mount could just be a read-only bind mount onto itself btw. i.e. no need to use overlayfs with its slightly unposix semantics if only a single layer is in effect and we just need to make it read-only.
poettering commentedon Jun 1, 2023
write ups sounds good to me, btw.
poettering commentedon Jun 1, 2023
and in case anyone wonders: if /usr.local/ exists and people call
systemd-sysext refresh --mode=ephemeralthen this should mean that /usr.local/ is included in the read-only stack of layers and the ephemeral tmpfs is used as writable layer. or in other words: if /usr.local/ exists it is always honoured, in all three modes. The--mode=read-only|writable|ephemeralchoice simply controls whether to make top layer writable, and which one.jcpunk commentedon Jun 1, 2023
How would this interact with selinux labels as
/usr/has a bunch of mappings in place, but/usr.localdoes not.bluca commentedon Jun 1, 2023
Not super enthusiastic about locating these on the root filesystem. We just managed to clean it up a bit (some still are...) from the legacy spread of directories. Extensions are stored in /var anyway, so I'd prefer if these local overrides were stored under /var too. Apart from decluttering the root directory, it also allows it to be read-only. On a read-only root system, you wouldn't be able to move the symlink as suggested to achieve the different layouts.
Why is this necessary? It will result in extra moving parts (and thus extra things that can go wrong), could that be avoided?
pothos commentedon Jun 5, 2023
The
/usr.localas backing folder for the overlayfs upperdir shouldn't be used directly, only through/usr- nothing special should be needed from my understanding.Regarding always setting up a mount for, e.g.,
/optindependent on the sysext contents or if there are syexts, I think it's necessary for consistent behavior. The first case about changing contents of a sysext is already a problem, and you get/optread-only or not depending on whether/optfiles are shipped or whether this sysext stopped matching. The second about usable sysexts being there or not is also good to ensure thatmerge --mode=always sets up the same mount and we don't switch between writable or read-only depending on sysexts being there or stopping to match.t-lo commentedon Jun 5, 2023
Not feeling strongly towards either - e.g.
/var/extensions/usr.localwould work fine for us too, or even/run/extensions/usr.localfor ephemeral mode. @poettering how do you feel about this?goenkam commentedon Mar 18, 2024
@bluca could you please attach a link to the 'reload --marked' PR / work item to the description too, if there is one?
core: Also refresh confext extensions when reloading notify-reload se…