From 82102c0d170ae5e23f0805a9c97ab09a8b6b7820 Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Fri, 24 Sep 2021 10:49:04 -0700 Subject: [PATCH] trim whitespace from /etc/timezone --- CHANGELOG.md | 4 ++++ server/src/cmds/run.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23b7860..b5c1a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ changes, see Git history. Each release is tagged in Git and on the Docker repository [`scottlamb/moonfire-nvr`](https://hub.docker.com/r/scottlamb/moonfire-nvr). +## unreleased + +* trim whitespace when detecting time zone by reading `/etc/timezone`. + ## `v0.6.6` (2021-09-23) * fix [#146](https://github.com/scottlamb/moonfire-nvr/issues/146): "init diff --git a/server/src/cmds/run.rs b/server/src/cmds/run.rs index 217fda4..edaad9b 100644 --- a/server/src/cmds/run.rs +++ b/server/src/cmds/run.rs @@ -149,9 +149,9 @@ fn resolve_zone() -> Result { } }; - // If `TIMEZONE_PATH` is a file, use its contents as the zone name. + // If `TIMEZONE_PATH` is a file, use its contents as the zone name, trimming whitespace. match ::std::fs::read_to_string(TIMEZONE_PATH) { - Ok(z) => Ok(z), + Ok(z) => Ok(z.trim().to_owned()), Err(e) => { bail!( "Unable to resolve timezone from TZ env, {}, or {}. Last error: {}",