From fd1f46cdc72d991fc426332b45187ba20e049b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Mon, 9 Feb 2026 07:50:36 +0000 Subject: [PATCH 1/2] Drop the unused security code --- rust/agama-lib/src/install_settings.rs | 3 - rust/agama-lib/src/lib.rs | 1 - rust/agama-lib/src/security.rs | 32 ---------- rust/agama-lib/src/security/client.rs | 69 ---------------------- rust/agama-lib/src/security/http_client.rs | 54 ----------------- rust/agama-lib/src/security/model.rs | 60 ------------------- rust/agama-lib/src/security/proxies.rs | 14 ----- rust/agama-lib/src/security/settings.rs | 46 --------------- rust/agama-lib/src/security/store.rs | 64 -------------------- rust/agama-lib/src/store.rs | 11 ---- rust/agama-server/src/lib.rs | 1 - rust/agama-server/src/web.rs | 4 +- rust/agama-server/src/web/docs/config.rs | 3 - 13 files changed, 1 insertion(+), 361 deletions(-) delete mode 100644 rust/agama-lib/src/security.rs delete mode 100644 rust/agama-lib/src/security/client.rs delete mode 100644 rust/agama-lib/src/security/http_client.rs delete mode 100644 rust/agama-lib/src/security/model.rs delete mode 100644 rust/agama-lib/src/security/proxies.rs delete mode 100644 rust/agama-lib/src/security/settings.rs delete mode 100644 rust/agama-lib/src/security/store.rs diff --git a/rust/agama-lib/src/install_settings.rs b/rust/agama-lib/src/install_settings.rs index 570d6f8b61..d4d3c38745 100644 --- a/rust/agama-lib/src/install_settings.rs +++ b/rust/agama-lib/src/install_settings.rs @@ -24,7 +24,6 @@ use crate::bootloader::model::BootloaderSettings; use crate::context::InstallationContext; use crate::hostname::model::HostnameSettings; -use crate::security::settings::SecuritySettings; use crate::storage::settings::zfcp::ZFCPConfig; use crate::{network::NetworkSettings, storage::settings::dasd::DASDConfig}; use serde::{Deserialize, Serialize}; @@ -57,8 +56,6 @@ pub struct InstallSettings { #[schema(value_type = Object)] pub iscsi: Option>, #[serde(skip_serializing_if = "Option::is_none")] - pub security: Option, - #[serde(skip_serializing_if = "Option::is_none")] #[schema(value_type = Object)] pub storage: Option>, #[serde(rename = "legacyAutoyastStorage")] diff --git a/rust/agama-lib/src/lib.rs b/rust/agama-lib/src/lib.rs index 1bd0770cc9..d670da9c47 100644 --- a/rust/agama-lib/src/lib.rs +++ b/rust/agama-lib/src/lib.rs @@ -60,7 +60,6 @@ pub mod profile; pub mod progress; pub mod proxies; pub mod questions; -pub mod security; pub mod storage; mod store; pub use store::Store; diff --git a/rust/agama-lib/src/security.rs b/rust/agama-lib/src/security.rs deleted file mode 100644 index 2eb2c6d7d3..0000000000 --- a/rust/agama-lib/src/security.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements support for handling the security settings, like SSL certificates. - -pub mod client; -pub mod http_client; -pub mod model; -pub mod proxies; -pub mod settings; -pub mod store; - -pub use http_client::{SecurityHTTPClient, SecurityHTTPClientError}; -pub use settings::SecuritySettings; -pub use store::{SecurityStore, SecurityStoreError}; diff --git a/rust/agama-lib/src/security/client.rs b/rust/agama-lib/src/security/client.rs deleted file mode 100644 index 442d8b5913..0000000000 --- a/rust/agama-lib/src/security/client.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) [2025] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -use std::str::FromStr; - -use zbus::Connection; - -use crate::error::ServiceError; - -use super::{ - model::{SSLFingerprint, SSLFingerprintAlgorithm}, - proxies::SecurityProxy, -}; - -/// D-Bus client for the security service -#[derive(Clone)] -pub struct SecurityClient<'a> { - security_proxy: SecurityProxy<'a>, -} - -impl SecurityClient<'_> { - pub async fn new(connection: Connection) -> Result { - Ok(Self { - security_proxy: SecurityProxy::new(&connection).await?, - }) - } - - pub async fn get_ssl_fingerprints(&self) -> Result, ServiceError> { - let dbus_list = self.security_proxy.ssl_fingerprints().await?; - dbus_list - .into_iter() - .map(|(alg, value)| { - Ok(SSLFingerprint { - fingerprint: value, - algorithm: SSLFingerprintAlgorithm::from_str(&alg)?, - }) - }) - .collect() - } - - pub async fn set_ssl_fingerprints( - &self, - list: &Vec, - ) -> Result<(), ServiceError> { - let dbus_list: Vec<(&str, &str)> = list - .iter() - .map(|s| (s.algorithm.into(), s.fingerprint.as_str())) - .collect(); - self.security_proxy.set_ssl_fingerprints(&dbus_list).await?; - Ok(()) - } -} diff --git a/rust/agama-lib/src/security/http_client.rs b/rust/agama-lib/src/security/http_client.rs deleted file mode 100644 index 764840475d..0000000000 --- a/rust/agama-lib/src/security/http_client.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) [2025] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -use super::model::SSLFingerprint; -use crate::http::{BaseHTTPClient, BaseHTTPClientError}; - -#[derive(Debug, thiserror::Error)] -pub enum SecurityHTTPClientError { - #[error(transparent)] - HTTP(#[from] BaseHTTPClientError), -} - -pub struct SecurityHTTPClient { - client: BaseHTTPClient, -} - -impl SecurityHTTPClient { - pub fn new(base: BaseHTTPClient) -> Self { - Self { client: base } - } - - pub async fn get_ssl_fingerprints( - &self, - ) -> Result, SecurityHTTPClientError> { - Ok(self.client.get("/security/ssl_fingerprints").await?) - } - - pub async fn set_ssl_fingerprints( - &self, - fps: &Vec, - ) -> Result<(), SecurityHTTPClientError> { - self.client - .put_void("/security/ssl_fingerprints", fps) - .await?; - Ok(()) - } -} diff --git a/rust/agama-lib/src/security/model.rs b/rust/agama-lib/src/security/model.rs deleted file mode 100644 index 1c9dec9c0f..0000000000 --- a/rust/agama-lib/src/security/model.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) [2025] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -use serde::{Deserialize, Serialize}; - -use crate::error::ServiceError; - -#[derive( - Default, - Clone, - Copy, - Debug, - strum::IntoStaticStr, - strum::EnumString, - Serialize, - Deserialize, - utoipa::ToSchema, -)] -#[strum(ascii_case_insensitive)] -#[strum( - parse_err_fn = alg_not_found_err, - parse_err_ty = ServiceError, -)] -pub enum SSLFingerprintAlgorithm { - SHA1, - #[default] - SHA256, -} - -#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)] -pub struct SSLFingerprint { - /// The string value for SSL certificate fingerprint. - /// Example value is "F6:7A:ED:BB:BC:94:CF:55:9D:B3:BA:74:7A:87:05:EF:67:4E:C2:DB" - pub fingerprint: String, - /// Algorithm used to compute SSL certificate fingerprint. - /// Supported options are "SHA1" and "SHA256" - #[serde(default)] - pub algorithm: SSLFingerprintAlgorithm, -} - -fn alg_not_found_err(s: &str) -> ServiceError { - ServiceError::UnsupportedSSLFingerprintAlgorithm(s.to_string()) -} diff --git a/rust/agama-lib/src/security/proxies.rs b/rust/agama-lib/src/security/proxies.rs deleted file mode 100644 index acf35c5513..0000000000 --- a/rust/agama-lib/src/security/proxies.rs +++ /dev/null @@ -1,14 +0,0 @@ -use zbus::proxy; -#[proxy( - interface = "org.opensuse.Agama.Security", - default_service = "org.opensuse.Agama.Software1", - default_path = "/org/opensuse/Agama/Software1", - assume_defaults = true -)] -pub trait Security { - /// SslFingerprints property - #[zbus(property)] - fn ssl_fingerprints(&self) -> zbus::Result>; - #[zbus(property)] - fn set_ssl_fingerprints(&self, value: &[(&str, &str)]) -> zbus::Result<()>; -} diff --git a/rust/agama-lib/src/security/settings.rs b/rust/agama-lib/src/security/settings.rs deleted file mode 100644 index 8c18cf3db9..0000000000 --- a/rust/agama-lib/src/security/settings.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Representation of the software settings - -use serde::{Deserialize, Serialize}; - -use super::model::SSLFingerprint; - -/// Security settings for installation -#[derive(Clone, Debug, Default, Serialize, Deserialize, utoipa::ToSchema)] -#[serde(rename_all = "camelCase")] -pub struct SecuritySettings { - /// List of user selected patterns to install. - #[serde(skip_serializing_if = "Option::is_none")] - // when we add support for remote URL here it should be vector of SSL - // certificates which will include flatten fingerprint - pub ssl_certificates: Option>, -} - -impl SecuritySettings { - pub fn to_option(self) -> Option { - if self.ssl_certificates.is_none() { - None - } else { - Some(self) - } - } -} diff --git a/rust/agama-lib/src/security/store.rs b/rust/agama-lib/src/security/store.rs deleted file mode 100644 index 3b9b96fdd8..0000000000 --- a/rust/agama-lib/src/security/store.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) [2025] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements the store for the security settings. - -use super::{settings::SecuritySettings, SecurityHTTPClient, SecurityHTTPClientError}; -use crate::http::BaseHTTPClient; - -#[derive(Debug, thiserror::Error)] -#[error("Error processing security settings: {0}")] -pub struct SecurityStoreError(#[from] SecurityHTTPClientError); - -type SecurityStoreResult = Result; - -/// Loads and stores the security settings from/to the HTTP API. -pub struct SecurityStore { - security_client: SecurityHTTPClient, -} - -impl SecurityStore { - pub fn new(client: BaseHTTPClient) -> Self { - Self { - security_client: SecurityHTTPClient::new(client), - } - } - - pub async fn load(&self) -> SecurityStoreResult { - let fingerprints = self.security_client.get_ssl_fingerprints().await?; - let opt_fps = if fingerprints.is_empty() { - None - } else { - Some(fingerprints) - }; - Ok(SecuritySettings { - ssl_certificates: opt_fps, - }) - } - - pub async fn store(&self, settings: &SecuritySettings) -> SecurityStoreResult<()> { - if let Some(fingerprints) = &settings.ssl_certificates { - self.security_client - .set_ssl_fingerprints(fingerprints) - .await? - } - Ok(()) - } -} diff --git a/rust/agama-lib/src/store.rs b/rust/agama-lib/src/store.rs index ed6419df55..7caf43c6fb 100644 --- a/rust/agama-lib/src/store.rs +++ b/rust/agama-lib/src/store.rs @@ -27,7 +27,6 @@ use crate::{ http::BaseHTTPClient, install_settings::InstallSettings, network::{NetworkStore, NetworkStoreError}, - security::store::{SecurityStore, SecurityStoreError}, storage::{ http_client::{ iscsi::{ISCSIHTTPClient, ISCSIHTTPClientError}, @@ -52,8 +51,6 @@ pub enum StoreError { #[error(transparent)] Network(#[from] NetworkStoreError), #[error(transparent)] - Security(#[from] SecurityStoreError), - #[error(transparent)] Storage(#[from] StorageStoreError), #[error(transparent)] ISCSI(#[from] ISCSIHTTPClientError), @@ -74,7 +71,6 @@ pub struct Store { dasd: DASDStore, hostname: HostnameStore, network: NetworkStore, - security: SecurityStore, storage: StorageStore, iscsi_client: ISCSIHTTPClient, http_client: BaseHTTPClient, @@ -88,7 +84,6 @@ impl Store { dasd: DASDStore::new(http_client.clone()), hostname: HostnameStore::new(http_client.clone()), network: NetworkStore::new(http_client.clone()), - security: SecurityStore::new(http_client.clone()), storage: StorageStore::new(http_client.clone()), iscsi_client: ISCSIHTTPClient::new(http_client.clone()), zfcp: ZFCPStore::new(http_client.clone()), @@ -103,7 +98,6 @@ impl Store { dasd: self.dasd.load().await?, hostname: Some(self.hostname.load().await?), network: Some(self.network.load().await?), - security: self.security.load().await?.to_option(), zfcp: self.zfcp.load().await?, ..Default::default() }; @@ -127,11 +121,6 @@ impl Store { if let Some(network) = &settings.network { self.network.store(network).await?; } - // security has to be done before product to allow registration against - // self-signed RMT - if let Some(security) = &settings.security { - self.security.store(security).await?; - } let mut dirty_flag_set = false; // iscsi has to be done before storage if let Some(iscsi) = &settings.iscsi { diff --git a/rust/agama-server/src/lib.rs b/rust/agama-server/src/lib.rs index c721bc6e1c..a7a24e7134 100644 --- a/rust/agama-server/src/lib.rs +++ b/rust/agama-server/src/lib.rs @@ -24,7 +24,6 @@ pub mod dbus; pub mod error; pub mod logs; pub mod profile; -pub mod security; pub mod users; pub mod web; pub use web::service; diff --git a/rust/agama-server/src/web.rs b/rust/agama-server/src/web.rs index 01c46eb75b..0f889c1ec0 100644 --- a/rust/agama-server/src/web.rs +++ b/rust/agama-server/src/web.rs @@ -25,8 +25,7 @@ //! * Serve the code for the web user interface (not implemented yet). use crate::{ - bootloader::web::bootloader_service, profile::web::profile_service, security::security_service, - server::server_service, + bootloader::web::bootloader_service, profile::web::profile_service, server::server_service, }; use agama_utils::api::event; use axum::Router; @@ -61,7 +60,6 @@ where { let router = MainServiceBuilder::new(events.clone(), web_ui_dir) .add_service("/v2", server_service(events, dbus.clone()).await?) - .add_service("/security", security_service(dbus.clone()).await?) .add_service("/bootloader", bootloader_service(dbus.clone()).await?) .add_service("/profile", profile_service().await?) .with_config(config) diff --git a/rust/agama-server/src/web/docs/config.rs b/rust/agama-server/src/web/docs/config.rs index 664fcb6f11..05f18fc3f5 100644 --- a/rust/agama-server/src/web/docs/config.rs +++ b/rust/agama-server/src/web/docs/config.rs @@ -102,9 +102,6 @@ impl ApiDocBuilder for ConfigApiDocBuilder { .schema_from::() .schema_from::() .schema_from::() - .schema_from::() - .schema_from::() - .schema_from::() .schema_from::() .schema_from::() .schema_from::() From 80d044540353ae2f11a12652d732b95052231bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Mon, 9 Feb 2026 08:02:53 +0000 Subject: [PATCH 2/2] Drop the unused bootloader code --- rust/agama-lib/src/bootloader.rs | 27 ------ rust/agama-lib/src/bootloader/client.rs | 57 ------------ rust/agama-lib/src/bootloader/http_client.rs | 53 ----------- rust/agama-lib/src/bootloader/model.rs | 48 ---------- rust/agama-lib/src/bootloader/proxies.rs | 35 -------- rust/agama-lib/src/bootloader/store.rs | 55 ------------ rust/agama-lib/src/install_settings.rs | 3 - rust/agama-lib/src/lib.rs | 1 - rust/agama-lib/src/store.rs | 9 -- rust/agama-server/src/bootloader/web.rs | 93 -------------------- rust/agama-server/src/lib.rs | 1 - rust/agama-server/src/web.rs | 5 +- rust/agama-server/src/web/docs.rs | 2 - rust/agama-server/src/web/docs/bootloader.rs | 43 --------- rust/agama-server/src/web/docs/config.rs | 1 - 15 files changed, 1 insertion(+), 432 deletions(-) delete mode 100644 rust/agama-lib/src/bootloader.rs delete mode 100644 rust/agama-lib/src/bootloader/client.rs delete mode 100644 rust/agama-lib/src/bootloader/http_client.rs delete mode 100644 rust/agama-lib/src/bootloader/model.rs delete mode 100644 rust/agama-lib/src/bootloader/proxies.rs delete mode 100644 rust/agama-lib/src/bootloader/store.rs delete mode 100644 rust/agama-server/src/bootloader/web.rs delete mode 100644 rust/agama-server/src/web/docs/bootloader.rs diff --git a/rust/agama-lib/src/bootloader.rs b/rust/agama-lib/src/bootloader.rs deleted file mode 100644 index 24dbb6c8d2..0000000000 --- a/rust/agama-lib/src/bootloader.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements support for handling the bootloader settings - -pub mod client; -pub mod http_client; -pub mod model; -pub mod proxies; -pub mod store; diff --git a/rust/agama-lib/src/bootloader/client.rs b/rust/agama-lib/src/bootloader/client.rs deleted file mode 100644 index 10287522e4..0000000000 --- a/rust/agama-lib/src/bootloader/client.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements a client to access Agama's D-Bus API related to Bootloader management. - -use zbus::Connection; - -use crate::{ - bootloader::{model::BootloaderSettings, proxies::BootloaderProxy}, - error::ServiceError, -}; - -/// Client to connect to Agama's D-Bus API for Bootloader management. -#[derive(Clone)] -pub struct BootloaderClient<'a> { - bootloader_proxy: BootloaderProxy<'a>, -} - -impl<'a> BootloaderClient<'a> { - pub async fn new(connection: Connection) -> Result, ServiceError> { - let bootloader_proxy = BootloaderProxy::new(&connection).await?; - - Ok(Self { bootloader_proxy }) - } - - pub async fn get_config(&self) -> Result { - let serialized_string = self.bootloader_proxy.get_config().await?; - let settings = serde_json::from_str(serialized_string.as_str())?; - Ok(settings) - } - - pub async fn set_config(&self, config: &BootloaderSettings) -> Result<(), ServiceError> { - // ignore return value as currently it does not fail and who knows what future brings - // but it should not be part of result and instead transformed to ServiceError - self.bootloader_proxy - .set_config(serde_json::to_string(config)?.as_str()) - .await?; - Ok(()) - } -} diff --git a/rust/agama-lib/src/bootloader/http_client.rs b/rust/agama-lib/src/bootloader/http_client.rs deleted file mode 100644 index c186da202b..0000000000 --- a/rust/agama-lib/src/bootloader/http_client.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements a client to access Agama's HTTP API related to Bootloader management. - -use crate::{ - bootloader::model::BootloaderSettings, - http::{BaseHTTPClient, BaseHTTPClientError}, -}; - -#[derive(Debug, thiserror::Error)] -pub enum BootloaderHTTPClientError { - #[error(transparent)] - HTTP(#[from] BaseHTTPClientError), -} - -pub struct BootloaderHTTPClient { - client: BaseHTTPClient, -} - -impl BootloaderHTTPClient { - pub fn new(base: BaseHTTPClient) -> Self { - Self { client: base } - } - - pub async fn get_config(&self) -> Result { - Ok(self.client.get("/bootloader/config").await?) - } - - pub async fn set_config( - &self, - config: &BootloaderSettings, - ) -> Result<(), BootloaderHTTPClientError> { - Ok(self.client.put_void("/bootloader/config", config).await?) - } -} diff --git a/rust/agama-lib/src/bootloader/model.rs b/rust/agama-lib/src/bootloader/model.rs deleted file mode 100644 index 1f235e187f..0000000000 --- a/rust/agama-lib/src/bootloader/model.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements a data model for Bootloader configuration. - -use serde::{Deserialize, Serialize}; - -/// Represents a Bootloader -#[derive(Clone, Debug, Serialize, Deserialize, Default, utoipa::ToSchema)] -#[serde(rename_all = "camelCase")] -pub struct BootloaderSettings { - #[serde(skip_serializing_if = "Option::is_none")] - pub stop_on_boot_menu: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub timeout: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub extra_kernel_params: Option, -} - -impl BootloaderSettings { - pub fn to_option(self) -> Option { - if self.stop_on_boot_menu.is_none() - && self.timeout.is_none() - && self.extra_kernel_params.is_none() - { - None - } else { - Some(self) - } - } -} diff --git a/rust/agama-lib/src/bootloader/proxies.rs b/rust/agama-lib/src/bootloader/proxies.rs deleted file mode 100644 index 48e2543ed5..0000000000 --- a/rust/agama-lib/src/bootloader/proxies.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! # D-Bus interface proxy for: `org.opensuse.Agama.Storage1.Bootloader` -//! -//! This code was generated by `zbus-xmlgen` `5.0.1` from D-Bus introspection data. -//! Source: `org.opensuse.Agama.Storage1.bus.xml`. -//! -//! You may prefer to adapt it, instead of using it verbatim. -//! -//! More information can be found in the [Writing a client proxy] section of the zbus -//! documentation. -//! -//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the -//! following zbus API can be used: -//! -//! * [`zbus::fdo::IntrospectableProxy`] -//! * [`zbus::fdo::ObjectManagerProxy`] -//! * [`zbus::fdo::PropertiesProxy`] -//! -//! Consequently `zbus-xmlgen` did not generate code for the above interfaces. -//! -//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html -//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces, -use zbus::proxy; -#[proxy( - default_service = "org.opensuse.Agama.Storage1", - default_path = "/org/opensuse/Agama/Storage1", - interface = "org.opensuse.Agama.Storage1.Bootloader", - assume_defaults = true -)] -pub trait Bootloader { - /// GetConfig method - fn get_config(&self) -> zbus::Result; - - /// SetConfig method - fn set_config(&self, serialized_config: &str) -> zbus::Result; -} diff --git a/rust/agama-lib/src/bootloader/store.rs b/rust/agama-lib/src/bootloader/store.rs deleted file mode 100644 index fc6dbf13be..0000000000 --- a/rust/agama-lib/src/bootloader/store.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! Implements the store for the bootloader settings. - -use super::{ - http_client::{BootloaderHTTPClient, BootloaderHTTPClientError}, - model::BootloaderSettings, -}; -use crate::http::BaseHTTPClient; - -// FIXME: should we follow this approach more often? -type BootloaderStoreResult = Result; - -#[derive(Debug, thiserror::Error)] -#[error("Error processing bootloader settings: {0}")] -pub struct BootloaderStoreError(#[from] BootloaderHTTPClientError); - -/// Loads and stores the bootloader settings from/to the HTTP service. -pub struct BootloaderStore { - bootloader_client: BootloaderHTTPClient, -} - -impl BootloaderStore { - pub fn new(client: BaseHTTPClient) -> Self { - Self { - bootloader_client: BootloaderHTTPClient::new(client), - } - } - - pub async fn load(&self) -> BootloaderStoreResult> { - Ok(self.bootloader_client.get_config().await?.to_option()) - } - - pub async fn store(&self, settings: &BootloaderSettings) -> BootloaderStoreResult<()> { - Ok(self.bootloader_client.set_config(settings).await?) - } -} diff --git a/rust/agama-lib/src/install_settings.rs b/rust/agama-lib/src/install_settings.rs index d4d3c38745..6088d77472 100644 --- a/rust/agama-lib/src/install_settings.rs +++ b/rust/agama-lib/src/install_settings.rs @@ -21,7 +21,6 @@ //! Configuration settings handling //! //! This module implements the mechanisms to load and store the installation settings. -use crate::bootloader::model::BootloaderSettings; use crate::context::InstallationContext; use crate::hostname::model::HostnameSettings; use crate::storage::settings::zfcp::ZFCPConfig; @@ -46,8 +45,6 @@ pub enum InstallSettingsError { #[derive(Clone, Debug, Default, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "camelCase")] pub struct InstallSettings { - #[serde(skip_serializing_if = "Option::is_none")] - pub bootloader: Option, #[serde(skip_serializing_if = "Option::is_none")] pub dasd: Option, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/rust/agama-lib/src/lib.rs b/rust/agama-lib/src/lib.rs index d670da9c47..4e3a22d3bd 100644 --- a/rust/agama-lib/src/lib.rs +++ b/rust/agama-lib/src/lib.rs @@ -44,7 +44,6 @@ //! As said, those modules might implement additional stuff, like specific types, clients, etc. pub mod auth; -pub mod bootloader; pub mod context; pub mod error; pub mod hostname; diff --git a/rust/agama-lib/src/store.rs b/rust/agama-lib/src/store.rs index 7caf43c6fb..4b8bfe28fd 100644 --- a/rust/agama-lib/src/store.rs +++ b/rust/agama-lib/src/store.rs @@ -22,7 +22,6 @@ // TODO: quickly explain difference between FooSettings and FooStore, with an example use crate::{ - bootloader::store::{BootloaderStore, BootloaderStoreError}, hostname::store::{HostnameStore, HostnameStoreError}, http::BaseHTTPClient, install_settings::InstallSettings, @@ -42,8 +41,6 @@ use crate::{ #[derive(Debug, thiserror::Error)] pub enum StoreError { - #[error(transparent)] - Bootloader(#[from] BootloaderStoreError), #[error(transparent)] DASD(#[from] DASDStoreError), #[error(transparent)] @@ -67,7 +64,6 @@ pub enum StoreError { /// /// This struct uses the default connection built by [connection function](super::connection). pub struct Store { - bootloader: BootloaderStore, dasd: DASDStore, hostname: HostnameStore, network: NetworkStore, @@ -80,7 +76,6 @@ pub struct Store { impl Store { pub async fn new(http_client: BaseHTTPClient) -> Result { Ok(Self { - bootloader: BootloaderStore::new(http_client.clone()), dasd: DASDStore::new(http_client.clone()), hostname: HostnameStore::new(http_client.clone()), network: NetworkStore::new(http_client.clone()), @@ -94,7 +89,6 @@ impl Store { /// Loads the installation settings from the HTTP interface. pub async fn load(&self) -> Result { let mut settings = InstallSettings { - bootloader: self.bootloader.load().await?, dasd: self.dasd.load().await?, hostname: Some(self.hostname.load().await?), network: Some(self.network.load().await?), @@ -147,9 +141,6 @@ impl Store { if settings.storage.is_some() || settings.storage_autoyast.is_some() { self.storage.store(&settings.into()).await? } - if let Some(bootloader) = &settings.bootloader { - self.bootloader.store(bootloader).await?; - } if let Some(hostname) = &settings.hostname { self.hostname.store(hostname).await?; } diff --git a/rust/agama-server/src/bootloader/web.rs b/rust/agama-server/src/bootloader/web.rs deleted file mode 100644 index eb86437ad5..0000000000 --- a/rust/agama-server/src/bootloader/web.rs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -//! This module implements the web API for the bootloader service. -//! -//! The module offers one public function: -//! -//! * `bootloader_service` which returns the Axum service. -//! -//! stream is not needed, as we do not need to emit signals (for NOW). - -use agama_lib::{ - bootloader::{client::BootloaderClient, model::BootloaderSettings}, - error::ServiceError, -}; -use axum::{extract::State, routing::put, Json, Router}; - -use crate::error; - -#[derive(Clone)] -struct BootloaderState<'a> { - client: BootloaderClient<'a>, -} - -/// Sets up and returns the axum service for the bootloader module. -pub async fn bootloader_service(dbus: zbus::Connection) -> Result { - let client = BootloaderClient::new(dbus).await?; - let state = BootloaderState { client }; - let router = Router::new() - .route("/config", put(set_config).get(get_config)) - .with_state(state); - Ok(router) -} - -/// Returns the bootloader configuration. -/// -/// * `state` : service state. -#[utoipa::path( - get, - path = "/config", - context_path = "/api/bootloader", - operation_id = "get_bootloader_config", - responses( - (status = 200, description = "bootloader configuration", body = BootloaderSettings), - (status = 400, description = "The D-Bus service could not perform the action") - ) -)] -async fn get_config( - State(state): State>, -) -> Result, error::Error> { - // BootloaderSettings is just a wrapper over serde_json::value::RawValue - let settings = state.client.get_config().await?; - Ok(Json(settings)) -} - -/// Sets the bootloader configuration. -/// -/// * `state`: service state. -/// * `config`: bootloader configuration. -#[utoipa::path( - put, - path = "/config", - context_path = "/api/bootloader", - operation_id = "set_bootloader_config", - responses( - (status = 200, description = "Set the bootloader configuration"), - (status = 400, description = "The D-Bus service could not perform the action") - ) -)] -async fn set_config( - State(state): State>, - Json(settings): Json, -) -> Result, error::Error> { - state.client.set_config(&settings).await?; - Ok(Json(())) -} diff --git a/rust/agama-server/src/lib.rs b/rust/agama-server/src/lib.rs index a7a24e7134..9085d86b91 100644 --- a/rust/agama-server/src/lib.rs +++ b/rust/agama-server/src/lib.rs @@ -18,7 +18,6 @@ // To contact SUSE LLC about this file by physical or electronic mail, you may // find current contact information at www.suse.com. -pub mod bootloader; pub mod cert; pub mod dbus; pub mod error; diff --git a/rust/agama-server/src/web.rs b/rust/agama-server/src/web.rs index 0f889c1ec0..87dece3e1e 100644 --- a/rust/agama-server/src/web.rs +++ b/rust/agama-server/src/web.rs @@ -24,9 +24,7 @@ //! * Emit relevant events via websocket. //! * Serve the code for the web user interface (not implemented yet). -use crate::{ - bootloader::web::bootloader_service, profile::web::profile_service, server::server_service, -}; +use crate::{profile::web::profile_service, server::server_service}; use agama_utils::api::event; use axum::Router; @@ -60,7 +58,6 @@ where { let router = MainServiceBuilder::new(events.clone(), web_ui_dir) .add_service("/v2", server_service(events, dbus.clone()).await?) - .add_service("/bootloader", bootloader_service(dbus.clone()).await?) .add_service("/profile", profile_service().await?) .with_config(config) .build(); diff --git a/rust/agama-server/src/web/docs.rs b/rust/agama-server/src/web/docs.rs index 4a892b2b6d..99ae223305 100644 --- a/rust/agama-server/src/web/docs.rs +++ b/rust/agama-server/src/web/docs.rs @@ -22,8 +22,6 @@ use utoipa::openapi::{Components, Info, InfoBuilder, OpenApi, OpenApiBuilder, Pa mod config; pub use config::ConfigApiDocBuilder; -mod bootloader; -pub use bootloader::BootloaderApiDocBuilder; mod profile; pub use profile::ProfileApiDocBuilder; mod misc; diff --git a/rust/agama-server/src/web/docs/bootloader.rs b/rust/agama-server/src/web/docs/bootloader.rs deleted file mode 100644 index 974efa9135..0000000000 --- a/rust/agama-server/src/web/docs/bootloader.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) [2024] SUSE LLC -// -// All Rights Reserved. -// -// This program is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, contact SUSE LLC. -// -// To contact SUSE LLC about this file by physical or electronic mail, you may -// find current contact information at www.suse.com. - -use utoipa::openapi::{Components, ComponentsBuilder, Paths, PathsBuilder}; - -use super::ApiDocBuilder; -pub struct BootloaderApiDocBuilder; - -impl ApiDocBuilder for BootloaderApiDocBuilder { - fn title(&self) -> String { - "Bootloader HTTP API".to_string() - } - - fn paths(&self) -> Paths { - PathsBuilder::new() - .path_from::() - .path_from::() - .build() - } - - fn components(&self) -> Components { - ComponentsBuilder::new() - .schema_from::() - .build() - } -} diff --git a/rust/agama-server/src/web/docs/config.rs b/rust/agama-server/src/web/docs/config.rs index 05f18fc3f5..b1e18695b0 100644 --- a/rust/agama-server/src/web/docs/config.rs +++ b/rust/agama-server/src/web/docs/config.rs @@ -49,7 +49,6 @@ impl ApiDocBuilder for ConfigApiDocBuilder { .schema("IpAddr", schemas::ip_addr()) .schema("IpInet", schemas::ip_inet()) .schema("macaddr.MacAddr6", schemas::mac_addr6()) - .schema_from::() .schema_from::() .schema_from::() .schema_from::()