[pbs-devel] [PATCH proxmox-backup 10/14] config: use new dedicated PAM and PBS realm types

Lukas Wagner l.wagner at proxmox.com
Wed Aug 7 11:24:19 CEST 2024


On  2024-07-16 15:45, Christoph Heiss wrote:
> diff --git a/src/config/mod.rs b/src/config/mod.rs
> index 324fabca..3931eee9 100644
> --- a/src/config/mod.rs
> +++ b/src/config/mod.rs
> @@ -12,6 +12,7 @@ use std::path::Path;
>  
>  use proxmox_lang::try_block;
>  
> +use pbs_api_types::{PamRealmConfig, PbsRealmConfig};
>  use pbs_buildcfg::{self, configdir};
>  
>  pub mod acme;
> @@ -194,3 +195,36 @@ pub(crate) fn set_proxy_certificate(cert_pem: &[u8], key_pem: &[u8]) -> Result<(
>  
>      Ok(())
>  }
> +
> +pub fn update_default_realms() -> Result<(), Error> {
> +    let _lock = pbs_config::domains::lock_config()?;
> +    let (mut domains, _) = pbs_config::domains::config()?;
> +
> +    if !pbs_config::domains::exists(&domains, "pam") {
> +        domains.set_data(
> +            "pam",
> +            "pam",
> +            PamRealmConfig {
> +                realm: "pam".to_owned(),
> +                comment: Some("Linux PAM standard authentication".to_owned()),
> +                // Setting it as default here is safe, because if we perform this
> +                // migration, the user had not had any chance to set a custom default anyway.
> +                default: Some(true),
> +            },
> +        )?;
> +    }
> +
> +    if !pbs_config::domains::exists(&domains, "pbs") {
> +        domains.set_data(
> +            "pbs",
> +            "pbs",
> +            PbsRealmConfig {
> +                realm: "pbs".to_owned(),
> +                comment: Some("Proxmox Backup authentication server".to_owned()),
> +                default: None,
> +            },
> +        )?;
> +    }

Just wondering, would it be a good idea to encode these defaults as
the `Default::default()` impl for these two types? What do you think?

> +
> +    pbs_config::domains::save_config(&domains)
> +}

-- 
- Lukas




More information about the pbs-devel mailing list