From: Ian Jackson Date: Sun, 2 May 2021 23:26:35 +0000 (+0100) Subject: config: Only chdir in server (!), actually X-Git-Tag: otter-0.6.0~461 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ad93302113522c073d2728bbf1fe015b09306c24;p=otter.git config: Only chdir in server (!), actually Signed-off-by: Ian Jackson --- 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); }