From ad93302113522c073d2728bbf1fe015b09306c24 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 00:26:35 +0100 Subject: [PATCH] config: Only chdir in server (!), actually Signed-off-by: Ian Jackson --- daemon/main.rs | 3 ++- src/bin/otter.rs | 2 +- src/config.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/daemon/main.rs b/daemon/main.rs index 84c46ca8..41fc1e80 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -262,7 +262,8 @@ fn main() { let opts = Opts::from_args(); - ServerConfig::read(opts.config_filename.as_ref().map(String::as_str))?; + ServerConfig::read(opts.config_filename.as_ref().map(String::as_str), + ResolveContext::ForServerReal)?; std::env::set_var("ROCKET_CLI_COLORS", "off"); diff --git a/src/bin/otter.rs b/src/bin/otter.rs index edf02006..780b6406 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -364,7 +364,7 @@ fn main() { "config file", "etc", DEFAULT_CONFIG_LEAFNAME, ".") }); - ServerConfig::read(Some(&config_filename)) + ServerConfig::read(Some(&config_filename), default()) .context("read config file")?; Ok::<_,AE>((otter::config::config(), config_filename)) })().map_err(|e| ArgumentParseError( diff --git a/src/config.rs b/src/config.rs index ac199a78..ddc6b10a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -229,7 +229,7 @@ fn set_config(whole: WholeServerConfig) { impl ServerConfig { #[throws(StartupError)] - pub fn read(config_filename: Option<&str>) { + pub fn read(config_filename: Option<&str>, rctx: ResolveContext) { let config_filename = config_filename.map(|s| s.to_string()) .unwrap_or_else( || format!("{}/{}", DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_LEAFNAME) @@ -238,7 +238,7 @@ impl ServerConfig { File::open(&config_filename).with_context(||config_filename.to_string())? .read_to_string(&mut buf)?; let spec: ServerConfigSpec = toml_de::from_str(&buf)?; - let whole = spec.resolve(ResolveContext::ForServerReal)?; + let whole = spec.resolve(rctx)?; set_config(whole); } -- 2.30.2