Skip to content

Commit 0c250ea

Browse files
authored
Merge pull request #427 from jeckersb/encapsulate-selinux-cleanup
Encapsulate selinux guard consumption a bit better
2 parents e70142d + d470465 commit 0c250ea

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/src/install.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@ impl State {
313313
tracing::debug!("Loaded SELinux policy: {csum}");
314314
Ok(Some(r))
315315
}
316+
317+
#[context("Finalizing state")]
318+
pub(crate) fn consume(self) -> Result<()> {
319+
// If we had invoked `setenforce 0`, then let's re-enable it.
320+
if let SELinuxFinalState::Enabled(Some(guard)) = self.selinux_state {
321+
guard.consume()?;
322+
}
323+
Ok(())
324+
}
316325
}
317326

318327
/// Path to initially deployed version information
@@ -1244,10 +1253,7 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
12441253

12451254
// At this point, all other threads should be gone.
12461255
if let Some(state) = Arc::into_inner(state) {
1247-
// If we had invoked `setenforce 0`, then let's re-enable it.
1248-
if let SELinuxFinalState::Enabled(Some(guard)) = state.selinux_state {
1249-
guard.consume()?;
1250-
}
1256+
state.consume()?;
12511257
} else {
12521258
// This shouldn't happen...but we will make it not fatal right now
12531259
tracing::warn!("Failed to consume state Arc");

0 commit comments

Comments
 (0)