-
Notifications
You must be signed in to change notification settings - Fork 247
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
stages/files: relabel /var/home and /var/roothome #632
Conversation
Can one of the admins verify this patch? |
The behaviour of how `restorecon` handles symlinks changed between RHCOS and FCOS. More specifically, `restorecon` will follow symlinks that are part of a given path, but not if the target path is a symlink itself. On OSTree-based systems, `/home` and `/root` are just symlinks, so the newer `restorecon` wasn't actually relabeling anything under there. Add the real paths to the list of dirs to relabel and add `-i` so that it's not a fatal error on non-OSTree-based systems. Closes: coreos/fedora-coreos-config#2
500a4ef
to
45b7518
Compare
@@ -41,6 +41,9 @@ func (s *stage) createPasswd(config types.Config) error { | |||
"/etc/.pwd.lock", | |||
"/home", | |||
"/root", | |||
// for OSTree-based systems (newer restorecon doesn't follow symlinks) | |||
"/var/home", | |||
"/var/roothome", |
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 also add /var/usrlocal
and /var/opt
? But this LGTM too.
See also rhinstaller/anaconda@43a8455
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.
Those should be fine, no? Any files/dirs that users add in there through their Ignition configs will be marked for relabeling as Ignition creates them.
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.
I'm thinking though of things that drop files in /usr/local
and /opt
.
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.
I mentioned this in the commit message:
More specifically,
restorecon
will follow symlinks that are
part of a given path, but not if the target path is a symlink itself.
So e.g. any files dropped under /usr/local
and /opt
will be relabeled properly. (I also just double checked this on FCOS to be triple sure).
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.
Ah sorry, missed that. LGTM then!
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.
LGTM assuming Colin's comment gets resolved.
ok to test |
good to merge |
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
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to care of here is to relabel the homedir files we created for each user. This should be cross-platform already.
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to care of here is to relabel the homedir files we created for each user. This should be cross-platform already.
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to take care of here is to relabel the homedir files we created for each user. This should be cross-platform already.
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to take care of here is to relabel the homedir files we created for each user. This is distro-agnostic.
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to take care of here is to relabel the homedir files we created or modified for each user. Because `setfiles` by default doesn't follow the final symlink, we also add a check here to relabel the target if the homedir is a link. (Ideally, we'd change the home directory of `root `to be `/var/roothome` like we do in rpm-ostree based systems for regular users: coreos/rpm-ostree#1726, but it's probably not worth the ripples that would cause.)
We shouldn't need to run `setfiles` with `-i`, which causes `setfiles` to ignore files that do not exist. All the files which we pass to `setfiles` should exist, and it should be a hard error if `setfiles` fails to find and relabel the file we wrote. This dates from coreos#632, where we added `/var/home` and `/var/roothome` for OSTree-based systems. We actually don't need to special-case OSTree systems at all anymore. The `/var/home` and `/var/roothome` directories themselves are now handled by `ignition-ostree-populate-var.service`. All we need to take care of here is to relabel the homedir files we created or modified for each user. Because `setfiles` by default doesn't follow the final symlink, we also add a check here to relabel the target if the homedir is a link. (Ideally, we'd change the home directory of `root `to be `/var/roothome` like we do in rpm-ostree based systems for regular users: coreos/rpm-ostree#1726, but it's probably not worth the ripples that would cause.)
The behaviour of how
restorecon
handles symlinks changed between RHCOSand FCOS. More specifically,
restorecon
will follow symlinks that arepart of a given path, but not if the target path is a symlink itself.
On OSTree-based systems,
/home
and/root
are just symlinks, so thenewer
restorecon
wasn't actually relabeling anything under there.Add the real paths to the list of dirs to relabel and add
-i
so thatit's not a fatal error on non-OSTree-based systems.
Closes: coreos/fedora-coreos-config#2