diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-22 01:23:41 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-22 01:23:41 -0400 |
commit | 63601c5ebb22c2c1c0f0b079a723aba961b337d1 (patch) | |
tree | 2c4ee54a2c0d5b59dbd870808ec2cab9cf84e323 /src/config.rs | |
parent | 1bc09a9c74d0d1c47d1b88b5833ad8174fc04928 (diff) | |
download | rbw-63601c5ebb22c2c1c0f0b079a723aba961b337d1.tar.gz rbw-63601c5ebb22c2c1c0f0b079a723aba961b337d1.zip |
don't allow setting lock_timeout to 0
this isn't useful, because the agent will just drop the keys as soon as
they are unlocked, before they can be used to decrypt anything
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs index caa27a6..39044c0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,8 +27,12 @@ impl Config { let mut json = String::new(); fh.read_to_string(&mut json) .context(crate::error::LoadConfig)?; - let slf: Self = serde_json::from_str(&json) + let mut slf: Self = serde_json::from_str(&json) .context(crate::error::LoadConfigJson)?; + if slf.lock_timeout == 0 { + log::warn!("lock_timeout must be greater than 0"); + slf.lock_timeout = default_lock_timeout(); + } Ok(slf) } @@ -40,8 +44,12 @@ impl Config { fh.read_to_string(&mut json) .await .context(crate::error::LoadConfigAsync)?; - let slf: Self = serde_json::from_str(&json) + let mut slf: Self = serde_json::from_str(&json) .context(crate::error::LoadConfigJson)?; + if slf.lock_timeout == 0 { + log::warn!("lock_timeout must be greater than 0"); + slf.lock_timeout = default_lock_timeout(); + } Ok(slf) } |