-
Notifications
You must be signed in to change notification settings - Fork 81
Fix selinux support #3103
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
Fix selinux support #3103
Changes from 8 commits
ceff753
1108d75
4959fa7
be23951
8ebbb63
617080a
0533b40
e85c3d4
136627c
f4f6ba1
136b30b
7f38b09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,14 @@ use crate::{ | |
| message, | ||
| model::{software_selection::SoftwareSelection, state::SoftwareState, ModelAdapter}, | ||
| zypp_server::{self, SoftwareAction, ZyppServer}, | ||
| Model, | ||
| Model, ResolvableType, | ||
| }; | ||
| use agama_bootloader; | ||
| use agama_security as security; | ||
| use agama_utils::{ | ||
| actor::{self, Actor, Handler, MessageHandler}, | ||
| api::{ | ||
| bootloader::KernelArg, | ||
| event::{self, Event}, | ||
| software::{Config, Proposal, Repository, SystemInfo}, | ||
| Issue, Scope, | ||
|
|
@@ -74,6 +76,7 @@ pub struct Starter { | |
| progress: Handler<progress::Service>, | ||
| questions: Handler<question::Service>, | ||
| security: Handler<security::Service>, | ||
| bootloader: Handler<agama_bootloader::Service>, | ||
| } | ||
|
|
||
| impl Starter { | ||
|
|
@@ -83,6 +86,7 @@ impl Starter { | |
| progress: Handler<progress::Service>, | ||
| questions: Handler<question::Service>, | ||
| security: Handler<security::Service>, | ||
| bootloader: Handler<agama_bootloader::Service>, | ||
| ) -> Self { | ||
| Self { | ||
| model: None, | ||
|
|
@@ -91,6 +95,7 @@ impl Starter { | |
| progress, | ||
| questions, | ||
| security, | ||
| bootloader, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -135,6 +140,7 @@ impl Starter { | |
| progress: self.progress, | ||
| product: None, | ||
| kernel_cmdline: KernelCmdline::parse().unwrap_or_default(), | ||
| bootloader: self.bootloader, | ||
| }; | ||
| service.setup().await?; | ||
| Ok(actor::spawn(service)) | ||
|
|
@@ -157,6 +163,7 @@ pub struct Service { | |
| product: Option<Arc<RwLock<ProductSpec>>>, | ||
| selection: SoftwareSelection, | ||
| kernel_cmdline: KernelCmdline, | ||
| bootloader: Handler<agama_bootloader::Service>, | ||
| } | ||
|
|
||
| #[derive(Default)] | ||
|
|
@@ -173,8 +180,9 @@ impl Service { | |
| progress: Handler<progress::Service>, | ||
| questions: Handler<question::Service>, | ||
| security: Handler<security::Service>, | ||
| bootloader: Handler<agama_bootloader::Service>, | ||
| ) -> Starter { | ||
| Starter::new(events, issues, progress, questions, security) | ||
| Starter::new(events, issues, progress, questions, security, bootloader) | ||
| } | ||
|
|
||
| pub async fn setup(&mut self) -> Result<(), Error> { | ||
|
|
@@ -190,6 +198,28 @@ impl Service { | |
| Ok(()) | ||
| } | ||
|
|
||
| fn update_selinux(&self, state: &SoftwareState) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps it would be cleaner to extend
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, I usually try to make shared method when there are at least two users of it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the problem is that the caller needs to know too many details about |
||
| let selinux_selected = state.resolvables.to_vec().iter().any(|(name, typ, state)| { | ||
| typ == &ResolvableType::Pattern && name == "selinux" && state.selected() | ||
| }); | ||
|
|
||
| let value = if selinux_selected { | ||
| "security=selinux" | ||
| } else { | ||
| "security=" | ||
| }; | ||
| let arg = KernelArg { | ||
| scope: "selinux".to_string(), | ||
|
jreidinger marked this conversation as resolved.
Outdated
|
||
| value: value.to_string(), | ||
| }; | ||
| let res = self | ||
| .bootloader | ||
| .cast(agama_bootloader::message::SetKernelArg { arg }); | ||
|
jreidinger marked this conversation as resolved.
Outdated
|
||
| if res.is_err() { | ||
| tracing::warn!("Failed to send to bootloader new selinux state: {:?}", res); | ||
| } | ||
| } | ||
|
|
||
| /// Updates the proposal and the service state. | ||
| /// | ||
| /// This function performs the following actions: | ||
|
|
@@ -214,6 +244,8 @@ impl Service { | |
| }; | ||
|
|
||
| tracing::info!("Wanted software state: {new_state:?}"); | ||
| self.update_selinux(&new_state); | ||
|
|
||
| let model = self.model.clone(); | ||
| let progress = self.progress.clone(); | ||
| let issues = self.issues.clone(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.