diff --git a/src/config.rs b/src/config.rs index eb765b092e6..a718395752f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,9 @@ use std::env::consts::EXE_SUFFIX; use std::process::exit; -use std::sync::RwLock; +use std::sync::{ + atomic::{AtomicBool, Ordering}, + RwLock, +}; use job_scheduler_ng::Schedule; use once_cell::sync::Lazy; @@ -17,6 +20,8 @@ static CONFIG_FILE: Lazy = Lazy::new(|| { get_env("CONFIG_FILE").unwrap_or_else(|| format!("{data_folder}/config.json")) }); +pub static SKIP_CONFIG_VALIDATION: Lazy = Lazy::new(|| AtomicBool::new(false)); + pub static CONFIG: Lazy = Lazy::new(|| { Config::load().unwrap_or_else(|e| { println!("Error loading config:\n {e:?}\n"); @@ -1105,7 +1110,9 @@ impl Config { // Fill any missing with defaults let config = builder.build(); - validate_config(&config)?; + if !SKIP_CONFIG_VALIDATION.load(Ordering::SeqCst) { + validate_config(&config)?; + } Ok(Config { inner: RwLock::new(Inner { diff --git a/src/db/models/emergency_access.rs b/src/db/models/emergency_access.rs index e1b85ec6153..f4f3b9a9c2a 100644 --- a/src/db/models/emergency_access.rs +++ b/src/db/models/emergency_access.rs @@ -26,7 +26,7 @@ db_object! { } } -/// Local methods +// Local methods impl EmergencyAccess { pub fn new(grantor_uuid: String, email: String, status: i32, atype: i32, wait_time_days: i32) -> Self { diff --git a/src/main.rs b/src/main.rs index a46b75493f4..c4e1029a514 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,7 @@ use crate::api::{WS_ANONYMOUS_SUBSCRIPTIONS, WS_USERS}; pub use config::CONFIG; pub use error::{Error, MapResult}; use rocket::data::{Limits, ToByteUnit}; -use std::sync::Arc; +use std::sync::{atomic::Ordering, Arc}; pub use util::is_running_in_container; #[rocket::main] @@ -125,6 +125,7 @@ fn parse_args() { print!("{HELP}"); exit(0); } else if pargs.contains(["-v", "--version"]) { + config::SKIP_CONFIG_VALIDATION.store(true, Ordering::SeqCst); let web_vault_version = util::get_web_vault_version(); println!("Vaultwarden {version}"); println!("Web-Vault {web_vault_version}");