-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
05core: relabel /var from initrd #245
Conversation
So with this + coreos/ignition#846, try:
|
Is that in a Fedora kernel build yet? It looks like it's not in an upstream release yet:
|
echo 0 > ${CAN_SETFILES_STAMP} | ||
fi | ||
fi | ||
grep 1 ${CAN_SETFILES_STAMP} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -q
to avoid unnecessary output.
fatal() { | ||
err "$@" | ||
exit 1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we should get these basics into dracut-lib.sh
or so.
err " e.g.: $0 /etc/passwd '/etc/group*'" | ||
fi | ||
|
||
source /sysroot/etc/selinux/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe silently do nothing if that file doesn't exist, to be nicer to people who want to build custom systems without SELinux? There's a similar pattern with other tools like restorecon
.
Reusing this for a tangentially related q; remind me again why we don't load policy from the initramfs? The complexity of handling #184 is much higher than Although, maybe a crude hammer would be a patch for |
Yeah, it was backported in https://bugzilla.redhat.com/show_bug.cgi?id=1758597 --> https://src.fedoraproject.org/rpms/kernel/c/8bb21014a55f50b1a734322639fffadafcd79672?branch=f31
See discussions with Lennart in coreos/ignition#635, starting from coreos/ignition#635 (comment).
OK yeah, I think this may be a problem. The issue is that while we can set labels, we can't read them back. So restoring the rootfs using |
Now that the kernel supports relabeling from the initrd, we can clean up some hacks here. After running `systemd-tmpfiles`, immediately relabel what we just wrote using `setfiles`. This allows us to drop the `Z /var` tmpfiles.d dropin, and hacking around `systemd-random-seed.service` ordering. For compatibility with RHCOS, I added a fallback in `coreos-relabel` so that if initrd relabeling isn't supported, we just use tmpfiles.d dropins. (RHCOS today sources the `05core` overlay directly, and I think doing it this way is cleaner than splitting things out into a separate overlay). I've also snuck in a fix for the live case with persistent `/var` so we don't always relabel everything in there.
6fcc31d
to
9cbcd3a
Compare
Fixups! ⬆️ |
But that would break the scenario where we're not replacing the rootfs. |
I meant if the source repo we're using to replace the rootfs wasn't bare (e.g. pulled over the network or something). Not that the embedded OSTree itself would be. :) I was more expanding on why it's problematic rather than suggesting a change. |
On OSTree systems, those are just symlinks in the deployment root. If they're not labeled correctly already, it signals an issue with the disk creation process itself (and might also signal that the next time a deployment root is created, it'll also be mislabeled). Anyway, even on non-OSTree systems, it seems reasonable to expect that `/home` and `/root` at least already exist and don't need to be created (and thus don't need to be relabeld). It's possible that [fixing `getxattr` without a policy loaded](coreos/fedora-coreos-config#245 (comment)) would also fix this, since `setfiles` would see that the symlinks were already correctly labeled. In effect, this is completing what coreos#632 started. Closes: coreos/fedora-coreos-tracker#339
On OSTree systems, those are just symlinks in the deployment root. If they're not labeled correctly already, it signals an issue with the disk creation process itself (and might also signal that the next time a deployment root is created, it'll also be mislabeled). Anyway, even on non-OSTree systems, it seems reasonable to expect that `/home` and `/root` at least already exist and don't need to be created (and thus don't need to be relabeld). It's possible that [fixing `getxattr` without a policy loaded](coreos/fedora-coreos-config#245 (comment)) would also fix this, since `setfiles` would see that the symlinks were already correctly labeled. In effect, this is completing what coreos#632 started. Closes: coreos/fedora-coreos-tracker#339
Now that the kernel supports relabeling from the initrd, we can clean up
some hacks here. After running
systemd-tmpfiles
, immediately relabelwhat we just wrote using
setfiles
. This allows us to drop theZ /var
tmpfiles.d dropin, and hacking around
systemd-random-seed.service
ordering.
For compatibility with RHCOS, I added a fallback in
coreos-relabel
sothat if initrd relabeling isn't supported, we just use tmpfiles.d
dropins. (RHCOS today sources the
05core
overlay directly, and I thinkdoing it this way is cleaner than splitting things out into a separate
overlay).
I've also snuck in a fix for the live case with persistent
/var
so wedon't always relabel everything in there.