Skip to content

Commit f45f0f0

Browse files
committed
lsm: Make setenforce 0 fallback require BOOTC_SETENFORCE0_FALLBACK
We shouldn't perform global system mutation without an opt-in. As painful as it is. Signed-off-by: Colin Walters <[email protected]>
1 parent c3b5fc8 commit f45f0f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/src/lsm.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ pub(crate) fn selinux_ensure_install_or_setenforce() -> Result<Option<SetEnforce
105105
// Note that this will re-exec the entire process
106106
selinux_ensure_install()?;
107107
let g = if !context_is_install_t(&current) {
108-
tracing::warn!("Failed to enter install_t; temporarily setting permissive mode");
109-
selinux_set_permissive(true)?;
110-
Some(SetEnforceGuard)
108+
if std::env::var_os("BOOTC_SETENFORCE0_FALLBACK").is_some() {
109+
tracing::warn!("Failed to enter install_t; temporarily setting permissive mode");
110+
selinux_set_permissive(true)?;
111+
Some(SetEnforceGuard)
112+
} else {
113+
anyhow::bail!("Failed to enter install_t (running as {current}) - use BOOTC_SETENFORCE0_FALLBACK=1 to override");
114+
}
111115
} else {
112116
None
113117
};

0 commit comments

Comments
 (0)