def want_selinux_relabel(
- config: Config, root: Path, fatal: bool = True
+ config: Config,
+ root: Path,
+ fatal: bool = True,
) -> Optional[tuple[Path, str, Path, Path]]:
if config.selinux_relabel == ConfigFeature.disabled:
return None
+ if config.selinux_relabel == ConfigFeature.auto and config.output_format == OutputFormat.directory:
+ return None
+
selinux = root / "etc/selinux/config"
if not selinux.exists():
if fatal and config.selinux_relabel == ConfigFeature.enabled:
disabled, files will not relabeled. If enabled, an SELinux policy has
to be installed in the image and **setfiles** has to be available to
relabel files. If any errors occur during **setfiles**, the build will
- fail. If set to `auto`, files will be relabeled if an SELinux policy
- is installed in the image and if **setfiles** is available. Any errors
- occurred during **setfiles** will be ignored.
+ fail. If set to `auto`, files will be relabeled if mkosi is not
+ building a directory image, an SELinux policy is installed in the
+ image and if **setfiles** is available. Any errors occurred during
+ **setfiles** will be ignored.
Note that when running unprivileged, **setfiles** will fail to set any
labels that are not in the host's SELinux policy. To ensure **setfiles**